-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
43 lines (35 loc) · 1.47 KB
/
app.ts
File metadata and controls
43 lines (35 loc) · 1.47 KB
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
40
41
import * as restify from 'restify';
import * as builder from 'botbuilder';
//=========================================================
// Bot Setup
//=========================================================
// Setup Restify Server
let server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, () => {
console.log(`${server.name} listening to ${server.url}`);
});
// Create chat bot
let connector = new builder.ConsoleConnector().listen();
let bot = new builder.UniversalBot(connector);
// Create LUIS recognizer that points at our model and add it as the root '/' dialog for our Cortana Bot.
let url = 'LUIS_URL';
let recognizer = new builder.LuisRecognizer(url);
let intents = new builder.IntentDialog({ recognizers: [recognizer] });
bot.dialog('/', intents);
//=========================================================
// Bots Dialogs
//=========================================================
// Add intent handlers
intents.matches('orderBeer', [
(session, args, next) => {
// Resolve and store any entities passed from LUIS.
let brand = builder.EntityRecognizer.findEntity(args.entities, 'brand');
let size = builder.EntityRecognizer.findEntity(args.entities, 'size');
session.send(`Vous avez commandé une ${brand.entity} en ${size.entity}. Elle est en cours de préparation !`);
}
]);
intents.matches('None', [
(session, args, next) => {
session.send(`Je n'ai pas compris votre demande`);
}
]);