If your planning to implement the Live Agent Chat we can use of 2 approaches as listed below
- With help of the Embedded Services code snippet generated by salesforce
- Using the Salesforce Live Agent REST API Integration.
1. {"reason":"client"}
2. {reason:"client"}
3. {"type":"ChatEndReason","reason":"client"}
- For value, 'clienttimeout', it cannot be explicitly sent as this is value that will be set automatically when the chat ends if end user takes more than configured time to reply.
- For value, 'client', it works fine and it is the only intended value that should be sent.
X-LIVEAGENT-API-VERSION:56 X-LIVEAGENT-AFFINITY:10.44.144.152:443 X-LIVEAGENT-SESSION-KEY:1a71214c-e!1671173289038!qwUZfQ56kOpSHSRIOINyBZRoGug=
X-LIVEAGENT-AFFINITY: aa:bb:ccc:ddd:443 format/hetehksd (8 digit alphanumeric token) both are valid
X-LIVEAGENT-SESSION-KEY: We need to take the key value not the id value from session api.
3. Sample Request:
End Point - https://hostname/chat/rest/Chasitor/ChatEnd
Type - Post
Headers - As mentioned above
RequestBody - As mentioned above
Sample Curl:
Update your chat setting url in host name
curl --location --request POST 'https://hostname/chat/rest/Chasitor/ChatEnd' \ --header 'X-LIVEAGENT-API-VERSION: 56' \ --header 'X-LIVEAGENT-AFFINITY: 11.58.224.242:443' \ --header 'X-LIVEAGENT-SESSION-KEY: 1a71214c-ed05-8383-a0c3-db568dbd6903!1671173289038!qwUZfQ56kOpSHSRIOINyBZRoGug=' \ --header 'Content-Type: application/json' \ --data-raw '{"reason":"client"}'If your receiving the below status code please check once- 403 You initiated the request but no agent's are available to accept the chat so pleasecheck the agent availability api before call session api/chat visitor session api.- 400 You might have the error in your end point or headers or body.Happy Learning 😊
Please comment or write us if you have any queries/requirements.
Please like,follow,bookmark,subscribe this site to receive daily updates.LinkedIn Group - Srinivas4sfdc (I Love Coding... You?)FaceBook Page - I Love Coding. You?
Hope this helps you..Enjoy..!