How to launch Salesforce Messaging for In-App and Web on button click?

How to launch Salesforce Messaging for In-App and Web on button click?

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:

Leave a Reply