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.

NameTypeDescription
chatKeyStringThe chatKey associated with the chat for which to call a function when the agent sends a message.
callbackfunctionJavaScript method called upon completion of the method.

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

NameTypeDescription
contentStringThe text of the agent’s message.
nameStringThe name of the agent who is attempting to send the message as it appears in the chat log.
typeStringThe type of message that was received—for example, agent.
timestampDate/TimeThe date and time the agent attempted to send the chat message.
successBooleantrue if firing event was successful; false if firing event wasn’t successful.