Newer Version Available

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

Post-Chat Code Sample

Test and preview how post-chat pages work for your agents and customers using this code sample.

You can customize your post-chat page by including the variables you want to be displayed.

If the post-chat page is hosted on a site that requires an active session, long-running chats can lead to session timeout. If the customer is on the post-chat page and is redirected to a login page, the post-chat context variables are lost.

Note

Possible Variables Description
requestTime The timestamp when the system received the chat request.
startTime The timestamp when the agent accepted the chat.
deploymentId The ID of the deployment.
buttonId The Id of the button that originated the chat.
chatKey The unique chat key.
lastVisitedPage The last visited page value sent to the agent.
originalReferrer The first page the customer visited containing the deployment code.
latitude Geo location latitude of the chat visitor.
longitude Geo location longitude of the chat visitor.
city Geo location city of the chat visitor.
region Geo location region of the chat visitor.
country Geo location country of the chat visitor.
organization Salesforce organization ID that hosted the chat.
disconnectedBy Reason for ending the chat. Possible values:
  • agent - the agent terminated the chat
  • client - the chat visitor terminated the chat
  • error - the system encountered an error that disconnected the chat
  • clientIdleTimeout - the chat visitor didn’t answer within the allotted time (must have Idle Timeout configured)
  • agentsUnavailable - there are no agents available to receive the chat or there is no room in the queue
windowLanguage Language of the window as configured in the chat button.
chatDetails A JSON representation of the chat data.
transcript A plain text copy of the transcript.
attachedRecords A list of IDs attached to the chat session in JSON array format.
error Description of any errors that occurred during the chat.
This code sample creates a post-chat page that includes basic information about the chat.

This code results in the following post-chat page for the agent:

Post-chat page

This message shows if the chat is abandoned:

Post-chat when chat is abandoned