-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (33 loc) · 1.1 KB
/
index.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
37
38
39
const restify = require('restify')
const builder = require('botbuilder')
// Setup Restify Server
const server = restify.createServer()
server.listen(process.env.port || process.env.PORT || 3978, () => {
console.log('%s listening to %s', server.name, server.url)
})
// Create chat connector for communicating with the Bot Framework Service
const connector = new builder.ChatConnector({
appId: process.env.APP_ID,
appPassword: process.env.APP_SECRET
})
// Listen for messages from users
server.post('/api/messages', connector.listen())
// Receive messages from the user and respond by echoing each message back (prefixed with 'You said:')
const bot = new builder.UniversalBot(connector, function (session) {
session.beginDialog('bigfive')
})
bot.dialog('bigfive', [
function (session) {
session.beginDialog('selectLanguange')
}
])
bot.dialog('selectLanguange', [
function (session) {
builder.Prompts.text(session, 'Please select language')
},
function (session, results) {
console.log(results)
session.send(`You selected ${results.response}`)
session.endDialogWithResult(results)
}
])