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.
- Before you initialize the API, add an event listener for
onEmbeddedMessagingReady
. This method notifies you when the API is ready for requests. - At some point after the
onEmbeddedMessagingReady
event is dispatched, pass hidden pre-chat fields to Salesforce usingsetHiddenPrechatFields
andremoveHiddenPrechatFields
. This call must also occur before the conversation begins. - When a conversation begins, you can no longer call
setHiddenPrechatFields
orremoveHiddenPrechatFields
. 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.