Launch Chat in Messaging for Web
This release is in preview. Features described here don’t become generally available until Winter ’23.
When Launch Chat API launches the chat client, the client opens in its initial state, for example, a pre-chat dialog if prechat is configured in setup or a chat state otherwise. The initial state depends on how you configured the messaging deployment.
To call this API, use the
utilAPI.launchChat() method. Here’s an example code for a Messaging for Web client. To find out how to get to the Code Snippet page that contains the code to initialize the Messaging for Web client, see Introduction.
Use the event handlers in the
utilAPI.launchChat() method to perform actions after the chat launches.
thenevent handler—If the client launches successfully, you can use this handler to, for example, hide the chat invitation or custom button.
catchevent handler—If there’s an error launching the client, you can use this handler to, for example, display an error message.
finallyevent handler—The method runs this handler after the client launches successfully or not. Use this handler to run any clean-up actions.
For more details, see the Messaging for Web reference documentation.