Auto-Responses in Messaging for Web

The auto-response API allows you to pass parameters to Salesforce so that you can provide additional data to the auto-response messaging component when showing the user a web page such as a survey. To learn about and set up auto-response components, see Create a Messaging Component: Auto-Response.

You build out the auto-response experience from within Salesforce Setup, but you can also use the Auto-Response JavaScript API to add or remove URL query parameters that get sent to the URL configured in the auto-response Messaging component in Salesforce Setup. This section describes the steps to take from your web client to add or remove parameters. See the associated documentation for each step of this sequence.

Auto-response sequence

  1. Before you initialize the API from the code snippet that we provide, add an event listener for onEmbeddedMessagingReady. This method notifies you when the API is ready for requests.
  2. After the onEmbeddedMessagingReady event is dispatched, add or remove any items to the list of auto-response parameters. Use the setAutoResponseParameters method to add a parameter. You can also use removeAutoResponseParameters to remove a parameter value.
  3. At some point during or after the conversation, the auto-response UI appears, using any parameters specified from within Salesforce and any parameters specified using this JavaScript API. Specifically, the auto-response messaging component can be shown during one of these phases: Conversation Acknowledgement, Start Conversation, or End Conversation. To learn more, see Create a Messaging Component: Auto-Response.

This sample code illustrates how you can implement the key steps of this sequence.

The Messaging for Web reference documentation describes these methods in more detail.

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.