Skip to content

Commit

Permalink
Update sample + documentation according to sdk load change
Browse files Browse the repository at this point in the history
  • Loading branch information
oanguenot committed Dec 27, 2017
1 parent 20d4234 commit 245186d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 38 deletions.
36 changes: 27 additions & 9 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@ The Alcatel-Lucent Enterprise (ALE) Rainbow ChatBot is a JavaScript library for

Rainbow ChatBot allows to create **chatbot** based on JSON scenario in some lines of codes.

This documentation will help you to use it.
This documentation will help you to create your first chatbot.


## Preamble

You need to have Node.JS (stable release) installed on your computer and a recent Rainbow SDK for Node.JS.
You need to have Node.JS (stable release) installed on your computer.

The Rainbow Bots application works on Windows, MacOSX and Linux platforms.
The Rainbow Bots library works on Windows, MacOSX and Linux platforms.

The Rainbow Bots library installs the SDK for Node.Js automatically.



## Install

To install the Rainbow chatbot library, execute the following command
To install the Rainbow Chatbot library, execute the following command

```bash

Expand Down Expand Up @@ -62,12 +64,28 @@ const bot = require("./bot.json");
// Load the scenario
const scenario = require("./scenario.json");

// Initialize the SDK
let nodeSDK = new NodeSDK(bot);
// Start the SDK
nodeSDK = new NodeSDK(bot);
nodeSDK.start().then( () => {
// Start the bot
chatbot = new ChatBot(nodeSDK, scenario);
return chatbot.start();
}).then( () => {
// Do something once the chatbot has been started
...

chatbot.onMessage((tag, step, content, from, done) => {
// Do something when an answer is handled by the bot (i.e. change the route)
...
done();
}, this);

chatbot.onTicket((tag, history, from, start, end) => {
// Do something when a user has completed a scenario
...
}, this);

// Connect the chat bot to the Rainbow SDK and load the scenario
let chatbot = new ChatBot(nodeSDK, scenario);
chatbot.start();
});

```

Expand Down
42 changes: 21 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rainbow-chatbot",
"version": "1.33.0",
"version": "1.34.0",
"description": "Rainbow ChatBot library for the Rainbow SDK for Node.JS",
"main": "index.js",
"scripts": {
Expand All @@ -9,11 +9,11 @@
"build": "grunt sdk"
},
"author": "AL-Enterprise <[email protected]>",
"license": "AL-Enterprise",
"license": "MIT",
"dependencies": {
"cuid": "^1.3.8",
"moment": "^2.19.2",
"rainbow-node-sdk": "^1.33.1",
"rainbow-node-sdk": "^1.34.0",
"winston": "^2.4.0"
},
"devDependencies": {
Expand Down
12 changes: 7 additions & 5 deletions samples/sample_message.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ const bot = require("./bot.json"); // Load bot identity
const scenario = require("./sample_message.json"); // Load scenario

let chatbot = null;
let nodeSDK = null;



// Start the SDK
let nodeSDK = new NodeSDK(bot);
nodeSDK.start().then(() => {
nodeSDK = new NodeSDK(bot);
nodeSDK.start().then( () => {
// Start the bot
chatbot = new ChatBot(nodeSDK, scenario);
chatbot.start();

return chatbot.start();
}).then( () => {
chatbot.onMessage((tag, step, content, from, done) => {
console.log("::: On answer>", tag, step, content, from);

Expand All @@ -28,7 +31,6 @@ nodeSDK.start().then(() => {
chatbot.onTicket((tag, history, from, start, end) => {
console.log("::: On ticket>", tag, history, from, start, end);
}, this);

});


Expand Down

0 comments on commit 245186d

Please sign in to comment.