Txt.openChat({
conversationName: "AI assistant",
prompt: "Who is the CTO of Unless?"
})| Argument | Type | Description |
|---|---|---|
| conversationName | string (optional) | A conversation name of this particular chat session. You can use this to separate different conversations. The conversation name will show up in the top left corner of the popover. |
| prompt | string (optional) | Generates a hidden prompt that triggers the AI to answer directly to the user. |
| promptLabel | string (optional) | If set, this shows as the label in the AI chat instead of the full prompt. |
| segments | { name: string, id: string, description: string } [] (optional) | Note; a segment is called a Topic in the dashboard. If you supply multiple topics here, the user will be forced to choose one of the topics before continuing. |
| mode | string (optional) | One of the following: 'sidebar' or 'conversation-center' or 'popover'. Defines if the chat will open in a popover, or in an overlay conversation center. Note: to start a chat in popover mode, a target must be defined. |
| target | DOM Element (optional) | A target element on the page that you can attach the AI popover to, usually this is the button the user clicked on. |
Current AI component state
Txt.isChatOpen() Close the AI component
Txt.closeChat()When the Ai components gets closed using the close button we throw the following event.
document.dispatchEvent(new CustomEvent('unless.chat-closed'))
// you can listen for this event using
document.addEventListener('unless.chat-closed', () => console.log('closed'))