The Freshworks Command-Line Interface (CLI) enables you to build, test, and package apps that are published to the Marketplace.
To view the list of CLI commands, after you install the CLI, at the command prompt type fdk and press Enter.Copied Copy
|❯ fdk Usage: fdk [global-flag] [command] [command-flags] [arguments] The Freshworks CLI enables you to build, test and publish apps on Freshworks Developer Platform Options: -v, --version prints the current version -u, --skip-update-check Skips daily check for new cli versions -d, --app-dir <directory> directory is the path to the directory where the app will be created. If this option is not specified, the app will be created in the current directory. -h, --help display help for command Commands: create [options] Creates a new app based on the specified options generate Generates configuration files for the app run [options] Runs the app on a local server for testing validate [options] Validates the app code pack [options] Creates the app package that can be submitted to the Marketplace version Display installed and latest version search [options] <phrase> Searches our developer community for a specified post test [options] Run tests defined for the current app help [command] display help for command ℹ For complete documentation please visit: https://freshworks.dev/ and navigate to the Documentation section.|
- To view the information about a CLI command, run the following command.
$ fdk COMMAND (-h | --help)
❯ fdk create -h Usage: fdk create [options] Creates a new app based on the specified options Options: -p, --product <product> where product is a Freshworks product. If this option is not specified, a prompt is displayed with the list of supported products. -t, --template <template> where template is the name of one of the templates that can be used as a starting point for development. If this option is not specified, a prompt is displayed with the list of supported templates for the given product. -h, --help display help for command EXAMPLE: $ fdk create $ fdk create --product freshservice --template your_first_app $ fdk create --app-dir /Users/user/myfirstapp ℹ For complete documentation please visit: https://freshworks.dev/ and navigate to the Documentation section.
- To obtain detailed logs, run the following command. $ NODE_DEBUG=fdk fdk COMMAND
Version update lifecycle
When you run the Freshworks CLI commands, if no version update check has run in the last 24 hours, the FDK:
- Checks whether a new FDK version is available.
- If a new version is available and if you are not on the latest version, displays an update prompt that enables you to move to the latest version.
- Keeps track of the update check time.
To prevent the FDK from checking for version updates, you can use the --skip-update-check option, along with the CLI commands, as follows:$ fdk <-u or --skip-update-check> <COMMAND> Examples $ fdk --skip-update-check create $ fdk -u run As a result of using the --skip-update-check option, the update prompt is not displayed.
The command creates an app in the specified directory, based on the default app template. If no directory is specified, the app is created in the current directory.
|--app-dir||To specify the absolute or relative path of the project directory where the app is to be created. If the option is not used with the create command, the app is created in the current directory.|
|--products||To specify the product for which the app is created. If the option is not used with the create command, you are prompted to select a product. Select freshworks_crm.|
|--template||To specify the template for which the app is created. If the option is not used with the create command, you are prompted to select a template.
Select the your_first_app template to create a front-end app and the your_first_serverless_app template to create a serverless app.
To create a Freshsales Suite app in the current directory, run the following command. Before you run the command, ensure that the current directory is empty. $ fdk create --products freshworks_crm --template your_first_app
A Freshsales Suite app is created based on the your_first_app template with the following files.
To create a Freshsales Suite app in the myfirstapp directory, run one of the following commands. Before you run the command, ensure that the myfirstapp directory is empty.
- $ fdk create --app-dir ./myfirstapp
- $ fdk create --app-dir /Users/user/myfirstapp
The app files are created in the /Users/user/myfirstapp directory.
This command is used to generate app files with a specific template for an existing app that was created by using the create command.
- After you create an app, run the following command. $ fdk generate The list of the following files is displayed.
- oauth_config.json: Contains the configuration parameters, such as client_id, client_secret, authorize_url, token_url, and account/agent scope, required for OAuth-based authentication.
- iparams.json: Contains the installation parameters, such as iparam name and type of iparam, whose values are set when the app is installed.
- iparams.html: Contains the html code to build the Custom Installation page. You can enter the page title, select the product css to link, and choose to add jquery, fresh_client.js, and iparam.js and iparam.css.
- server.js: Contains the event registration and callback methods. You need to enter the names of the events and callback functions.
- manifest.json: Contains app information such as platform version, product, location, event registration, and so on. You need to select the product and app location.
- Select a file and enter the appropriate parameter values. The corresponding file is generated based on the values.
The run command starts the local server, deploys the app project on the server, and enables you to test the app.$ fdk run [--app-dir DIR]
Example: $ fdk run -d /user/myFirstApp
|Specifies the directory path to the folder that contains the app that is tested locally.|
Example: $ fdk run -V lint
|Skips specific validation checks. The errors associated with the validation, if any, are not displayed when the app is tested locally.|
If you are running a serverless app that contains dependencies, the packages defined in manifest.json are automatically installed.
After testing, press Control + C to stop the server. A code coverage summary that indicates the extent of testing is displayed. A coverage summary that indicates extensive testing is as follows.
|======================= Coverage summary ======================== Statements : 98.18% ( 54/55 ) Branches : 100% ( 4/4 ) Functions : 84.62% ( 22/26 ) Lines : 98.18% ( 54/55 ) =================================================================|
When apps are submitted for the App Review process, ensure that in the coverage summary, the coverage of each component is at least 80%. See Code coverage for more information.
To deploy the app project located in the current directory, run the following command:
Append "dev=true" to your Freshworks_crm account URL to start testing
Quit the server with Control-C.
To deploy the app project located in the myfirstapp directory, run the following command:
$ fdk run --app-dir /Users/user/myfirstapp The output will be the same as Example 1.
To deploy a serverless app project located in the myfirstapp directory, run the following command:
$ fdk run --app-dir /Users/user/myfirstapp Output $ Starting local testing server at http://*:10001/
Append "dev=true" to your Freshworks_crm account URL to start testing
Quit the server with Control-C.
To simulate product, app setup, and external events, visit - http://localhost:10001/web/test
To test the installation page, visit - http://localhost:10001/custom_configs
Configurable parameter$ [REQUEST_TIMEOUT=<timeout in milliseconds>] fdk run
|REQUEST_TIMEOUT||Specify the time in milliseconds after which a Request Method call times out during local testing.
Example: REQUEST_TIMEOUT=10000 fdk run
Minimum value: 5000
Maximum value: 10000
Note: If you specify a REQUEST_TIMEOUT value that breaches the min or max limits, the timeout is defaulted to the min or max value and a warning message is displayed.
Note: Ensure to install or update to the latest FDK version.
This command validates whether the app code is error free. If there are errors in the code, corresponding violations are displayed after the command is run.$ fdk validate [--app-dir DIR] [--fix]
Example: $ fdk validate -d /user/myFirstApp
|Specifies the directory path to the folder that contains the app that is validated.|
|When validating an app, the option fixes all lint errors for which auto-fix support is available.|
Example: $ fdk pack -V lint
|Skips specific validation checks. The errors associated with the validation, if any, are not displayed when the app is validated|
The latest FDK version requires Node.js 14 or later versions. If you run the fdk validate command to validate an app built using an earlier (major) Node.js version and if your current Node.js runtime environment is 14 or later, the FDK displays a warning message and a prompt asking whether you want to continue. If you continue with the validation, the FDK:
Deletes the existing coverage folder. The folder contains the results of the fdk run command that is used to set up the local server and test an app.
Deletes the node_modules folder. The folder contains the npm dependencies (specified in manifest.json) that are installed when the fdk run command is run.
Includes or updates the engines attribute in manifest.json. The updated engines.node and engines.fdk values reflect the Node.js and FDK versions on which the app is validated.
After a successful validation, ensure to retest the app by using the fdk run command. The retesting generates the coverage folder and the coverage summary that is required to pack your app for submission.
If there is a minor Node.js version mismatch between the version used to build the app and the current Node.js runtime version, the FDK automatically updates manifest.json > engines.node to reflect the Node.js version on which the app is validated.
Note: Before packing, ensure to validate the app; resolve all Node.js version mismatch issues, if any.
The pack command creates an app package file that can be submitted for the app review process.$ fdk pack [--app-dir DIR]
Example: $ fdk pack -d /user/myFirstApp
|Specifies the directory path to the folder that contains the app that is packed.|
Example: $ fdk pack -V lint
|Skips specific validation checks. The errors associated with the validation, if any, are not displayed when the app is packed.|
The command displays the Node.js and FDK versions that are used when packing the app.
After you run the pack command, a dist/<appdirectory>.zip file is generated. To submit the app and get it published to the Freshworks Marketplace, upload the generated file to the Freshsales developer portal.
To pack the app files located in the current app project directory, run the following command: $ fdk pack
The /dist/<current_app_directory>.zip file is generated.
To pack the app project files located in the myfirstapp directory, run the following command: $ fdk pack --app-dir /Users/user/myfirstapp The /dist/myfirstapp.zip file is generated.
The version command displays the installed and latest CLI version numbers.$ fdk version
To install the latest version type "npm install https://dl.freshdev.io/cli/fdk.tgz -g"
The FDK includes a testing framework (currently in beta) to help test serverless apps. This enables you to write and maintain unit tests as part of app files. The test command runs these unit tests.$ fdk test For information on how to use the testing framework and the output of the test command, see the Testing Framework documentation.
The search command searches our developer community for all content relevant to the specified query-string (search phrase) and lists the links to the content. If the search finds appropriate WIKI articles, the articles are listed first and then other relevant content in the community are listed.$ fdk search [query-string]
$ fdk search Serverless app
Outputℹ Here is what we found: #1 How to configure GraphQL for Appsync API from Serverless app? https://community.freshworks.dev/t/1362 #2 How can we handle Callback URL redirection in FD serverless app? https://community.freshworks.dev/t/388 #3 Reading/creating data from serverless app https://community.freshworks.dev/t/223 #4 How to validate user input on routing automation in Freshcaller with the help of Serverless app? https://community.freshworks.dev/t/849 #5 Raise timeout for serverless app api requests https://community.freshworks.dev/t/6473 #6 How to handle exceptions in a freshdesk serverless app https://community.freshworks.dev/t/3149 #7 Need to call HTTP REST API with JSON request from FD Serverless app https://community.freshworks.dev/t/374 #8 Axios not working in Freshservice serverless APP https://community.freshworks.dev/t/8149 ✔ search complete
The FDK includes a testing framework (currently in beta) to help test serverless apps. This enables you to write and maintain unit tests as part of app files. The test command runs these unit tests. $ fdk test
For information on how to use the testing framework and the output of the test command, see the Testing Framework documentation.