Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Extend Rocket.Chat with Apps: Step-by-Step Guide

· 4 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can extend Rocket.Chat with apps to add custom slash commands, integrate external services, automate workflows, and change the UI. Apps run inside Rocket.Chat's own App Engine, so you don't need to modify the core server. Before you start, you'll need a Rocket.Chat server (version 6.0 or later recommended) and an account with admin or app-developer permissions.

What You'll Need

  • A Rocket.Chat server (self-hosted or cloud) where you have admin or app-publishing rights.
  • Node.js and npm installed locally (for building and testing apps).
  • Rocket.Chat App CLI (rc-apps) installed globally via npm.
  • Basic knowledge of JavaScript and REST APIs.
  • Access to the Rocket.Chat Marketplace or the ability to upload apps manually.

Step-by-Step

  1. Install the App CLI. Open a terminal and run npm install -g @rocket.chat/apps-cli. Verify with rc-apps --version.
  2. Create a new app project. Run rc-apps create my-app and follow the prompts. This generates a folder with the app's basic structure.
  3. Open the project in your code editor. The main files are App.ts, manifest.json, and commands/ or slashcommands/ folders.
  4. Edit the manifest. In manifest.json, set a unique app ID, name, version, and add permissions your app needs (e.g., slashcommand, send-messages).
  5. Write your first slash command. In the commands folder, create a file like hello.ts. Extend SlashCommand and implement executor() to send a message back. Example:
    import { IHttp, IModify, IRead } from '@rocket.chat/apps-engine/definition/accessors';
    import { SlashCommand } from '@rocket.chat/apps-engine/definition/slashcommands';
    
    export class HelloCommand extends SlashCommand {
      public command = 'hello';
      public i18nParamsExample = '';
      public i18nDescription = '';
      public providesPreview = false;
    
      public async executor(context, read, modify, http, persistence) {
        const message = modify.getCreator().startMessage()
          .setText('Hello from my app!')
          .setRoom(context.room);
        await modify.getCreator().finish(message);
      }
    }
  6. Register the command. In App.ts, import and add the command in the extendConfiguration method: configuration.slashCommands.provideSlashCommand(new HelloCommand());
  7. Test locally (optional). Use the CLI to run tests: rc-apps test.
  8. Deploy the app. Run rc-apps deploy --url https://your.rocket.chat --username your_admin --password your_password. This uploads and installs the app on your server.
  9. Verify in Rocket.Chat. Open any channel, type /hello, and you should see the response.
  10. Extend further. Add more features like HTTP requests, scheduled jobs, or UI buttons by exploring the App Engine API. Refer to the official Rocket.Chat Apps Engine documentation for available modules.

Common Mistakes

  • Wrong app ID format. The manifest requires a reverse-domain style ID (e.g., com.example.myapp). Using spaces or uppercase will cause errors.
  • Missing permissions. If your app tries to send messages but doesn't have the send-messages permission, it will fail silently or throw an error.
  • Not updating the manifest after adding commands. Some changes require bumping the version in manifest.json and redeploying.
  • Forgetting to restart the server after manual uploads. If you upload an app manually via the admin panel, a server restart may be needed for it to activate.
  • Using deprecated APIs. The Apps Engine evolves; check the version of the engine your server uses and match your code accordingly.

Tips

  • Start small: build one slash command first, then expand.
  • Use the Rocket.Chat Apps Engine TypeScript definitions for autocomplete and type checking.
  • Test on a development server before deploying to production.
  • Use environment variables for sensitive data like API keys, not hard-coded strings.
  • Check the Rocket.Chat Marketplace for existing apps that might already do what you need—don't reinvent the wheel.

Troubleshooting

If your app doesn't work as expected, try these in order:

  1. Check the server logs. Look for errors related to your app ID. Logs are in the admin panel under Administration > Logs.
  2. Verify the app is enabled. Go to Administration > Apps and ensure your app is installed and not disabled.
  3. Re-deploy the app. Sometimes the upload fails silently; run rc-apps deploy again.
  4. Clear the app's cache. In the admin panel, you can uninstall and reinstall the app.
  5. Check the manifest for errors. Use a JSON validator to ensure the file is valid.
  6. If the command doesn't appear, make sure the command name is lowercase and doesn't conflict with built-in commands.
  7. If the app uses HTTP requests, ensure the server can reach external URLs (firewall rules may block outbound requests).

Frequently Asked Questions

Can I extend Rocket.Chat without writing code?

Yes, you can use the Rocket.Chat Marketplace to install pre-built apps, but custom features require coding.

Do apps work on both cloud and self-hosted Rocket.Chat?

Yes, apps work on both, but self-hosted servers may need the App Engine enabled in settings.

Can I use Python or other languages?

No, apps are written in TypeScript/JavaScript using the Apps Engine SDK.

How do I update an app after changes?

Run rc-apps deploy again with the same app ID; it will overwrite the existing version.

What permissions does my app need to send messages?

Add send-messages to the permissions array in manifest.json.

Can I make money from my Rocket.Chat app?

Yes, you can publish it to the Marketplace and set a price, but you must follow Rocket.Chat's marketplace guidelines.