Overview

The Freshworks app development platform includes a serverless environment to enable you to create apps that run in response to events such as Freshdesk 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:
You need to have CLI v4.0.0 or higher in order to use this feature. For more information on how to install the latest version, click here.

Use Cases
Custom Automations

Freshdesk enables workflow automations through dispatcher and observer rules, 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 requester’s subscription renewal date is within the next 30 days and accordingly set the ticket priority.
  • Automation rules in Freshdesk are limited to ticket events. You can now build workflows for contact, app installation, and external events.

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 Freshdesk, the same contact will be created or updated in your CRM 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 product, 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.

Note:
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.

Create

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

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
├── README.md ├── config │   ├── iparam_test_data.json │   └── iparams.json ├── manifest.json └── server ├── lib │   └── handle-response.js ├── server.js └── test_data ├── onAppInstall.json ├── onAppUninstall.json ├── onContactCreate.json ├── onContactUpdate.json ├── onConversationCreate.json ├── onExternalEvent.json ├── onTicketCreate.json └── onTicketUpdate.json 4 directories, 14 files
EXPAND ↓

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.

Dependencies

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.

Note:
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
    1
    2
    3
    "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
    1
    2
    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
    1
    var handler = require("./lib/handle-response");

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

Sample apps
  • 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.

Log in with your Freshdesk account

Enter your helpdesk URL to proceed to login

Proceed

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