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.
In this article we will discuss about how to end the chat initiated by the "Salesforce Live Agent REST API Integration" using the API's in Salesforce.
When I looked at the Salesforce document it's feels me very simple but while doing the actual integration I have faced couple of issue .So, I thought of sharing the same with you guys so that if you have come across same concerns it will clear lot of issues.
Salesforce Document :
Key Points :
1. Is the Request body is valid:
Yes ,it's valid json body ,even i had the same conception but it's worked with body type raw json/ raw text and the possible request bodies are listed below and it worked for me with any of body request.
1. {"reason":"client"}
2. {reason:"client"}
3. {"type":"ChatEndReason","reason":"client"}
Possible Values for "reason" property:
- 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.
2.Header Values(Check Underscore and Hypon):
X-LIVEAGENT-API-VERSION:56 X-LIVEAGENT-AFFINITY:10.44.144.152:443 X-LIVEAGENT-SESSION-KEY:1a71214c-e!1671173289038!qwUZfQ56kOpSHSRIOINyBZRoGug=
These 3 keys would be fine enough and sequence is not required. The below both
values will taken from the Session API which will be invoked initially to start the
live agent chat session.
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..!
No comments:
Post a Comment