App for Freshchat

If you start a trial of Freshchat from the web page, it appears in Freshworks CRM. This is a different UI to what you see if you start a trial from within Freshdesk.

In this Freshchat trial you can access a developer portal and install a custom app in that environment, but request API calls fail with the error

{"success":false,"error_code":0,"error_message":"java.lang.RuntimeException: Token not present"}

Developing for Freshchat is a bit confusing and there is nothing I can see in the documentation. Please could you advise how to approach this.

Hi @RobAtOpinyin

Are you using generic FC url i.e. (https://api.freshchat.com) or instance specific URL?
I am not 100% sure but you might need to use the generic API url based on instance region like https://api.freshchat.com

Hi @Sachin_Kumar

I am using the format https://[instance subdomain].freshchat.com. I will try the one you suggest.

Do you know where you get the correct regional instance from for each region?

Hi Rob,

Support can help however quickest way to run any get request like get channels in postman with (https://api.freshchat.com or https://api.in.freshchat.com or https://api.eu.freshchat.com or https://api.au.freshchat.com) with your chat api token.

Hi @Sachin_Kumar

I am not sure I fully understand. I would be making these requests in an app so would I need to try all these till one worked and then store that as an iparam?

@RobAtOpinyin,

Support team should be able to help with the region related question however there are only 4 generic URLs so we can check them using CURL or any tool like Postman etc. to test a sample get request. And yes the one which works can be used as an app iparams.

Example :

curl -X GET “https://api.freshchat.com/v2/channels?” -H “accept: application/json” -H “Authorization: Bearer <<Freshchat_Token>>”

Hi @Sachin_Kumar

Ok. Thanks. These URLS change depending on where the user is in the world?

No these are AWS region specific where your freshchat instance is hosted.

OK. Understood. Thanks

I have made a little progress with the regional urls however now when I try one with the format api.eu.freshchat.com the app complains that this is not whitelisted even though I have *.freshchat.com in my whitelist.

Can you try adding both "*.freshchat.com" and "api.*.freshchat.com" to whitelisted-domains?

I assume *.freshchat.com will match <subdomain>.freshchat.com, but not another nested subdomain.

Thanks @kaustavdm. I have it working now.

Hi @kaustavdm

There appears to be some differences in the way the Freshchat API behaves with these new url access points to the previous ones. I am having trouble using the conversations end point in postman to get conversation details or post messages to it but I am using exactly the same methods as I use with the old url.

Here are some examples:

https://api.eu.freshchat.com/v2/conversations/:conversation_id

returns the following even though I captured the conversation ID via the console from an installed custom app.

{
    "code": 404,
    "status": "CONVERSATION_NOT_FOUND",
    "message": "Conversation Not Found"
}

Also when trying to post a message to a chat with some a stringified payload in the body I get the following error with the new urls. I tried to get this to work in postman and it suggested the end point doesn’t like the payload.

'{"code":400,"status":"INVALID_VALUE"}'

Any chance of an online session to look at this as this all worked fine against the old url access point.

1 Like

Hey @RobAtOpinyin
Do you think it merits tracking this most recent post as a new topic so we could address it separately from the original problem? While they are indeed linked, I wonder if many other developers may come across these problems at the same time.

1 Like

Hi @satwik

Good idea. I have created a new topic here

2 Likes

Hey @RobAtOpinyin !
you are probably getting this error because you sending the wrong conversation id, thsi part is missing in docs. iin case you need to get right conversation id try my code sample:

function getConversation() {
  client.data.get('conversation').then(
    function (payload) {
      console.log(payload)
      };
    },
    function (error) {
      console.error('Failed to get conversation details');
  
    }
  );
}

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.