Skip to content

Naktibalda/botium-connector-botkit-websocket

Repository files navigation

Botium Connector for Botkit over websockets

NPM

Build Status npm version license

This is a Botium connector for testing your Botkit chatbot over websockets.

Did you read the Botium in a Nutshell articles ? Be warned, without prior knowledge of Botium you won't be able to properly use this library!

How it works ?

This connector connects to websocket endpoint of Botkit web adapter.

It can be used as any other Botium connector with all Botium Stack components:

Requirements

  • Node.js and NPM
  • a Botkit web socket Server
  • a project directory on your workstation to hold test cases and Botium configuration

Install Botium and Botkit Connector

When using Botium CLI:

> npm install -g botium-cli
> npm install -g botium-connector-botkit-websocket
> botium-cli init
> botium-cli run

When using Botium Bindings:

> npm install -g botium-bindings
> npm install -g botium-connector-botkit-websocket
> botium-bindings init mocha
> npm install && npm run mocha

When using Botium Box:

TODO

Connecting your Botkit server to Botium

Open the file botium.json in your working directory and add the Botkit chatbot connection settings.

{
  "botium": {
    "Capabilities": {
      "PROJECTNAME": "<whatever>",
      "CONTAINERMODE": "botkit-websocket",
      "BOTKIT_SERVER_URL": "..."
    }
  }
}

Botium setup is ready, you can begin to write your BotiumScript files.

Quick replies

When using BotiumScript, you can assert quick replies visible texts and use a quick reply to respond with corresponding payload.

Asserting quick replies

For asserting quick replies use BUTTONS Asserter:

#bot
Here are some quick replies
BUTTONS Foo|Bar

Using quick reply

BUTTON takes quick reply visible text as a parameter and sends payload as user input

#me
BUTTON Foo

Message fields

Setting websocket message fields

For setting websocket message fields, you have to use the UPDATE_CUSTOM logic hook. This example changes message type to hello and adds custom name field:

#me

UPDATE_CUSTOM SET_FIELD|type|hello
UPDATE_CUSTOM SET_FIELD|name|John

Asserting websocket message fields

For asserting existence and values of websocket message fields, you can use the JSON_PATH asserter:

#bot
Please wait until I transfer you to someone who can help
JSON_PATH $.frontend_action|talk_to_agent

Examples

More examples can be found in tests/spec directory

Supported Capabilities

Set the capability CONTAINERMODE to botium-connector-botkit-websocket to activate this connector.

BOTKIT_SERVER_URL

The Botkit server url (without any path, just http/https, servername, port)

About

Botium Connector for Botkit over websockets

Resources

License

Stars

Watchers

Forks

Packages

No packages published