Showing posts with label LiveAgent. Show all posts
Showing posts with label LiveAgent. Show all posts

Friday, December 16, 2022

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..!



Thursday, June 9, 2022

How can we setup different work item capacity for agents in Salesforce Omni-Channel

 Scenario:

Let's assume we have group of users assigned under the omni channel for handling of incoming chat request.
How can we set the different maximum chat limit for user basis on experience. Ex For new joiner we want to setup of maximum cap as 5 and others as 7 chats.

Solution:
Ideally in omni channel the agent capacity and which Omni-channels features can be accessed like auto decline or auto accept of the work items can be performed using the "Presence Configuration" settings.

So in our case also we can create two presence configurations ,one for the new joiners and second for the others. Under the new joiners configuration we will add all the new joiners so when they logged into Omni channel the chat capacity will be picked up from here automatically.



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..!

Monday, June 21, 2021

How To Deploy Einstein Bots In Salesforce

Lets follow the below steps to deploy the Einstein bot using the change sets.

1. Goto Setup and search Outbound Changes Set

2. Open Outbound change set and click on New

3.Give the change set name and click save.

4.Goto Change Set Components and Click on Add button

5.From the component drop down select "Bot" as a type.



6.Select the bot name you want to deploy and click add to change set.



7.Clcik on the Add dependencies button and select the version of the bot you want to deploy.




8.Agian from the Component Type select "Einstein Intent Set" component



9. Select the all the intent sets related to you bot and click add to change set

10.Click on Deploy button Upload button to upload the change set.


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

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




Hope this helps you..Enjoy..!

Friday, June 4, 2021

How To Use Einstein Bot Object Search Results in Einstein Messages

Let assume that you have a Einstein bot and it uses "Object Search" action to fetch the data present in the selected salesforce object with specified search criteria.

Each search record result will have the columns we have selected in the result section and the list of records returned by the search criteria will be stored in a "Search Result Variable" of type Object List.

Search Criteria:



Result Panel:

In my case the results has been stored in a object variable called "ServiceProviderDetails" and now I will show how to use these results in another dialog to show the result values in message.

By default the list index will start from 0(Zero) it means the first record will be stored in 0 index and 2nd record will be stored in 1 index and so on..

If you want to refer the field inside the record use the syntax as {!ServiceProviderDetails[0].filedApiName}.The same has been shown below.



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

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




Hope this helps you..Enjoy..!

Thursday, May 13, 2021

Messaging Objects Schema in Salesforce

 What is Messaging ?

Messaging is providing the convenient way to the customer chatting from their mobile devices using most popular social media apps or text apps with salesforce executives/agents/bots.

Messaging currently works on below listed apps

  • Facebook messenger
  • SMS
  • Whatsapp 

Object Details:

The entire messaging feature of salesforce works on the list of objects mentioned below.
  • MessagingChannel
  • MessagingChannelSkill
  • ConversationEntry
  • MessagingSession
  • MessagingEndUser
  • MessagingTemplate
  • MessagingDeliveryError

Object Schema:

The schema of these objects as shown below



If you want to know the usage of each object and corresponding fields you can refer to the Salesforce documentation page




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

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




Hope this helps you..Enjoy..!


Monday, May 10, 2021

How to see the list of Whatsapp Numbers(Customers) who interacted with Einstein Bot

Scenario: 

Let's assume that you configured a Einstein bot to handle the some of the end user queries before connecting to the agent. Obviously this bot need to be assigned either with Live agent chat or Messaging channel (Whatsapp/Facebook messenger/text) to answer the queries.

In our case consider that we have assigned this Bot with Messaging channel called Whatsapp and sometimes the bot will answers all the customer queries and ends the chat automatically and in some cases the bot will transfers the chat to agents.

The overall setup is done and it's working as expected.  After the couple of days if you want to know the details of the customers (whatsapp) who interacted with Bot and the conversations has been automatically closed by the Bot.

Solution:

According to the salesforce documentation every time the customer comes to messaging channel an entry will created( if not exist already) in object called Messaging User with details as shown in below image.


In case if you want to see the whole conversation what is happened between the Bot and Customer that can also fetched from the one more object called the Messaging Session. The Messaging Session will be the child object of the Messaging User. Every time the customer chat with bot a new Messaging Session will be in case if the previous conversation got marked as end.



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

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




Hope this helps you..Enjoy..!

Monday, February 10, 2020

How To Search/Open Record Detail Page in Live Agent Using REST API

In my previous posts we have seen how to send the pre-chat details,how to store pre-chat details in transcript object.

In this post I will explain how to perform the search in specified object with given filed names and details.If record found with given criteria how to open this record in chat details automatically .This in turn will helps the agents to save the time to look for the record by doing the manual search to answers the customer.

The key area that we need to look at is "entityMaps" array in prechatdetails and "prechatEntities" array .
  • entityMaps - Store object api name search field name and it's values
  • prechatEntities - which will stores the search object,search field,perform the search or not,create a new if not exist and whether to do exact match or not. 
{
   
   "organizationId":"00XXXXXXxfQ",
   "buttonId":"573xxxxxl",
   "deploymentId":"572xxxxxx9",
   "userAgent":"",
   "language":"en-US",
   "screenResolution":"1920x1080",
   "visitorName":"John A",
   "prechatDetails":[
       {
         "label":"search field api name",
         "value":"value for the search field",
         "displayToAgent":true,
         "transcriptFields": [],
          "entityMaps":[
            {
               "entityName":"object api name",
               "fieldName":"search field api name"
            }
         ]
      }
     
   ],
   "prechatEntities":[
      {
         "entityName":"object api name",
         "showOnCreate":true,
         "entityFieldsMaps":[
            {
               "fieldName":"field api name",
               "label":"field api name",
               "doFind":true,
               "isExactMatch":true,
               "doCreate":false
            }
         ]
      }
 ],
   "receiveQueueUpdates":true,
   "isPost":true
}

Sample Request:


  • Object To be Searched - Booking_Details__c
  • Filed Name to be Searched - Pnr__c
  • Field value - PNR_3563788883

{
   
   "organizationId":"00XXXXXXxfQ",
   "buttonId":"573xxxxxl",
   "deploymentId":"572xxxxxxx9",
   "userAgent":"",
   "language":"en-US",
   "screenResolution":"1920x1080",
   "visitorName":"John A",
   "prechatDetails":[
       {
         "label":"Pnr__c", // search field api name
         "value":"PNR_3563788883",//Value for pnr to be search
         "displayToAgent":true,
         "transcriptFields": [],
          "entityMaps":[
            {
               "entityName":"Booking_Details__c", //object api name
               "fieldName":"Pnr__c" //search field api name
            }
         ]
      }
     
   ],
   "prechatEntities":[
      {
         "entityName":"Booking_Details__c", //object api name
         "showOnCreate":true,
         "entityFieldsMaps":[
            {
               "fieldName":"Pnr__c", //search field api name
               "label":"Pnr__c", //search field api name
               "doFind":true, //tells to do search or not
               "isExactMatch":true, // do exact match value or not
               "doCreate":false // want to create if not found the record
            }
         ]
      }
 ],
   "receiveQueueUpdates":true,
   "isPost":true
}

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

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




Hope this helps you..Enjoy..!




Monday, January 6, 2020

Origins may not contain paths or queries, since they are not part of the origin in Salesforce

You might encounter with this while adding your community URL or domain address in CORS or While setting up the Snap Ins(Known as (Embedded Service Chat).

The error indicates the url we are should not have any paths and we should take only the url till .com/.in/.domain etc..

If you look in this  scenario the url needs to be added is

https://srinivas4sfdc-developer-edition.ap1.force.com/HelpCust

The one highlighted in yellow can be considered as path or queries.So,please copy your url till the domain(till ends with .com/.in/.edu etc) name not the full url.

The Final url we need to add in CORS or SnapIns settings is 

https://srinivas4sfdc-developer-edition.ap1.force.com/


Hope this helps you..Enjoy..!



Thursday, December 12, 2019

Unable To Fetch The affinityToken From SessionId API In Live Agent REST API


  • According to the salesforce documentation to get the affinityToken first in headers you  have to set the X-LIVEAGENT-AFFINITY as null.
  • If your not setting or if your not passing this header without null value in your request will not receive any affinityToken.


Sample request without X-LIVEAGENT-AFFINITY header:








Sample request with X-LIVEAGENT-AFFINITY header:








Hope this helps you..Enjoy..!

Monday, December 9, 2019

How To Store The Pre Chat Details in Live Agent Transcript Object Using REST API

In my previous post we have learn how to pass the pre-chat details in REST API and how it shown to agent etc .Now,if you want to store this information in ChatTranscript (Object Name -LiveChatTranscript ) for future reference we can do it easily just by setting few things the same request body by making some changes at "transcriptFields":[] property in the request.

This information will get stored only after agent has ended the chat conversation with customer and if has chosen a option to store the transcript.

First,please goto the ChatTranscript object and create a custom fields to store the required data.

In my scenario I want to store the product category and price .So,I have created 3 new fields as Category__c,Product_Category__c,Price_Range__c. Product which comes from the chat request I want to store it 2 custom fields called Category__c,Product_Category__c and Price range in Price_Range__c.


API Details:


Headers:
X-LIVEAGENT-API-VERSION:34
X-LIVEAGENT-AFFINITYaffinityToken from SessionId API
X-LIVEAGENT-SESSION-KEYkey from from SessionId API
X-LIVEAGENT-SEQUENCE:1
Content-Type:application/json



Sample Request:

{
  "organizationId": "000008afQ",
  "deploymentId": "57228",
  "buttonId": "57328",
  "sessionId": "id-from-response",
  "userAgent": "Lynx/2.8.8",
  "language": "en-US",
  "screenResolution": "1900x1080",
  "visitorName": "Frank Underwood",
  "prechatEntities": [
    
  ],
  "receiveQueueUpdates": true,
  "isPost": true,
  "prechatDetails": [
   {
      "label": "Price Range",
      "value": "20,000-30,000",
      "displayToAgent": true,
      "transcriptFields": [ "Price_Range__c"],
      "entityFieldMaps": [
        
      ]
    },
{ "label": "Product Category", "value": "Smart Phone", "displayToAgent": true, "transcriptFields": ["Category__c","Product_Category__c"], "entityFieldMaps": [ ] }, { "label": "Description", "value": "I'm looking for a mobile with 8GB RAM and 256 GB ROM ", "displayToAgent": true, "transcriptFields": [ ], "entityFieldMaps": [ ] } ] }

Sample Response:

["Ok","200"]

                                             Hope this helps you..Enjoy..!

Friday, December 6, 2019

Live Agent REST API To Send The Pre Chat Details

Let's take a use case ,where you have bot or some custom FAQs to handle the basic customer queries and but sometimes it's required to connect the customer with one of your executives using salesforce live agent chat.

Whenever your connecting the customer with agent,it's required to pass the pre-chat conversation details to agents so that it will help him/her to greet the customer with issue details and also helps to resolve the customer queries quickly.

Luckily Salesforce supports all these features in their REST API.Please take a look at the api details below.

API Details:


Headers:
X-LIVEAGENT-API-VERSION:34
X-LIVEAGENT-AFFINITYaffinityToken from SessionId API
X-LIVEAGENT-SESSION-KEY: key from from SessionId API
X-LIVEAGENT-SEQUENCE:1
Content-Type:application/json


Sample Request:

{
  "organizationId": "000008afQ",
  "deploymentId": "57228",
  "buttonId": "57328",
  "sessionId": "id-from-response",
  "userAgent": "Lynx/2.8.8",
  "language": "en-US",
  "screenResolution": "1900x1080",
  "visitorName": "Frank Underwood",
  "prechatEntities": [
    
  ],
  "receiveQueueUpdates": true,
  "isPost": true,
  "prechatDetails": [
    {
      "label": "Product Category",
      "value": "Smart Phone",
      "displayToAgent": true,
      "transcriptFields": [  ],
      "entityFieldMaps": [
        
      ]
    },
    {
      "label": "Price Range",
      "value": "20,000-30,000",
      "displayToAgent": true,
      "transcriptFields": [  ],
      "entityFieldMaps": [
        
      ]
    },
    {
      "label": "Description",
      "value": "I'm looking for a mobile with 8GB RAM and 256 GB ROM ",
      "displayToAgent": true,
      "transcriptFields": [   ],
      "entityFieldMaps": [
        
      ]
    }
  ]
}

Sample Response:

["Ok","200"]

How Agent Looks in Salesforce This Data:
After mouse over on Accept


In chat Transcript



Hope this helps you..Enjoy..!




Live Agent REST API To Check Whether Agents Are Available(in Online or Not)

If you want to check whether any agent is available or not to take the new chat,then first we need to check whether a particular button is available to take the request or not.

Because agents are tagged under a particular button,if button status is online it means agents are under the same button is available to take the request.

Please look at the API details below


This api basically takes the list of button ids to which you want to verify ,if specified button id is online it will returns the flag called isAvailable or else isAvailable will not be present in the response.


EndPoint : 


https://HostName/chat/rest/Visitor/Availability?Availability.prefix=Visitor&Availability.ids=[List of Button Ids]&deployment_id=DeploymentId&org_id=OrganizationId

Headers:
X-LIVEAGENT-API-VERSION:34

Content-Type:application/json


Query parameters:

  • org_id - The ID of the Salesforce organization that’s associated with the Live Agent deployment.
  • deployment_id - The 15-digit ID of the Live Agent deployment that the chat request was initiated from.
  • Availability.ids - A comma separated button object IDs for which to verify availability.


{
"messages": [
{
"type": "Availability",
"message": {
"results": [
{
"id": "573280000l",
"isAvailable": true // Agents are available to accept new chat request 
},
{
"id": "573000004" // No agents are available to accept new chat request 
},
{
"id": "5730I00000",
"isAvailable": true //Agents are available to accept new chat request
}
]
}
}
]
}


Hope this helps you..Enjoy..!