1

enter image description hereSometimes salesforce changes the liveagent chat server and when they do so we need to manually change the server URl in our apex code where we have hardcoded the Url's For example:--('htps://d.la1-c1-lon.salesforceliveagent.com/chat') to ('htps://d.la1-c1-frf.salesforceliveagent.com/chat')

I need to know a way this can be changed dynamically. Is Live Chat Deployments an option?. as Live Chat Deployments has the current endpoint will it change dynamically as the server changes in salesforce end? and how can we call this Live Chat Deployments URL in pour apex code?.

Live Chat Deployments as shown in pic attached.

1

2 Answers 2

2

Here is a link showing when the change would effect the chats invocation. https://help.salesforce.com/articleView?id=000233888&type=1

It says : " Now, if the only reference to the API Endpoint URL is within the Deployment code snippet that Salesforce provides, you should see no issues. The system knows how to reroute the call to the correct Live Agent server, so there is no need to update that.

HOWEVER, if you have that API Endpoint URL referenced anywhere else in your webpage code, you MUST update the URL to the new server manually. This is why you SHOULD NOT be hard coding the URL reference within your own code. "

First off, do not hard code the Endpoint url in the VF page. The best way would be to use a custom setting to store the Live Agent Endpoint url. Then change the url whenever salesforce changes it.

In our implementation we have stored the endpoints, Buttonids, orgid, deploymentid etc in custom settings for easier changes when liveagent server is changed.

This also helps when migrating the code from org to org.

1
  • Glad that i could help!
    – Wilson
    Commented Sep 16, 2017 at 11:08
0

We can get the livechat URL dynamically with below Script.

<script type="text/Javascript">
        var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
        var tgtURL = decodeURIComponent(endpointMatcher.exec(document.location.search)[1]);
        var tgtURLsplit = tgtURL.split("/",3);
        var result = tgtURLsplit[2];
</script> 

and use the URL which we get in result on preChatInit method.

liveagent.details.preChatInit('https://'+result+'/chat', 'detailCallback'); 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .