@freshworks-jaya/freshchat-api
TypeScript icon, indicating that this package has built-in type declarations

0.7.35 • Public • Published

SDK for Freshchat API

Install

npm install --save @freshworks-jaya/freshchat-api

or

yarn add @freshworks-jaya/freshchat-api

Usage

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>');

Examples

Resolve a conversation

freshchat.conversationStatusUpdate('<conversation-id>', 'resolved');

Reopen a conversation

freshchat.conversationStatusUpdate('<conversation-id>', 'new');

Generate chat Transcript

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);
  });

Reports API

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;

Trigger a Raw Report

freshchat.triggerRawReports(startTime, endTime, eventType, isExcludePii)
  .then(function (response) {
    { id } = response;
    console.log('Request ID: ', id);
  }, function (error) {
    console.log(error);
  });

Retrieve a Raw Report

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);
  });

Readme

Keywords

none

Package Sidebar

Install

npm i @freshworks-jaya/freshchat-api

Weekly Downloads

73

Version

0.7.35

License

ISC

Unpacked Size

55.4 kB

Total Files

29

Last publish

Collaborators

  • srivatsan07
  • prabhu_kathiresan
  • shashaankkrishnatray
  • bhavani.freshworks
  • vinu_1936
  • abiswasfreshworks
  • abisht1991