Skip to main content

Deploy in WeChat Official Account

WeChat Official Account is a perfect enforcement of the concept of SoLoMo(Social, Local, Mobile) Marketing and has tonnes of features to interact with the audience. In this how to guide, you will learn how to deploy the bot in WeChat Official Account locally and integrate bot from the list of examples present in starter templete.

Deploy in Lark

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 puppet official account.

Deployment#

npm install wechaty-puppet-official-accountexport WECHATY_PUPPET=wechaty-puppet-official-accountnpm start

Integration#

Let's take up an example on how to integrate bot from starter templete to WeChat Official Account. The step is similar for all other bots as well.

Prerequisite#

  1. Official Wechaty package: package/wechaty.
  2. Address of the service provider that supports HTTP and HTTPS such as 80, 443. Several internet penetration tools: localtunnel.
  3. Permanent external network address: ngrok.

You can follow up the steps mentioned below:

  1. Initialize the project by creating a new folder my-bot.
mkdir my-botcd my-bot
  1. Install the dependencies using the following commands:
npm install wechaty
  1. Develop temporary internet address as follows:
npm install -g localtunnel lt โ€“port 80
  1. Add the dependencies for using the bot with WeChat Official Account:
npm install wechaty-puppet-official-account
  1. Create a new folder src and add a file my-bot.js. Add any of the functions from add functionality to the bot section to the snippet below:
import {  Contact,  Message,  ScanStatus,  Wechaty,  log,} from 'wechaty'console.log(welcome)const bot = new Wechaty()/* *Your function goes here */
  1. Configure your appId, appSecret, token, port as follows:
const bot = new Wechaty({    name: '<your bot name>',  puppet: new PuppetOA({    appId: "wxbd801c28fbe1bbbd",    appSecret: "6959408a3ba1c82db1a11d941df65764",    token: "token",    port: 80  })})
  1. After you are done with the file, you can run the bot using the following commands:
export WECHATY_LOG=verboseexport WECHATY_PUPPET=wechaty-puppet-official-accountnode src/my-bot.js

Now, you are ready to play with the bot!

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

References#

Blogs#