Configure app manifest, subscribe to events, and register callback

You can use the manifest.json file (also called the app manifest) to specify,

  • App start-up parameters - such as the platform version used to build the app, the node version used, and so on.
  • App’s functional parameters - such as the events that the app must respond to.

When you use the fdk create command, select the serverless-starter-template, and generate the serverless app files, the app manifest generated contains default attributes. To configure the app manifest for your app, you can modify the attribute values, delete (non-mandatory) attributes that your app does not require, or add appropriate attributes.

After creating the app files, to configure the app manifest, do one of the following:

  • From the app’s root directory, navigate to manifest.json and manually configure the attributes. Or
  • Use the fdk generate command to edit the default manifest.json.

App manifest attributes - description and how to configure them

  • platform-versionstring

    Platform version you use to build the app. This value is auto-generated when you create the default app files by using the fdk create command.

  • modulesobjectRequired

    Specifies all modules on which the app can be deployed.


    When you create an app by using the fdk create command, the default app manifest is created with the common and support_ticket modules. You can edit the app manifest and replace the support_ticket module or add additional modules.

    Important:
    • The app manifest must contain at least one module (apart from the common module).
    • Even if your app is built only for the common module, ensure that the modules object contains at least one module in addition to the common module. In this case, the other module(s) can be an empty JSON object. This other module’s name ties the app to the product on which the app is eventually deployed.
    • commonobject

      Specifies the common events that the app must respond to. Common events are events that are not specific to a module.

      • eventsobjectRequired

        Various common serverless events and the corresponding callback function/method names, specified in the following format:

        "events": {
         "<eventName1>": {
            "handler": "<callbackFunctionName1>"
         },
         "<eventName2>": {
            "handler": "<callbackFunctionName2>"
         }
        }



        Subscribe to common events through event listeners: When you build a serverless app, replace the default values in this attribute with the events pertaining to your app. For app setup events, <eventName> is onAppInstall, onAppUninstall, or afterAppUpdate. For external events, <eventName> is onExternalEvent. For scheduled events, <eventName> is onScheduledEvent.


        Register callback: In <callbackFunctionName> enter the name of the callback method defined (or planned to be defined) in server.js. Ensure that for each event, only one callback is registered.

        Important:Common events are events independent of the product on which the app is deployed. So, ensure not to configure product events in common.events. Configure product events in the corresponding <module_name>.

      • requestsobject

        All configured request templates that the app code uses, for a product, in the following format.

        "requests": {
            "<requestTemplateName>":{
                "<option-name>": "<option-value>",
                "<option-name1>": "<option-value1>"
            },
            "<requestTemplateName1>": {}
            }
        Notes:
        • <requestTemplateName> must be the same as that configured in config/requests.json.
        • Possible values of <option-name> are maxAttempts, retryDelay, and oauth. If an option is specified in both manifest.json and config/requests.json, the option value specified in manifest.json takes precedence.

        Important:In the default app manifest, created through the fdk create command, the requests object is not present. If your app code uses request templates, ensure to configure the requests object.

    • <module-name>objectRequired


      Contains the module-specific events that the app can respond to. The events must be compatible with the module identified by <module_name>.


      In the default app manifest, created through the fdk create command, the <module-name> is support_ticket. You can edit the module name to replace it with the module where you want your app to be rendered. You can also add new modules, in addition to the support_ticket module.

      • eventsobjectRequired

        Product events that the app must respond to and the corresponding callback function/method names, specified in the following format:

        "events": {
         "<eventName1>": {
            "handler": "<callbackFunctionName1>"
         },
         "<eventName2>": {
            "handler": "<callbackFunctionName2>"
         }
        }



        Subscribe to product events through event listeners: When you build a serverless app, replace the default values in this attribute with the events pertaining to your app. <eventName> is the appropriate product event name. For a list of all compatible product events, see Module introduction.


        Register callback: In <callbackFunctionName> enter the name of the callback method defined (or planned to be defined) in server.js. Ensure that for each event, only one callback is registered.

  • installationobject

    Information pertaining to the installation scope.


    You can use this object in the app manifest, to specify if the app is available for installation at account level or client(workspace) level or both. To learn more about the workspace or client level installation, see Configure app installation scope.


    Example:

    "installation": {
            "scopes": [
                "account"
            ]
        }

    Note:In the manifest, along with the common module, you should include at least one of the Freshservice modules in order to specify the installation object for the app.

    • scopesarray of strings

      Level at which the app can be installed.


      Possible values:

      • account: The app is available for account level installation only.
      • service_workspace: The app is available for client(workspace) level installation only.

      To make the app available at both the account and client(workspace) level for installation, specify the attribute value as follows:


      Example:

      "scopes": [
                "account", "service_workspace"
              ]
      
      Notes:
      • After an app is published with a specific installation level in its scopes, the existing level cannot be removed in later versions. You can only add an additional installation level. For example, an app with an account installation level scope cannot be redefined to have only a service_workspace installation level scope, and vice versa.
      • By default, all existing apps are available for account level installation.
  • scriptsobject

    Contains the unit testing framework details.

    • fdk-unit-teststring

      Specifies the unit testing framework to be used when running tests for the app.

  • enginesobjectRequired

    Node.js and FDK versions that are used to build the app. When you create the front-end app files by using the fdk create command, this attribute value is auto-populated.

    • nodestring

      Node.js version on which the app is built.

    • fdkstring

      FDK version that is used to build, test, validate, and pack the app.

  • dependenciesobject

    All npm packages that the app uses, specified as <npm-package-name>:<version> pairs.


    This attribute is not a default attribute. If your app uses npm packages, in manifest.json, include this dependencies attribute and register the packages as dependencies.

  • appobject

    Information pertaining to the app metrics, auto-generated when the app is created.

    Note:Currently, this object is auto-generated only when the app uses any Freddy Copilot features.

    • trackingIdstring

      Identifier for the app.

    • startTimestring

      Timestamp of when the app was created, specified in the UTC format.