Skip to main content

Deploy in Whatsapp

Whatsapp is the most popular IM platform, so this how to guide focuses on deploying the bot in Whatsapp locally. You will learn how to deploy the bot in Whatsapp locally and integrate bot from the list of examples present in the starter templete.

Deploy in WeChat

Requirements#

  1. Your system must have Node.js installed (version >= 12).
  2. Your system must have Wechaty (version >= 0.40).
  3. You must be familiar with Wechaty Plugins.

Deployment#

Run wechaty-puppet-whatsapp:

npm install wechaty-puppet-whatsappexport WECHATY_PUPPET=wechaty-puppet-whatsappnpm start

Integrating a Bot to Whatsapp#

Let's take up an example on how to integrate bot from starter templete to Whatsapp.

The steps are similar for all other bots as well.

Prerequisite#

  1. Offical Wechaty package: package/wechaty.
  2. QRCode terminal edition: package/qrcode-terminal.

You can follow up the steps mentioned below:

  1. Initialize the project by creating a new folder `my-bot`.
  2. mkdir my-botcd my-bot
  3. Install the dependencies using the following commands:
  4. npm install wechatynpm install qrcode-terminal
  5. Add the dependencies for using the bot with Whatsapp.
  6. npm install wechaty-puppet-whatsapp
  7. Create a new folder `src` and add a file `my-bot.js`. Add your custom functions to the code snippet below:
  8. const {  Contact,  Message,  ScanStatus,  Wechaty,  log,}= require('wechaty')
    import qrTerm  from 'qrcode-terminal'
    console.log(welcome)const bot = new Wechaty()
    /* *Your function goes here */
  9. After you are done with the file, you can run the bot using the following commands:
export WECHATY_LOG=verboseexport WECHATY_PUPPET=wechaty-puppet-whatsappnode src/my-bot.js

Scan it using your Whatsapp and you are ready to play with the bot!

You can deploy the bot with popular container solutions as well such as:

References#

Blogs#