-
Notifications
You must be signed in to change notification settings - Fork 8
/
app.js
31 lines (25 loc) · 1003 Bytes
/
app.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
require('./connectorSetup.js')();
//Bot listening for inbound backchannel events - in this case it only listens for events named "buttonClicked"
bot.on("event", function (event) {
var msg = new builder.Message().address(event.address);
msg.textLocale("en-us");
if (event.name === "buttonClicked") {
msg.text("I see that you just pushed that button");
}
bot.send(msg);
})
//Basic root dialog which takes an inputted color and sends a changeBackground event. No NLP, regex, validation here - just grabs input and sends it back as an event.
bot.dialog('/', [
function (session) {
var reply = createEvent("changeBackground", session.message.text, session.message.address);
session.endDialog(reply);
}
]);
//Creates a backchannel event
const createEvent = (eventName, value, address) => {
var msg = new builder.Message().address(address);
msg.data.type = "event";
msg.data.name = eventName;
msg.data.value = value;
return msg;
}