The Freshworks app development platform includes a serverless environment to enable you to create apps that run in response to events such as Freshchat app setup and external events. Serverless computing involves servers, but they are abstracted away from developers.

To use this feature, all you need to do is configure an event listener and the callback method. When the event occurs, the callback method is executed on a server. This is in contrast to front-end apps which run in response to events, such as a Conversation page load or button click, which are executed on the client’s browser (UI).

Use Cases
Data Synchronization

Events, such as contact create and update, can be used to synchronize data across multiple products. For example, every time a contact is created or updated in your CRM, the same contact can be created or updated in your Freshchat account in real time.

Alerts and Notifications

This feature can also be used to apply custom logic to alerts and notifications. You can receive notifications through the desired channel (email, chat, SMS) when app or external events occur.

Server Method Invocation

The server method invocation allows code in server.js to be executed in response to front-end events. This feature enables you to use node libraries (that only run on the backend) or hide sensitive information.

1. The serverless component of the app is executed in sandbox mode where some methods, such as setTimeout and setInterval, cannot be used.
2. The app must complete its execution within 20 seconds or it will timeout.


To create a new serverless app, run the following command. $ fdk create --products freshchat --template your_first_serverless_app The current directory should be empty.

A new Freshchat app is successfully created from the your_first_serverless_app template with the following files.

├── README.md ├── config │   ├── iparam_test_data.json │   └── iparams.json ├── manifest.json └── server ├── server.js └── test_data ├── onAppInstall.json ├── onAppUninstall.json ├── onConversationCreate.json ├── onConversationUpdate.json ├── onExternalEvent.json ├── onMessageCreate.json ├── onScheduledEvent.json ├── onUserCreate.json └── onUserUpdate.json 3 directories, 14 files

Folder/File Description
README.md Developers can outline additional instructions or specifications here.
server/ Contains files and folders related to the serverless component of the app. JS files in this folder must follow the ES6 standard.
server/lib Contains an external library with methods that can be used in server.js. require("./lib/handle-response"); Here, handle-response is a lib file in the project-folder/server/lib/ directory.
server/server.js Contains event registration and callback methods.
server/test_data Includes files that contain a sample payload for each event which will be used during local testing.
config/ Contains installation parameters files.
config/iparams.json Contains all the parameters that users need to specify/set when they install the app. For more information on installation parameters and related APIs, see Installation Parameters.
config/iparam_test_data.json Developers can specify parameter values here to test the app in their local setup.
manifest.json Contains details about the app and its configuration.


These are npm packages that can be used in the server.js file and server/lib folder files as per your requirement. For example, you can use the utility methods in the underscore package or easily make HTTP calls with the request package.

1. If you are using a Windows machine, see the prerequisites to ensure that your machine is set up correctly.
2. All popular npm packages (at least 50 downloads) are supported.

To use npm packages, follow these steps.

  1. List the packages in the manifest file with their corresponding versions as shown.
  2. manifest.json Copied Copy
    "dependencies": { "underscore": "1.8.3" },
  3. You can now load the dependencies by including the require() method in the server.js file. Use this method in the first call and not inside functions.
  4. Copied Copy
    var _ = require("underscore"); _.first([5, 4, 3, 2, 1]);

    Here, underscore is the package that is loaded when this method is invoked from server.js.

    Local Libraries

    You can use local libraries which contain helper methods in your server.js file to make your code modular and maintainable. You can load the local library from the server/lib directory by using the require() method in the server.js file.

    server.js Copied Copy
    var handler = require("./lib/handle-response");

    Here, handle-response is a library file in the server/lib directory.

    Note: The FDK’s testing framework (beta) enables you to create automated unit tests for serverless apps. For information on how to write and run tests, see the Testing Framework documentation.

Sample Apps

Take a look these Freshdesk sample apps. The same functionality is available in Freshchat.

  • Your First Serverless App - Prints a "Hello {requester name}" message in the terminal window when a new ticket is created.
  • Serverless Request App - Sends an API request to HTTPbin.org and prints the response in the terminal window when a new ticket is created.
  • JIRA External Events App - Uses external events to create an outbound email ticket in Freshdesk when an issue of type “bug” is created in JIRA.
  • Asana Serverless+OAuth App - Sends serverless requests using an OAuth token to create an Asana task for every Freshdesk ticket.
  • Ticket Merger - Merges tickets created by the same requester within a configurable time window.