npm install --save @freshworks-jaya/freshchat-api
or
yarn add @freshworks-jaya/freshchat-api
import Freshchat from '@freshworks-jaya/freshchat-api';
const freshchat = new Freshchat('https://api.freshchat.com/v2', '<freshchat-api-token>');
On Marketplace App server.js
const Freshchat = require('@freshworks-jaya/freshchat-api').default;
var freshchat = new Freshchat('https://api.freshchat.com/v2', '<freshchat-api-token>');
freshchat.conversationStatusUpdate('<conversation-id>', 'resolved');
freshchat.conversationStatusUpdate('<conversation-id>', 'new');
var appUrl = 'https://domain.freshchat.com';
var appAlias = '<App ID>'; //Available from Settings--> Mobile SDKs
var conversationId = '<Freshchat Conversation UUID>';
freshchat.getConversationTranscript(
appUrl,
appAlias,
conversationId,
{
//The below value can either be 'text' or 'html'
output: 'html',
//Below is a Flag to include the conversation link in the generated transcript.
isIncludeFreshchatLink: true,
//Below is a Flag to generate transcript for the entire conversation or every interaction. (Create -> Latest message, Reopen -> Latest message)
isFetchUntilLastResolve: true,
//Choose a timezone offset for timestamps in conversation
timezoneOffset: 330 // for Asia/Kolkata timezone
//Limit the number of messages fetched in the transcript
messagesLimit: 200
},
{
//Exclude normal messages
isExcludeNormal: false,
//Exclude private messages
isExcludePrivate: false,
//Exclude system messages
isExcludeSystem: true
})
.then(function (resp) {
console.log(resp);
}, function (error) {
console.log(error);
});
const Freshchat = require('@freshworks-jaya/freshchat-api').default;
var freshchat = new Freshchat('https://api.freshchat.com/v2', '<freshchat-api-token>');
var startTime = '2020-12-03T05:08:36.791Z';
var endTime = '2020-12-04T05:08:35.791Z';
var eventType = 'classic';
var isExcludePii = false;
freshchat.triggerRawReports(startTime, endTime, eventType, isExcludePii)
.then(function (response) {
{ id } = response;
console.log('Request ID: ', id);
}, function (error) {
console.log(error);
});
Use the Request ID from the response of the Trigger Raw Report API to retrieve the report.
freshchat.retrieveRawReports(requestId)
.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});