The Apps Engine CLI
This guide will help you get started with our official Apps Engine Command Line Interface (CLI) to start creating your own apps.
The Rocket.Chat Apps Engine CLI is a simple Command Line Interface, that gives you a kickstart in developing your Rocket.Chat App. Using simple commands, you can create a basic app structure, package & deploy into your RC Server. Not just that, we have extended its capability to generate boilerplate code for various functions, display autocomplete installation instructions, submit an App to the Marketplace for review and much more.
The CLI available on GitHub and published on NPM. It provides an easy interface for developing extensions. Follow the quick steps below to create your first application.

Installation

Before installing the CLI make sure that you have Node already installed on your machine. To verify Node installation, use the following command in your terminal.
1
node -v
2
# v10.15.3
3
# It should return you a valid version.
Copied!
Once you have installed Node, run the following command in your terminal to install the CLI globally.
1
npm install -g @rocket.chat/apps-cli
Copied!
It will take a while to install the CLI depending on your internet connection. After installation, run the following command to verify the installation.
1
rc-apps -v
2
# @rocket.chat/apps-cli/1.4.0 darwin-x64 node-v10.15.3
Copied!
Note that the response may vary depending on your machine and environment, but it should look similar. Now, you are all set to create your first app.

App Development using CLI

Logging Inside an App

Due to limitations of NodeJS's vm package we have had to implement a custom logger class. To make usage of this you can use this.getLogger() and then do the normal console style logging.

rc-apps create

The development tools provide a command to quickly scaffold a new Rocket.Chat App, simply run rc-apps create and a new folder will be created inside the current working directory with a basic App which does nothing but will compile and be packaged in the dist folder.

App description

The app description file, named app.json, contains basic information about the app. You can check the app-schema.json file for all the detailed information and fields allowed in the app description file, the basic structure is similar to this:
1
{
2
"id": "5cb9a329-0613-4d39-b20f-cc2cc9175df5",
3
"name": "App Name",
4
"nameSlug": "app-name",
5
"version": "0.0.1",
6
"requiredApiVersion": "^1.4.0",
7
"description": "App which provides something very useful for Rocket.Chat users.",
8
"author": {
9
"name": "Author Name <[email protected]>",
10
"support": "Support Url or Email"
11
},
12
"classFile": "main.ts",
13
"iconFile": "beautiful-app-icon.jpg"
14
}
Copied!

Extending the App class

The basic creation of an App is based on extending the App class from the Rocket.Chat Apps definition library. Your class also has to implement the constructor and optionally the initialize function, for more details on those check the App definition documentation.
1
import {
2
IAppAccessors,
3
IConfigurationExtend,
4
IEnvironmentRead,
5
ILogger,
6
} from '@rocket.chat/apps-engine/definition/accessors';
7
import { App } from '@rocket.chat/apps-engine/definition/App';
8
import { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata';
9
10
export class TodoListApp extends App {
11
constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) {
12
super(info, logger, accessors);
13
}
14
15
public async initialize(configurationExtend: IConfigurationExtend, environmentRead: IEnvironmentRead): Promise<void> {
16
await this.extendConfiguration(configurationExtend, environmentRead);
17
this.getLogger().log('Hello world from my app');
18
}
19
}
Copied!

Packaging the app

Currently the Rocket.Chat servers and Marketplace allow submission of zip files, these files can be created by running rc-apps package which packages your app and creates the zip file under dist folder.

Uploading the app

For uploading the app you need add to the required parameters in the .rcappsconfig already created in the apps directory. It accepts two types of objects:-
  • Upload using username, password
1
{
2
url: string;
3
username: string;
4
password: string;
5
}
Copied!
  • Upload using personal access token and userId
1
{
2
url: string;
3
userId: string;
4
token: string;
5
}
Copied!

Enabling autocomplete for commands

To enable autocomplete for the apps cli use the command rc-apps autocomplete <your-shell-type> with the shell type as zsh or bash as the supported types. This would provide a step by step instruction to enable shell completion in your preferred shell.
Last modified 12h ago