Parameter whatsappServiceWebhookUrl added.
This commit is contained in:
parent
1bc4b37827
commit
3b6edd4f3a
4 changed files with 183 additions and 179 deletions
|
@ -99,6 +99,8 @@ export class GuaribasInstance extends Model<GuaribasInstance> implements IGBInst
|
||||||
|
|
||||||
@Column whatsappServiceUrl: string;
|
@Column whatsappServiceUrl: string;
|
||||||
|
|
||||||
|
@Column whatsappServiceWebhookUrl: string;
|
||||||
|
|
||||||
@Column spellcheckerKey: string;
|
@Column spellcheckerKey: string;
|
||||||
|
|
||||||
@Column theme: string;
|
@Column theme: string;
|
||||||
|
|
|
@ -41,13 +41,13 @@ import { GBCoreService } from "./GBCoreService";
|
||||||
|
|
||||||
import { Session, Message, LuisRecognizer } from "botbuilder";
|
import { Session, Message, LuisRecognizer } from "botbuilder";
|
||||||
|
|
||||||
import { GBService, GBServiceCallback, IGBConversationalService} from "botlib";
|
import { GBService, GBServiceCallback, IGBConversationalService } from "botlib";
|
||||||
import { GBError } from "botlib";
|
import { GBError } from "botlib";
|
||||||
import { GBERROR_TYPE } from "botlib";
|
import { GBERROR_TYPE } from "botlib";
|
||||||
import { GBMinInstance } from "botlib";
|
import { GBMinInstance } from "botlib";
|
||||||
|
|
||||||
|
|
||||||
export class GBConversationalService implements IGBConversationalService{
|
export class GBConversationalService implements IGBConversationalService {
|
||||||
|
|
||||||
coreService: GBCoreService;
|
coreService: GBCoreService;
|
||||||
|
|
||||||
|
@ -91,10 +91,10 @@ export class GBConversationalService implements IGBConversationalService{
|
||||||
// PACKAGE: Send to packages.
|
// PACKAGE: Send to packages.
|
||||||
|
|
||||||
if (intent === "Student.CheckAttendance") {
|
if (intent === "Student.CheckAttendance") {
|
||||||
session.replaceDialog("/belagua-check-attendance", {entities: entities});
|
session.replaceDialog("/belagua-check-attendance", { entities: entities });
|
||||||
}
|
}
|
||||||
else if(intent === 'User.Authenticate'){
|
else if (intent === 'User.Authenticate') {
|
||||||
session.replaceDialog("/belagua-user-login", {entities: entities});
|
session.replaceDialog("/belagua-user-login", { entities: entities });
|
||||||
}
|
}
|
||||||
else if (intent === "PerguntarSobreTermo") {
|
else if (intent === "PerguntarSobreTermo") {
|
||||||
session.send(
|
session.send(
|
||||||
|
@ -104,6 +104,8 @@ export class GBConversationalService implements IGBConversationalService{
|
||||||
} else if (intent === "ShowSubjectMenu") {
|
} else if (intent === "ShowSubjectMenu") {
|
||||||
session.replaceDialog("/menu");
|
session.replaceDialog("/menu");
|
||||||
} else {
|
} else {
|
||||||
|
// TODO testar diálogos v2
|
||||||
|
// inclui diálogo
|
||||||
session.sendTyping();
|
session.sendTyping();
|
||||||
session.send("Desculpe-me, não encontrei nada a respeito...");
|
session.send("Desculpe-me, não encontrei nada a respeito...");
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ export class GBWhatsappPackage implements IGBPackage {
|
||||||
|
|
||||||
loadBot(min: GBMinInstance): void {
|
loadBot(min: GBMinInstance): void {
|
||||||
this.channel = new WhatsappDirectLine(min.botId, min.instance.whatsappBotKey, min.instance.whatsappServiceKey,
|
this.channel = new WhatsappDirectLine(min.botId, min.instance.whatsappBotKey, min.instance.whatsappServiceKey,
|
||||||
min.instance.whatsappServiceNumber, min.instance.whatsappServiceUrl);
|
min.instance.whatsappServiceNumber, min.instance.whatsappServiceUrl, min.instance.whatsappServiceWebhookUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadBot(min: GBMinInstance): void {
|
unloadBot(min: GBMinInstance): void {
|
||||||
|
|
|
@ -54,12 +54,13 @@ export class WhatsappDirectLine extends GBService {
|
||||||
whatsappServiceKey: string;
|
whatsappServiceKey: string;
|
||||||
whatsappServiceNumber: string;
|
whatsappServiceNumber: string;
|
||||||
whatsappServiceUrl: string;
|
whatsappServiceUrl: string;
|
||||||
|
whatsappServiceWebhookUrl: string;
|
||||||
botId: string;
|
botId: string;
|
||||||
watermark: string = null;
|
watermark: string = null;
|
||||||
|
|
||||||
conversationIds = {};
|
conversationIds = {};
|
||||||
|
|
||||||
constructor(botId, directLineSecret, whatsappServiceKey, whatsappServiceNumber, whatsappServiceUrl) {
|
constructor(botId, directLineSecret, whatsappServiceKey, whatsappServiceNumber, whatsappServiceUrl, whatsappServiceWebhookUrl) {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -67,6 +68,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
this.whatsappServiceKey = whatsappServiceKey;
|
this.whatsappServiceKey = whatsappServiceKey;
|
||||||
this.whatsappServiceNumber = whatsappServiceNumber;
|
this.whatsappServiceNumber = whatsappServiceNumber;
|
||||||
this.whatsappServiceUrl = whatsappServiceUrl;
|
this.whatsappServiceUrl = whatsappServiceUrl;
|
||||||
|
this.whatsappServiceWebhookUrl = whatsappServiceWebhookUrl;
|
||||||
|
|
||||||
// TODO: Migrate to Swagger 3.
|
// TODO: Migrate to Swagger 3.
|
||||||
this.directLineClient = rp(this.directLineSpecUrl)
|
this.directLineClient = rp(this.directLineSpecUrl)
|
||||||
|
@ -81,15 +83,13 @@ export class WhatsappDirectLine extends GBService {
|
||||||
new Swagger.ApiKeyAuthorization('Authorization', 'Bearer ' +
|
new Swagger.ApiKeyAuthorization('Authorization', 'Bearer ' +
|
||||||
directLineSecret, 'header'));
|
directLineSecret, 'header'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: UrlJoin(this.whatsappServiceUrl, "webhook"),
|
url: UrlJoin(this.whatsappServiceUrl, "webhook"),
|
||||||
qs:
|
qs:
|
||||||
{
|
{
|
||||||
token: this.whatsappServiceKey,
|
token: this.whatsappServiceKey,
|
||||||
webhookUrl: `https://a2fc0900.ngrok.io/instances/${this.botId}/whatsapp`
|
webhookUrl: `${this.whatsappServiceWebhookUrl}/instances/${this.botId}/whatsapp`
|
||||||
},
|
},
|
||||||
headers:
|
headers:
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue