Chatbot sample using Tock and stories written
in Javascript running on Nodejs (see tock-node
).
-
Create a bot application on a Tock platform (Bot API mode), such as the Tock demo public instance.
-
Add a Web connector to the bot and copy the API key.
-
In
index.js (L11)
replace the API key. -
If necessary, declare the Tock platform host, port and WebSocket protocol to use. Default values are
demo-bot.tock.ai
(the public demo),443
andwss
(secured port/protocol).
Tock demo example:
const bot = new Bot('<YOUR_API_KEY_HERE>');
Local instance example:
const bot = new Bot('<YOUR_API_KEY_HERE>', 'localhost', '8080', 'ws');
NOTE: Don't prefix the host with http://
or https://
. Don't suffix it with a relative path or the Web connector path.
- Run
tock-node-example
from root folder:
Using YARN:
yarn install
yarn start
NPM alternative:
npm install
npm start
- When
Connection established
, Tock Nodejs stories are ready to test.