Overview¶
Prisme.ai allows you to interact with the bot through a javascript API.
In window scope, a prismeai
namespace is now available so you can access it with window.prismeai
. It offers the following methods:
Action API¶
Toggle dialogbox¶
prismeai.action({ type: 'toggle', value: true })
Open the dialogbox.
prismeai.action({ type: 'toggle', value: false })
Close the dialogbox.
Reset conversation¶
prismeai.action({ type: 'resetConversation' })
This will clear the current conversation and start a new one.
Push text in dialogbox¶
prismeai.action({ type: 'text', value: 'Some text message' })
Send 'Some text message' to the bot as if the user typed it.
Push event in dialogbox¶
prismeai.action({ type: 'event', value: {
text: 'Some text message',
event: 'Event name
}
})
Push content to panel¶
prismeai.action({ type: 'pushPanelItems', value:
[
{
title: 'this is the panel title',
text: '<p>this is the panel content </p>',
isActive: true
},
{
title: 'this is the second page title',
text: '<p>this is the second page panel content </p>',
isActive: true
}
]
});
Open or close the panel¶
prismeai.action({ type: 'togglePanel', value: false })
This example closes the panel. Setting value
to true will instead open it.
Listening to Dialogbox events¶
Clicks on elements¶
prismeai.on('click', callback)
Listen to the "click" event, which triggers the callback method provided when triggered. The event provided to the callback has multiple properties :
Message¶
This object is defined if a chat message was clicked. It has the following properties:
- type: can be button, event, link, or linkInText.
The latter is used for a link in a text message.
- text: Clickable element's text, or the whole message's text content if a linkInText.
- value: the url if it is a link or linkInText.
The target event if an event, or the text to trigger if a button
- fromFAQ: Is 'true' if the element was in a FAQ's panel, 'false' otherwise.
Unavailable for 'linkInText' elements.
FAQ¶
The FAQ object is defined if the click was from the FAQ page. Its properties are :
- intentName: name of the intent.
- question: disambiguation sentence.
- responseText: The first text message of this intent.
- response: The elements displayed in the panel when the FAQ element was clicked.
Action¶
Its value can be:
- stopSpeaking: When the voice recording stops
- stopRecording: On native app, when the voice recording stops
- voiceRecognition: On native app, when the voice recording starts
Message received by user¶
prismeai.on('messageReceived', callback)
This event contains the message object including the following properties:
- botName: name of the bot
- confidence: the NLU's confidence
- intent: the intent's name