Newer Version Available

This content describes an older version of this product. View Latest

onAgentSend()

Registers a function to call when an agent sends a chat message through the Salesforce console. This method intercepts the message and occurs before it is sent to the chat visitor. Available in API version 29.0 or later.

This method is only called when an agent sends a message through the chat window interface. This method doesn’t apply when a sendMessage() method is called in the API.

Note

Syntax

Arguments

Name Type Description
chatKey String The chatKey associated with the chat for which to call a function when the agent sends a message.
callback function JavaScript method called upon completion of the method.

Sample Code–Visualforce

Response

This method is asynchronous so it returns its response in an object in a callback method. The response object contains the following properties:

Name Type Description
content String The text of the agent’s message.
name String The name of the agent who is attempting to send the message as it appears in the chat log.
type String The type of message that was received—for example, agent.
timestamp Date/Time The date and time the agent attempted to send the chat message.
success Boolean true if firing event was successful; false if firing event wasn’t successful.