Migrating Bot Boot logic to BotFmwV4.
This commit is contained in:
parent
f6bf1068bb
commit
96f78956b6
4 changed files with 36 additions and 25 deletions
|
@ -56,9 +56,10 @@ export class WelcomeDialog extends IGBDialog {
|
||||||
date < 12 ? "bom dia" : date < 18 ? "boa tarde" : "boa noite";
|
date < 12 ? "bom dia" : date < 18 ? "boa tarde" : "boa noite";
|
||||||
|
|
||||||
let messages = [`Oi, ${msg}.`, `Oi!`, `Olá, ${msg}`, `Olá!`];
|
let messages = [`Oi, ${msg}.`, `Oi!`, `Olá, ${msg}`, `Olá!`];
|
||||||
dc.context.sendActivity(messages[0]);
|
await dc.context.sendActivity(messages[0]);
|
||||||
|
|
||||||
if (dc.context.activity && dc.context.activity.text != "") {
|
if (dc.context.activity && dc.context.activity.type == "message" &&
|
||||||
|
dc.context.activity.text != "") {
|
||||||
await dc.replace("/answer", { query: dc.context.activity.text });
|
await dc.replace("/answer", { query: dc.context.activity.text });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@ export class GuaribasInstance extends Model<GuaribasInstance> implements IGBInst
|
||||||
@Column
|
@Column
|
||||||
instanceId: number;
|
instanceId: number;
|
||||||
|
|
||||||
|
@Column applicationPrincipal: string;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
whoAmIVideo: string;
|
whoAmIVideo: string;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const gBuilder = require("botbuilder");
|
const gBuilder = require("botbuilder");
|
||||||
const {TextPrompt} = require("botbuilder-dialogs");
|
const { TextPrompt } = require("botbuilder-dialogs");
|
||||||
const UrlJoin = require("url-join");
|
const UrlJoin = require("url-join");
|
||||||
const Path = require("path");
|
const Path = require("path");
|
||||||
const Fs = require("fs");
|
const Fs = require("fs");
|
||||||
|
@ -231,7 +231,6 @@ export class GBMinService {
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
min.dialogs.add('textPrompt', new TextPrompt());
|
min.dialogs.add('textPrompt', new TextPrompt());
|
||||||
|
|
||||||
server.post(`/api/messages/${instance.botId}`, (req, res) => {
|
server.post(`/api/messages/${instance.botId}`, (req, res) => {
|
||||||
|
@ -258,22 +257,40 @@ export class GBMinService {
|
||||||
user.subjects = [];
|
user.subjects = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
`[RCV]: ${context.activity.type}, ChannelID: ${context.activity.channelId},
|
||||||
|
ConversationID: ${context.activity.conversation.id},
|
||||||
|
Name: ${context.activity.name}, Text: ${context.activity.text}.`
|
||||||
|
);
|
||||||
|
|
||||||
if (context.activity.type === "conversationUpdate" &&
|
if (context.activity.type === "conversationUpdate" &&
|
||||||
context.activity.membersAdded.length > 0) {
|
context.activity.membersAdded.length > 0) {
|
||||||
|
|
||||||
// TODO: Something when starting conversation here.
|
let member = context.activity.membersAdded[0];
|
||||||
|
if (member.name === "GeneralBots") {
|
||||||
|
logger.info(`Bot added to conversation, starting chat...`);
|
||||||
|
appPackages.forEach(e => {
|
||||||
|
e.onNewSession(min, dc);
|
||||||
|
});
|
||||||
|
await dc.begin('/');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger.info(`Member added to conversation: ${member.name}`);
|
||||||
|
}
|
||||||
|
|
||||||
await dc.continue();
|
|
||||||
} else if (context.activity.type === 'message') {
|
} else if (context.activity.type === 'message') {
|
||||||
|
|
||||||
// Check to see if anyone replied. If not then start echo dialog
|
// Check to see if anyone replied. If not then start echo dialog
|
||||||
|
|
||||||
if (!user.once) {
|
if (context.activity.text === "admin") {
|
||||||
await dc.begin('/');
|
|
||||||
} else if (context.activity.name === "whoAmI") {
|
|
||||||
dc.begin("/whoAmI");
|
|
||||||
} else if (context.activity.text === "admin") {
|
|
||||||
dc.begin("/admin");
|
dc.begin("/admin");
|
||||||
|
} else {
|
||||||
|
await dc.continue();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (context.activity.type === 'event') {
|
||||||
|
if (context.activity.name === "whoAmI") {
|
||||||
|
dc.begin("/whoAmI");
|
||||||
} else if (context.activity.name === "showSubjects") {
|
} else if (context.activity.name === "showSubjects") {
|
||||||
dc.begin("/menu");
|
dc.begin("/menu");
|
||||||
} else if (context.activity.name === "giveFeedback") {
|
} else if (context.activity.name === "giveFeedback") {
|
||||||
|
@ -295,15 +312,6 @@ export class GBMinService {
|
||||||
await dc.continue();
|
await dc.continue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
appPackages.forEach(e => {
|
|
||||||
e.onNewSession(min, dc);
|
|
||||||
});
|
|
||||||
|
|
||||||
logger.info(
|
|
||||||
`[RCV]: ChannelID: ${context.activity.channelId}, ConversationID: ${context.activity.conversation.id}
|
|
||||||
Type: ${context.activity.type}, Name: ${context.activity.name}, Text: ${context.activity.text}.`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,7 +35,7 @@ import { UserAgentApplication } from "msal";
|
||||||
|
|
||||||
class GBLoginPlayer extends React.Component {
|
class GBLoginPlayer extends React.Component {
|
||||||
|
|
||||||
constructor() {
|
constructor(tenant) {
|
||||||
super();
|
super();
|
||||||
this.state = {
|
this.state = {
|
||||||
token: "",
|
token: "",
|
||||||
|
|
Loading…
Add table
Reference in a new issue