Skip to content

Speechbubble

The speechbubble is the main element of the rooomAssistant. It shows text and buttons to the user. The text and buttons can be changed dynamically via the API. the language of the text can be changed via the language selector.

Text

Text is shown on top of the speechbubble. It can be changed dynamically via the API. Remember that that it only changes the text that is currently visible. The text stored in the state will remain unchanged!

bubble.text

Alters the text of the current visible speechbubble. The text stored in the state will remain unchanged. If no argument is provided, the current text will be returned.

GET | SET bubble.text(text?: string): Promise<string>
js
api.bubble.text('This is a new text. The old text will be overwritten.')
js
actions: [{ name: 'bubble.text', arg: 'This is a new text. The old text will be overwritten.' }]

bubble.addText

Append text to the current visible speechbubble. The text stored in the state will remain unchanged. The result will be the new text.

SET bubble.addText(text: string): Promise<string>
js
api.bubble.addText('This is a new text added to the old text.')
js
actions: [{ name: 'bubble.addText', arg: 'This is a new text added to the old text.' }]

bubble.deleteText

Delete the text of the current visible speechbubble. The text stored in the state will remain unchanged. The result will be the new text.

SET bubble.deleteText(): Promise<string>
js
api.bubble.deleteText()
js
actions: [{ name: 'bubble.deleteText' }]

Buttons

Buttons are shown below the text. They can be changed dynamically via the API. You can add, remove or change buttons. Remember that it only changes the buttons that are currently visible. The buttons stored in the state will remain unchanged!

bubble.buttons

Gets or Sets the buttons of the current visible speechbubble. The buttons stored in the state will remain unchanged. If no argument is provided, the current array of buttons will be returned.

GET | SET bubble.buttons(buttons?: Array): Promise<Array>
js
api.bubble.buttons([
	{
		text: 'I am a button',
		actions: [{ name: 'states.set', arg: 'next' }],
	},
	// ... more buttons
])

bubble.getButton

Gets a button of the current visible speechbubble by index. The buttons stored in the state will remain unchanged. The result will be the button.

GET bubble.getButton(index?: number): Promise<Object>
js
api.bubble.getButton(1).then((button) => console.log(button))
// { text: 'I am a button', actions: [{ name: 'states.set', arg: 'next' }] }

bubble.addButton

Add a button to the current visible speechbubble. The buttons stored in the state will remain unchanged.

SET bubble.addButton(button: Object): Promise<Object>
js
api.bubble.addButton({
	text: 'I am a button',
	actions: [{ name: 'states.set', arg: 'next' }],
})

bubble.deleteButton

Delete a button of the current visible speechbubble by index. The buttons stored in the state will remain unchanged. The result will be the new array of buttons.

SET bubble.deleteButton(index: number): Promise<Array>
js
api.bubble.deleteButton(1)

General

bubble.language

Change the language of the current visible speechbubble. If the language is not supported, the first language will be used. If no argument is provided, the current language will be returned. The result will be the language.

GET | SET bubble.language(language?: string): Promise<string>
js
api.bubble.language().then((language) => console.log(language))
// 'de'
js
actions: [{ name: 'bubble.language', arg: 'de' }]

bubble.setEnabled

Show or hide the speechbubble. If no argument is provided, the current status will be returned.

GET | SET bubble.setEnabled(status?: boolean): Promise<boolean>
js
api.bubble.setEnabled(false)
js
actions: [{ name: 'bubble.setEnabled', arg: false }]

bubble.reload

Reload the speechbubble. This is useful when language has changed or when you want to reset the speechbubble.

GET bubble.reload(): Promise<void>
js
api.bubble.reload()

bubble.speak

Speak the text of the current visible speechbubble. When the speech is finished the promise will be resolved.

GET bubble.speak(): Promise<void>
js
api.bubble.speak().then(() => console.log('Speech finished'))