Deploy in Gitter
Gitter is an open-source instant messaging and chat room system for developers and users of GitLab and GitHub repositories. In this how-to guide, you will learn how to deploy the ding-dong bot in Gitter locally from the Wechaty gitter template.
Requirements
- Your system must have Node.js installed (version >= 12).
- Your system must have Wechaty (version >= 0.40).
Deployment
Run wechaty-puppet-gitter
:
- Linux
- macOS
- Windows
npm install wechaty-puppet-gitter
export WECHATY_PUPPET=wechaty-puppet-gitter
npm start
npm install wechaty-puppet-gitter
export WECHATY_PUPPET=wechaty-puppet-gitter
npm start
npm install wechaty-puppet-gitter
set WECHATY_PUPPET=wechaty-puppet-gitter
npm start
Integration
Let's take up an example on how to integrate the ding-dong bot from Wechaty gitter template. The step is similar for all other bots as well.
Prerequisite
- Official Wechaty package: package/wechaty.
- A TOKEN from gitter so that it can connect to the gitter.im service: developer.gitter.im/docs/services.
You can follow up the steps mentioned below:
- Git clone the Wechaty gitter template.
- From the root directory install the necessary dependencies using the following commands:
npm install wechaty
npm install wechaty-puppet-gitter
- To pass the token, add the snippets below to the head of examples/ding-dong-bot.ts file:
import { Wechaty } from 'wechaty'
/**
* Personal Access Token: this token can be used to access the Gitter API.
* https://developer.gitter.im/apps
*/
const puppet = new PuppetGitter({ token: 'your_gitter_token' })
const wechaty = new Wechaty({ puppet })
wechaty.start()
All necessary functions like onLogout, onLogin, onError, and onMessage are predefined.
Replace your_gitter_token with your 40 digits hexadecimal token id.To generate your own token id, navigate to developer.gitter.im/docs/services and login/signin your account.
Now you can run the bot using the following commands:
WECHATY_LOG=verbose
export WECHATY_PUPPET=wechaty-puppet-gitter
npm start
You have successfully deployed the ding-dong with Gitter!
You can deploy the bot with popular container solutions as well such as:
References
- Find out some more information about puppet from docs/puppet-providers.
- Get the starter template from wechaty-getting-started.