![](https://www.infallibletechie.com/wp-content/uploads/2024/03/Launch-Salesforce-Messaging-for-In-App-and-Web-on-button-click-1024x576.jpg)
embeddedservice_bootstrap.utilAPI.launchChat() can be used to launch Salesforce Messaging for In-App and Web on a button click.
Sample Code:
<html>
<!--
Copy Paste the Embedded Service Code Snippet here
-->
<button id="launchChatButton" onclick="launchChat()">
Chat with our Agents!!!
</button>
<script>
function launchChat() {
embeddedservice_bootstrap.utilAPI.launchChat()
.then(() => {
console.log(
'Inside Launch Chat'
);
}).catch(() => {
console.log(
'Inside Launch Chat catch Block'
);
}).finally(() => {
console.log(
'Inside Launch Chat finally Block'
);
});
}
</script>
</html>
Output:
![](https://www.infallibletechie.com/wp-content/uploads/2024/03/Salesforce-Messaging-for-In-App-and-Web-Button-Click-Launching.png)