Skip to main content

WeChat as an inbound channel

WeChat is a text and voice messenger that also supports video and voice VoIP calls.

Do the following to use WeChat as an inbound channel:

  1. Create a test account.
  2. Create a channel.
  3. Test the bot.

Creating a test account

WeChat only allows one bot to be connected to one test account at a time. To connect other bots, create a new test account for each bot.

You will need to register a WeChat account and install the official app on your smartphone to create a bot.

We will connect an app-based bot for a test account in the WeChat interface. You might want to install a plugin or switch your language, as the website is only available in Chinese.

  1. Click Authorize, and the page with a QR code will appear.
  2. Open the WeChat mobile app and click plus → Scan QR code.
  3. Scan the QR code from the web page and click Agree in the window that appears. You will get administrative access to the test account.
  4. Copy the following values: WeChat ID, appID and appsecret. You will need them to create a channel.

test account parameters

  1. In the URL field, enter the server address to which WeChat will send us requests. The server address should be the following way:
  1. In the Token field, you need to enter WeChat ID to generate a signature. This field must match the WeChat_ID specified in the server URL to pass the security check.

  2. Click Submit and proceed to create a channel.

Creating a channel

Click Channels → Inbound → Connect channel on the control panel. Select WeChat under Messengers and social networks.

Fill out the following fields:

  • Name — specify a name for the channel or keep the default one.
  • Access token — specify your bot’s WeChat ID generated when you created your test account.
  • AppID — specify the application ID generated when you created your test account.
  • Appsecret — specify the application access token generated when you created your test account.
  • Branch — specify the project branch you want to deploy into the channel (master by default). You can also select a Git tag or enter a specific commit hash.
  • Deployment — select Automatic (whenever any change made to the project is saved) or Manual (using the Deploy button in the channel description line).
You have to deploy a script before starting the bot. At this stage, the system builds the bot, checks the script syntax, and performs tests.

Click Create. Wait for a pop-up window with the deploy result to appear.

Testing a bot

To open a dialog window with a bot in WeChat:

  1. Open the WeChat mobile app and click plus → Scan QR code.
  2. Go to the test account web page, find the QR code, and scan it using the app.
  3. A test account will appear in the app. Click Follow. The dialog window will be opened automatically.
  4. Send a greeting/activation phrase according to your script. Then a dialog with your bot should start.
To open the bot chat in the app, go to Contacts → Official accounts and find your test account chat in the list.