Overview

The Freshworks app development platform includes a serverless environment to enable you to create apps that run in response to events such as Freshservice product, 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 ticket page load or a button click, which are executed on the client’s browser (UI).

Note:
1. You need to have CLI v4.0.0 or higher in order to use this feature. You can find instructions on how to get the latest version here.
2. All outgoing requests from serverless apps originate from AWS servers whose IP addresses adhere to the range mentioned in this list.

Use Cases

Custom Automations

Freshservice enables automations through workflow automator, which you can enhance in a variety of ways:

  • You can obtain data from external sources to customize your workflow. For instance, when a ticket is created, an app can check if the ticket raised is related to a security issue and set the priority accordingly.
  • Automation rules in Freshservice are limited to ticket events. You can now build workflows for app installation, and external events.


Bi-directional sync

Events, such as ticket creation and updation, can be used to synchronize data across multiple products. For example, every time a ticket is created or updated in Freshdesk with certain ticket property, the ticket will be created or updated in your Freshservice instance in real time.


Alerts and Notifications

This feature can also be used to apply custom logic to alerts and notifications. You can get notified when a product app, or external event occurs. ThThis 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 a product, app, or external events occur.


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

Create

If you want to create a new serverless app, run the following command: $ fdk create --products freshservice --template your_first_serverless_app The current directory should be empty.

Output
A new Freshservice app was successfully created from template your_first_serverless_app with the following files.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
├── README.md ├── config │   ├── iparam_test_data.json │   └── iparams.json ├── manifest.json └── server ├── lib │   └── handle-response.js ├── server.js └── test_data ├── onTicketCreate.json └── onTicketUpdate.json 4 directories, 14 files
EXPAND ↓

Folder/File Description
README.md Any additional instructions or specifications the developer may want to outline can be mentioned here.
server/ This folder 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 external library with methods that can be used in server.js. require("./lib/handle-response"); Where handle-response is a lib file under project-folder/server/lib/ directory.
server/server.js Contains the event registration and callback methods.
server/test_data Contains files that contain a sample payload for each event which will be used during local testing.
config/ This directory contains the installation parameters files.
config/iparams.json This file contains all the parameters that the user will have to specify/set when they install the app. For more information on the installation parameters and related APIs, see Installation Parameters.
config/iparam_test_data.json If you wish to test the app locally, you will need to specify parameter values here.
manifest.json Contains details about your app and its configuration.

Dependencies

Dependencies are npm packages that can be used by the server.js file and files in the server/lib folder. Using them enables you to reuse their functionality as per your app’s requirement. For example, you can use popular npm packages such as underscore to take advantage of its utility methods or request to easily make HTTP calls.

Note:
1. If you are using a windows machine, please refer to the prerequisites to ensure that your machine is correctly set up.
2. Ensure that the included module was downloaded at least 50 times in the last month.


List the packages in the manifest with their corresponding versions as shown below:

manifest.json Copied Copy
1
2
3
"dependencies": { "underscore": "1.8.3" },

You can now load the dependencies by including the require() method in the server.js file. Avoid using require inside functions, always require everything in the first call itself.

Copied Copy
1
2
var _ = require("underscore"); _.first([5, 4, 3, 2, 1]);

Where underscore is the package that will be loaded when this method is invoked from server.js.

Local Libraries

You can use local library files that contain helper methods for your server.js file to use. This will enable you to make your code modular and maintainable. You can load your local library from server/lib directory by including the require() method in the server.js file:

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

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

Log in with your Freshservice account

Enter your helpdesk URL to proceed to login

Proceed

By clicking "Proceed", you agree to our Terms of Use.