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




3 comments:

  1. This is a great article with lots of informative resources. I appreciate your work this is really helpful for everyone. Check out our website Web Search Api for more related info!

    ReplyDelete
  2. Hey Srinivas,

    This is a great Article. I've 1 quick question. I followed your code and I'm able to open a contact record when I accept chat request in my SF console. But is there a way that I can link that contact record to Chat Transcript?

    ReplyDelete
    Replies
    1. Look at this article, if not you can write a trigger on transcript object to do this linkup. https://www.srinivas4sfdc.com/2019/12/how-to-store-pre-chat-details-in-live.html

      Delete