Friday, December 16, 2022

Embedded Messaging with host domain value cannot be hosted on domain Error In Salesforce

Issue:

These types of errors mostly pops up when your working any kind of the Messaging Systems/Live Agent Chat or Messaging In App and Web chat features in salesforce.

In my case this error is on "Messaging In App and Web" chat configuration.

When your configuring the this Messaging In App and Web we need to create a Embedded Service Deployment to deploy this chat button in on your company/local websites.

Solution:

If we look at "Embedded Service Deployment" configuration it will have bunch of the key properties we need to setup like

  • Embedded Service Deployment Name
  • Site Endpoint
  • Domain
  • Messaging Channel
But now we will discuss more about the Domain property details and it's behavior.

Domain: This domain is the main key reason for this issue. Ideally here we need to add the domain name of your company/website where your going add this chat button on web. So, this code can be hosted on this server without any error.

So if here you have entered domain as "srinivas4sfdc.com"  in your configuration ideally this code snippet you need add on this site only else you will receive the same error.

In my case I have added my domain name as my company domain address like yourcompany.com,yourcompanydomain.in etc and when I'm try to add this code snippet on my website domain "srinivas4sfdc.com" I'm getting the same error.

Deployment Setup Screen:


Error On Website:






Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.


FaceBook Page - I Love Coding. You?


Hope this helps you..Enjoy..!

How To End The Live Agent REST API Chat In Salesforce

If your planning to implement the Live Agent Chat we can use of 2 approaches as listed below

  1.  With help of the Embedded Services code snippet generated by salesforce
  2.  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, 'agent' cannot be used. As this will be a rest call that will be fired by end used, then how is it possible that agent has ended the chat.

- 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 please
check 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.


FaceBook Page - I Love Coding. You?


Hope this helps you..Enjoy..!