https://github.com/codeforequity-at/botium-connector-wechat
Botium Connector for Wechat
https://github.com/codeforequity-at/botium-connector-wechat
Last synced: 12 months ago
JSON representation
Botium Connector for Wechat
- Host: GitHub
- URL: https://github.com/codeforequity-at/botium-connector-wechat
- Owner: codeforequity-at
- License: mit
- Created: 2019-03-04T12:43:01.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-12-03T12:30:14.000Z (over 1 year ago)
- Last Synced: 2025-06-02T23:23:57.982Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://www.botium.at
- Size: 12.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Botium Connector for Wechat
[](https://nodei.co/npm/botium-connector-wechat/)
[](https://app.codeship.com/projects/329576)
[](https://badge.fury.io/js/botium-connector-wechat)
[]()
This is a [Botium](https://github.com/codeforequity-at/botium-core) connector for testing your Wechat chatbot.
__Did you read the [Botium in a Nutshell](https://medium.com/@floriantreml/botium-in-a-nutshell-part-1-overview-f8d0ceaf8fb4) articles? Be warned, without prior knowledge of Botium you won't be able to properly use this library!__
## How it works
* Does not use the [Wechat API](http://admin.wechat.com/wiki/index.php), just the webservice behind it.
* Does not support async communication. (Because async communication means call from webservice to Wechat API)
* Just for text messages (booth directions)
* Provides a valid signature, token validation is possible
* Able to emulate sessions (via __WECHAT_GENERATE_FROM_USERNAME__ capability)
It can be used as any other Botium connector with all Botium Stack components:
* [Botium CLI](https://github.com/codeforequity-at/botium-cli/)
* [Botium Bindings](https://github.com/codeforequity-at/botium-bindings/)
* [Botium Box](https://www.botium.at)
## Requirements
* **Node.js and NPM**
* a **Wechat-capable webservice**. It must not bound to Wechat. Its URL must not be public.
* a **project directory** on your workstation to hold test cases and Botium configuration
## Install Botium and Wechat Connector
When using __Botium CLI__:
```
> npm install -g botium-cli
> npm install -g botium-connector-wechat
> botium-cli init
> botium-cli run
```
When using __Botium Bindings__:
```
> npm install -g botium-bindings
> npm install -g botium-connector-wechat
> botium-bindings init mocha
> npm install && npm run mocha
```
When using __Botium Box__:
_Already integrated into Botium Box, no setup required_
## Connecting Wechat to Botium
Create a botium.json with te URL, and Token of your service
```
{
"botium": {
"Capabilities": {
"PROJECTNAME": "",
"CONTAINERMODE": "wechat",
"WECHAT_WEBHOOK_URL": "...",
"WECHAT_TOKEN": "..."
}
}
}
```
To check the configuration, run the emulator (Botium CLI required) to bring up a chat interface in your terminal window:
```
> botium-cli emulator
```
Botium setup is ready, you can begin to write your [BotiumScript](https://github.com/codeforequity-at/botium-core/wiki/Botium-Scripting) files.
## How to start sample
There is a small demo in [samples/techdemo](./samples/techdemo) with Botium Bindings.
It contains a Wechat capable Chatbot, and its Test. They are already configured (see [Chatbot](./samples/techdemo/chatbot/.env), and [Test](./samples/techdemo/test/botium.json)).
The code is separated into Chatbot, and Test project just for better understanding, don't follow this.
Starting:
* Run the Chatbot
```
> cd ./samples/techdemo/chatbot
> npm install && npm start
```
* Run the Test
```
> cd ./samples/techdemo/test
> npm install && npm test
```
## Supported Capabilities
Set the capability __CONTAINERMODE__ to __wechat__ to activate this connector.
### WECHAT_WEBHOOK_URL
The URL to the webservice.
### WECHAT_TOKEN
Wechat token. (Used to register the webhook in Wechat portal)
### WECHAT_TO_USERNAME
_Optional_
Wechat ID of the chatbot. If it is omitted, then Connector generates one
### WECHAT_GENERATE_FROM_USERNAME
_Optional_
Wechat Open ID of the sender. If it is omitted, then Connector generates one for each test. Good to emulate sessions.
## Roadmap
* Support for async messages (Communicating direct with Wechat API)
* Rich component support in Wechat responses (links, images...)
* Simulate user interaction (If Wechat supports it)
* Add some technical checks
* Signature (Token) validation
* Get endpoint (Availability, response, token validation)