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

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