• Dinesh Kumar R 7
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Dear Team,

I really need your suggestion and help , please, please post your suggetion for the below.

Currently we are using liveagent in our Service Cloud to get the request, feedback and complain from the customer.
Now we have new requirement to use the bot serivce to autoreply to customer  for the simple quiery such as order status and product details , when the bot is not able to answer  to the customer query , it should redirect back to liveagent with all the chat transcript information .

Do you have any suggestion , how can I use Apex REST Callouts to send all the chat information to LiveAgent. 

Thank you in advance.

Regards,
Dinesh Kumar
Hi.

I'm trying to user Live Agent's rest API to retrieve the current session id to then subsequently retrieve if any agents are online or not.  I can call the rest API using a Chrome extension called Restlet Client & see the correct response.  However when I try to make the same call using Javascript I get 'https://xxx.salesforceliveagent.com/chat/rest/System/SessionId 400 (Bad Request)' when performing the request.send().

The javascript being used, with the appropriate URLs being anonymised, is shown below.  The restApi function gets the error but the movies function, which is basically the same but to a public rest API service which requires no request headers, doesn't.  Any suggestions would be very gratefully received. 
 
<html>
    <head>
    </head>
    <body>

        <button type="submit" onclick="javascript:restApi()">RestApi</button>
        
        <button type="submit" onclick="javascript:movies()">Movies</button>
        
    
        <script type="text/javascript">
            
            function restApi(){
                var request = new XMLHttpRequest();

                request.open('GET', 'https://xxx.salesforceliveagent.com/chat/rest/System/SessionId', true);
                request.setRequestHeader('X-LIVEAGENT-API-VERSION', '34');
                request.setRequestHeader('X-LIVEAGENT-AFFINITY', '');
                request.onload = function () {
                    var data = JSON.parse(this.response);
                    console.log(request.status);
                        if (request.status >= 200 && request.status < 400) {
                            console.log('worked');
                        } else {
                            console.log('error');
                        }
                }

                request.send();
            }
            
            function movies(){
                var request = new XMLHttpRequest();

                request.open('GET', 'https://ghibliapi.herokuapp.com/films', true);
                request.setRequestHeader('X-LIVEAGENT-API-VERSION', '34');
                request.setRequestHeader('X-LIVEAGENT-AFFINITY', '');
                request.onload = function () {
                    var data = JSON.parse(this.response);
                    console.log(request.status);
                        if (request.status >= 200 && request.status < 400) {
                            console.log('worked');
                            data.forEach(movie => {
                                console.log(movie.title);
                            });
                        } else {
                            console.log('error');
                        }
                }

                request.send();
            }

            
        </script>

    </body>
<html>