forked from onyxolu/covid19Bot_Nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
41 lines (33 loc) · 1.17 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
const botbuilder = require("botbuilder");
const restify = require("restify");
const Botmenu = require("./bot_core/menu");
const server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, () => {
console.log("%s listening.....", server.name);
});
const connector = new botbuilder.ChatConnector({
appId: "759e7feb-45ac-46dd-bf29-199acda0aecc",
appPassword: "n4.fnGUFHqc=[x7V[ZFPoczd7UxVguQ4",
});
const inMemoryStorage = new botbuilder.MemoryBotStorage();
const bot = new botbuilder.UniversalBot(connector, (session) => {
session.beginDialog("/welcome");
}).set("storage", inMemoryStorage);
server.post("/api/messages", connector.listen());
const menu = new Botmenu();
menu.init(bot, botbuilder);
bot.on("conversationUpdate", (message) => {
if (message.membersAdded) {
message.membersAdded.forEach((identity) => {
if (identity.id == message.address.bot.id) {
let reply = new botbuilder.Message()
.address(message.address)
.text(
"Welcome to the Covid-19 bot of Microsoft Tech Community Unilag. Press any key to continue"
);
bot.send(reply);
} else {
}
});
}
});