Get Started With APIs for Messaging for Web

To use the JavaScript APIs for Messaging for Web, add the code snippet provided by Salesforce from your deployment settings to your web page. See Messaging for Web Reference for more details on the APIs.

Here are the steps to configure your web page to use the Messaging for Web APIs.

  1. From Setup, in the Quick Find box, enter Embedded Service Deployments, and select Embedded Service Deployments. See Configure a Messaging for Web Deployment in Salesforce Help.

  2. Click Code Snippet.

    Messaging for Web Code Snippet

  3. To retrieve the code snippet, follow the on-screen instructions.

    Messaging for Web Code Snippet

  4. Add the code snippet to your web page. Here’s an example of a code snippet.

  5. Add the Messaging for Web APIs to your web page. You can call the APIs inside or outside the code snippet, but call them after the client dispatches the onEmbeddedMessagingReady event. If you call the APIs before receiving this event, they don't execute.

    If your Messaging for Web deployment is on an Experience Cloud site, follow the instructions in Salesforce Help to add JavaScript code to the head markup section of your site. See Configure a Messaging for Web Deployment in an Experience Builder Site in Salesforce Help.

  6. To ensure that Messaging for Web works optimally, always republish your deployment after testing newly added features and bug fixes. See Configure a Messaging for Web Deployment in Salesforce Help.