Configure product events

Product events are events such as creating a ticket, updating a ticket, creating a conversation, and so on, that occur in the product on which your app is deployed. You can enable product events to trigger your app, call a corresponding callback function, and execute the app logic.

To do this,

  1. From your app’s root directory, navigate to the manifest.json file.

  2. Subscribe to an event by configuring an event listener: Include the events attribute, specifying the product-event's name and the corresponding callback methods as follows:

    manifest.json
     "events": {
       "<productEventName>": {
           "handler": "<eventCallbackMethod>"
       }
     }

    When the event occurs, the corresponding event listener invokes the callback method and passes a standard payload to the method.

  3. Navigate to the server.js file. In the exports block, enter the callback function definition as follows:

    Sample server.js
     exports = {
       // args is a JSON block containing the payload information
       // args["iparam"] will contain the installation parameter values
       //eventCallbackMethod is the call-back function name specified in manifest.json
       eventCallbackMethod: function(args) {
         console.log("Logging arguments from the event: " + JSON.stringify(payload));
       }};

Note:The serverless component of the app is executed in a sandbox mode where some methods, such as setTimeout and setInterval, cannot be used.

Payload attributes

When a product event occurs, an event-specific payload is passed to the callback method.

The payload is a JSON object with the following attributes.

  • account_idstring

    Identifier of the Freshdesk account, auto-generated when the account is configured for an organization.

  • dataobject

    Event-specific Freshdesk data, specified as a JSON object of key:value pairs.

  • domainstring

    Domain name for the Freshdesk account.

  • eventstring

    Name of the product event.

  • iparamsobject

    Installation parameters specified as a JSON object of <parameter name>: <parameter value> pairs.

  • regionstring

    Region where the Freshdesk account is deployed.

    Possible values: US, EU, EUC, AUS, and IND.

  • timestampnumber

    Timestamp of when the product event occurs, specified in the epoch format.