Open the AI component
Txt.openChat({ conversationName: "AI assistant", prompt: "Who is the CTO of Unless?",})Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
conversationName | string (optional) | A conversation name of this particular chat session. You can use this to separate different conversations. |
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 | array (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. |
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. |
Check if the component is open
Section titled “Check if the component is open”Txt.isChatOpen()Close the component
Section titled “Close the component”Txt.closeChat()Chat closed event
Section titled “Chat closed event”When the user closes the chat via the close button:
document.addEventListener('unless.chat-closed', () => { console.log('chat was closed')})