Any API for Business hours in Freshchat

Hi all,

Hope you all doing well. Are there any APIs for fetching all business hours in Freshchat. I have a requirement that for non-business hours if any message is sent need to create tickets in a Third-party account.

Thanks in advance,
Tejasri Kalluri

1 Like

Hi @Tejasri_Kalluri,

We have a v1 API that can be used to list all the Business Hours rules.

curl --location --request GET 'https://api.freshchat.com/app/services/app/v1/operating_hours_v2' \
--header 'Authorization: <FRESHCHAT_APP_ID>'

Note the base URL https://api.freshchat.com is dependent on the Freshchat account’s data center and can be any of the following values.

  1. US - https://api.freshchat.com
  2. EU - https://api.eu.freshchat.com
  3. IN - https://api.in.freshchat.com
  4. AU - https://api.freshchat.com

The FRESHCHAT_APP_ID can be retrieved from Admin–> Mobile SDKs, as highlighted below.

Hope this helps.

4 Likes

Hi @Arjun_Paliath,

Thanks for your response, I try this request, I got a 500 status. FYI

Hi @Tejasri_Kalluri

As mentioned earlier, you cannot consume the v2 API’s Token.

The authorisation for this API is simply the header

--header 'Authorization: <FRESHCHAT_APP_ID>'

And the App Id can be retrieved from Admin–> Mobile SDKs as shown in my previous response.

Let me know if it still fails.

2 Likes

Hi @Arjun_Paliath,
Its works Thank you,
and I have one doubt in which format is it displaying timezone Can you help me?

“days”: {

            "0": "46800;61200;",

            "1": "36000;61200;",

            "2": "36000;61200;",

            "3": "36000;54000;",

            "4": "36000;61200;",

            "5": "36000;61200;",

            "6": "36000;61200;"

        }

Hey @Tejasri_Kalluri,

The Time Zone will be available with the timezone key in the object as shown below.

image

However, the time is displayed in seconds, you can use a time function(sample is below) or build your own function to get the value in HH:mm.

String.prototype.toHHMMSS = function () {
    var sec_num = parseInt(this, 10); // don't forget the second param
    var hours   = Math.floor(sec_num / 3600);
    var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
    var seconds = sec_num - (hours * 3600) - (minutes * 60);

    if (hours   < 10) {hours   = "0"+hours;}
    if (minutes < 10) {minutes = "0"+minutes;}
    if (seconds < 10) {seconds = "0"+seconds;}
    return hours+':'+minutes+':'+seconds;
}

You can consume the above function as shown below.

console.log("61200".toHHMMSS());

The Output will be as below.

17:00:00

Hope this helps.

1 Like

Thank you @Arjun_Paliath

1 Like