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 | SETbubble.text(text?: string): Promise<string>
api.bubble.text('This is a new text. The old text will be overwritten.')
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.
SETbubble.addText(text: string): Promise<string>
api.bubble.addText('This is a new text added to the old text.')
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.
SETbubble.deleteText(): Promise<string>
api.bubble.deleteText()
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 | SETbubble.buttons(buttons?: Array): Promise<Array>
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.
GETbubble.getButton(index?: number): Promise<Object>
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.
SETbubble.addButton(button: Object): Promise<Object>
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.
SETbubble.deleteButton(index: number): Promise<Array>
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 | SETbubble.language(language?: string): Promise<string>
api.bubble.language().then((language) => console.log(language))
// 'de'
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 | SETbubble.setEnabled(status?: boolean): Promise<boolean>
api.bubble.setEnabled(false)
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.
GETbubble.reload(): Promise<void>
api.bubble.reload()
bubble.speak
Speak the text of the current visible speechbubble. When the speech is finished the promise will be resolved.
GETbubble.speak(): Promise<void>
api.bubble.speak().then(() => console.log('Speech finished'))