The BotKit framework is on open-source framework for bots. It provides support for conversations, regular expressions, hooks for language understanding services, and lots more.
Our botkit service lives here: https://crm-sod.superoffice.com/botkit/ There is a simple web chat there you can use to test the bot.
It has no state, and just uses some simple matching rules. It is a glorified echo bot.
- "sample" -> I heard a sample message.
- "foo" -> I heard "foo" via a function test
- "123" -> I heard a number using a regular expression.
- "ABC" -> I HEARD ALL CAPS!
- wildcard -> Echo: wildcard
These rules are coded into the botkit/features/ folder. It's easy to extend the botkit with more rules.
We post the message to https://crm-sod.superoffice.com/botkit/api/messages
{ "type":"message",
"text":"see",
"user":"28ef498a-936d-9e6a-8117-bb7a20d43e9c",
"channel":"webhook" }
and get back one or more message responses:
[ {
"type": "message",
"text": "Echo: see"
} ]
We just mirror the botkit response to the chat session.
- Install NodeJS
- Go to the
botkit
folder. - Open a command-line window
npm install
will download all the dependencies.npm run start
wil start the bot on localhost port 3000- open a browser to http://localhost:3000/ to see a web chat for testing.
- Create a CrmScript folder named 'Botkit'.
- Place the 3 CrmScripts into the folder.
- The presence of a script named
...bot register...
signals the existence of a chatbot in the folder. - Go to the Chat admin and open a chat topic.
- Go to the Chatbot tab and enable the chatbot.
- Choose the "Botkit" folder from the list, and name the chatbot.
- Save the chat topic.
Now open a chat window for the chat topic. You should be greeted by the Botkit using the name you gave in step 6.
When the chat channel (aka topic) is configured and saved, the ...bot register...
script is called.
The CrmScript folder is scanned for additional scripts, and the ones with recognized names are noted.
When a customer clicks the chat button, a new chat session is created.
If the chat channel the session is in has a chatbot enabled, then the chatbot script called ...bot session created...
is called.
The bot session created
script calls the botkit API to start the session, and posts a welcome message to the chat.
When the user posts a message to the channel, and the bot is active, then the script called
...bot message received...
is called.
The script builds a JSON structure with the message text from the customer, and posts it to botkit. Botkit formulates a response and returns a JSON array with one or more messages.
We post the botkit response as a new message to the chat.