forked from alavers/smooch-bot-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
36 lines (31 loc) · 960 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'use strict';
const Script = require('smooch-bot').Script;
module.exports = new Script({
processing: {
prompt: (bot) => bot.say('Beep boop...'),
receive: () => 'processing'
},
start: {
receive: (bot) => {
return bot.say('Hi! I\'m Smooch Bot!')
.then(() => 'askName');
}
},
askName: {
prompt: (bot) => bot.say('What\'s your name?'),
receive: (bot, message) => {
const name = message.text;
return bot.setProp('name', name)
.then(() => bot.say(`Great! I'll call you ${name}`))
.then(() => 'finish');
}
},
finish: {
receive: (bot, message) => {
return bot.getProp('name')
.then((name) => bot.say(`Sorry ${name}, my creator didn't ` +
'teach me how to do anything else!'))
.then(() => 'finish');
}
}
});