Hidden Pre-Chat API

To learn about and set up hidden pre-chat, see Customize Pre-Chat for Messaging for In-App and Web (can be unavailable during release preview).

This section describes the steps you must take from your web client to send user data, also known as hidden pre-chat data, to Salesforce. See the associated documentation for each step of this sequence.

Hidden pre-chat sequence

  1. Before you initialize the API, add an event listener for onEmbeddedMessagingReady. This method notifies you when the API is ready for requests.
  2. At some point after the onEmbeddedMessagingReady event is dispatched, pass hidden pre-chat fields to Salesforce using setHiddenPrechatFields and removeHiddenPrechatFields. This call must also occur before the conversation begins.
  3. When a conversation begins, you can no longer call setHiddenPrechatFields or removeHiddenPrechatFields. Any call to these methods returns an error if the conversation has already begun.

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.