-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
executable file
·38 lines (31 loc) · 1.29 KB
/
bot.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
'use strict';
require('dotenv').config();
const server = require('restify').createServer();
server.listen(process.env.port || process.env.PORT || 3978, '::', () =>
console.log('%s listening to %s', server.name, server.url)
);
const builder = require('botbuilder');
const connector = new builder.ChatConnector({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
});
server.post('/api/messages', connector.listen());
const bot = new builder.UniversalBot(connector);
bot.dialog('/',
new builder
.IntentDialog({ recognizers: [new builder.LuisRecognizer(process.env.LUIS_APP_MODEL)] })
.matches('builtin.intent.communication.send_text', [
(session, args) => {
let message = builder.EntityRecognizer.findEntity(args.entities, 'builtin.communication.message');
message = message && message.entity;
let contact_name = builder.EntityRecognizer.findEntity(args.entities, 'builtin.communication.contact_name');
contact_name = contact_name && contact_name.entity;
session.send(`You asked to send the message "${message}" to "${contact_name}"`);
}
])
.onDefault(
(session) => {
session.send("I am a very simple bot. Try asking me to send a message.");
}
)
);