When 'autoInitialize' = false, Chat will not make any calls to the Halo API until the intialize event is sent.
This function sends the "haloChat_inboundEvent_initialize" event.
When chat is ready it will respond with event "haloChat_outboundEvent_initialized" and event.detail.chatAvailable will either be true or false depending on if the Chat Profile is available at the current time.
Chat will still auto-initialize if there is an ongoing conversation when the page refreshes.
You can also override the chat profile when Initializing the chat to select a different profile at runtime.
Not connected
Identity Token Management and Opening Chat
The Open Chat button sends the "haloChat_inboundEvent_openChatWindow" event to chat, along with the Identity Token JWT entered below. If there is not currently a conversation in progress, this function will begin a new chat with the identity token specified, and open the conversation window. If there is already a conversation in progress, it will open the conversation window only and not use the Identity Token.
The Identity token is optional - if not specified the chat will behave as if you are not logged in. If specified it will either create a user or match to an existing user in Halo, and act as if you are authenticated as that user.
When a new conversation is created with an Identity token a Chat session cookie will be issued and that is used to retain access to the conversation.
You can also alter the start step of the flow by specifying the id of the step. The step must be configured as an allowed start step in the chat flow config in Halo to do this.
The "Upgrade Anon Chat to Authenticated Chat" button sends the "haloChat_inboundEvent_upgradeAnonChat" event to chat. This expects an Identity token. If there is an open Anonymous chat, this will upgrade the chat to an Authenticated Chat using the identity token. This page listens to the haloChat_outboundEvent_upgradeAnonChat event to report the result.
The "Login Changed / Logout / Clear Session" button sends the "haloChat_inboundEvent_loginStateChanged" event to chat. This effectively ends the current session, removing the conversation and Chat session cookie, allowing you to then open a new conversation with a different identity token. This function should be called when the authenticated user changes or logs out.
This will get passed to the New Chat / Open Chat Window function (when there isn't an open conversation), and the Upgrade Anon Chat to Authenticated Chat function.
Chat Controls
These are additional functions that allow you to control the chat window using Javascript events
You can also drag the Chat bubble around this page. This uses the "haloChat_inboundEvent_repositionBubble" to update it's position.
Getting Chat Data
This demonstrates how to get the information regarding the current state of Halo Chat.
"Get Chat Data" calls a function in Halo Chat to retrieve information on the current open chat, such as unread count, and messages.
When new messages are received Halo Chat uses the haloChat_outboundEvent_newMessage outbound event to send this page information about the new message.
Data from additional outbound events will show in the Javascript console.