---
schema_version: "1"
id: 60b47a4a9eb276e92e4bd03f818f639c029ddd7261d84c98a2a0bca9260c37d1
title: Auto-Responses in Enhanced Web Chat
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/service-cloud/messaging-web/guides/auto-response.md
canonical_url: https://developer.salesforce.com/docs/service/messaging-web/guide/auto-response.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 4dcc347d7589d04b5986e76317bf67a21f90b6052ee130211c380913206a74fc
products:
  - Enhanced Web Chat
  - Service Cloud Developer Content
---
# Auto-Responses in Enhanced Web Chat

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](https://help.salesforce.com/s/articleView?id=service.messaging_components_auto_response.htm).

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](https://developer.salesforce.com/docs/media/messaging-web/auto-response-sequence.png)

1. Before you initialize the API from the code snippet that we provide, add an event listener for [`onEmbeddedMessagingReady`](/docs/service/messaging-web/guide/event-listeners.html). 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](https://help.salesforce.com/s/articleView?id=service.messaging_components_auto_response.htm).

This sample code illustrates how you can implement the key steps of this sequence.

```javascript
window.addEventListener("onEmbeddedMessagingReady", () => {
  console.log("Received the onEmbeddedMessagingReady event…");

  embeddedservice_bootstrap.autoResponseAPI.setAutoResponseParameters({
    cartValue: "123",
  });
});
```

The Enhanced Web Chat [reference documentation](/docs/service/messaging-web/references) describes these methods in more detail.

**note:** If your Enhanced Web Chat 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 an Enhanced Web Chat Deployment in an Experience Builder Site](https://help.salesforce.com/s/articleView?id=service.miaw_deployment_experience_builder.htm) in _Salesforce Help_.

