Freshchat API

Hi Team,
I want to create custom app in Freshdesk in which I have a use of Freshchat API.
I found one SDK for Freshchat API : https://www.npmjs.com/package/@freshworks-jaya/freshchat-api

To explore this SDK, I have simple created node project and installed the given command.

Now, When I tried to test installation by using example given in the site,

import Freshchat from '@freshworks-jaya/freshchat-api';

const freshchat = new Freshchat('https://api.freshchat.com/v2', '<freshchat-api-token>');

It gives error that “Freshchat is not a constructor”.

What could be the reason for the error?
How can I resolve it?

Thanks

What Node.js version are you using? Can you try the require() based import mentioned in their docs?

const Freshchat = require('@freshworks-jaya/freshchat-api').default;

var freshchat = new Freshchat('https://api.freshchat.com/v2', '<freshchat-api-token>');
2 Likes

This require based approached worked!
Thanks!