You can build a Freshteam app by using the following steps.
We recommend that you use Node Version Manager (NVM) to install Node.js. NVM enables you to install and work with multiple versions of Node.
Note: To check if Node is installed on your computer, run the node --version command. Uninstall all Node versions on your computer and remove all the folders related to Node and Node Package Manager (npm).
- To install NVM:
- To verify the NVM installation, run the following command. $ nvm --version
- To install Node, run the following command. $ nvm install 10.18
- To verify the Node installation, run the following command.
$ node --version
Note: On Windows, if the Node version is not displayed, run the nvm on command to enable NVM.
- To set the default Node version, run the following command. $ nvm alias default 10.18
- On Windows, to install the required tools and configurations to start using Node, run the following command. $ npm install --global --production windows-build-tools For more information, see the write-up on node-gyp.
Install the Freshworks CLI
1. Uninstall the previous CLI version by using the npm uninstall fdk -g command.
To build, test, and publish apps in Freshworks Marketplace, you need to install the CLI.
- To install the CLI, run the following command. Copied Copy
- To verify the CLI installation, run the following command. $ fdk version
|npm install https://dl.freshdev.io/cli/fdk-6.5.4.tgz -g|
Create an App
Note: At present, you can create only serverless apps.
- From the command line, navigate to the empty directory in which you want to create an app.
- Run the fdk create command.
- From the displayed product list, select Freshteam and press Enter.
A new app is created based on the your_first_serverless_app template and the following app files are created in the directory.
|config/||Contains the installation parameters and OAuth configuration files.|
|config/iparams.json||Specifies all the installation parameters which you set when you install the app. For more information, see Installation Parameters.|
|server/lib/||Uses this folder to store library files which contain helper methods that you could use in your server.js file.|
|server/server.js||Contains code which is executed on a Freshworks server every time a specific event occurs. The file also contains registration wherein callback methods bind themselves to specific events.|
|server/test_data/||To test a serverless app, you have to simulate events that trigger the app. When an event is simulated, a sample payload containing details about the corresponding event is sent to the registered callback. The files containing the payload are present in this folder.|
|manifest.json||Contains details about the app and its characteristics.|
|README.md||Contains additional instructions, information, and specifications.|
For a detailed walkthrough of the app, see Code Walkthrough.
1. The iparam_test_data.json file has been deprecated. Before testing the app, navigate to http://localhost:10001/custom_configs and enter appropriate values for the configured installation parameters.
2. If you use React, Ember, Vue, or any other front-end framework, include the source files of your app in the src directory to ensure quick app reviews.
Test the App
Note: Use the latest version of Chrome browser.
You can test your app on your computer by simulating events, and you can test different scenarios by directly modifying the payload.
Note: As the testing is only a simulation of events, an actual event will not be recorded in the back end. If you need an actual record to be created, then it is recommended to publish your app as a custom app and test the operation manually.
To simulate events for testing, follow the given steps.
- From the command line, navigate to your project directory and run the following command. $ fdk run
- In the browser, enter the following URL to test the app: http://localhost:10001/web/test.
- Select the event that you want to simulate.
- Once you select an event, the corresponding event payload is displayed. Edit the values and then click Simulate. When you edit the payload, ensure that you adhere to the JSON format.
Validate and Pack
To check if the app is error-free and package it for submission, follow the given steps.
To validate the code, run the following command.
$ fdk validate [--app-dir DIR]
Here, DIR is the relative or absolute path to the app directory. If there are errors in the code, corresponding violations are displayed. To auto-fix certain errors and display only those that need manual fixing, use the $fdk validate --fix command. Ensure to fix all violations before packing the app.
- To pack the app for submission, run the following command. $ fdk pack [--app-dir DIR] The command generates the dist/<app_directory>.zip file.
- To publish the app to the Freshworks Marketplace, navigate to the Freshteam developer portal and upload the packed file. For more information on the app submission process, see Types of Apps.