fix(whatsapp.gblib): Adding Google to WhatsApp.

This commit is contained in:
Rodrigo Rodriguez 2021-06-16 11:53:20 -03:00
parent cdd1a9968c
commit dc9286ffe8
4 changed files with 20 additions and 17 deletions

View file

@ -7,7 +7,6 @@ var pjson = require('./package.json');
// Displays version of Node JS being used at runtime and others attributes.
console.log(`[GB Runtime] BotServer = v${pjson.version}`);
console.log(`[GB Runtime] BotLib = v${pjson.dependencies.botlib}`);
console.log(`[GB Runtime] BotBuilder (MS) = v${pjson.dependencies.botbuilder}`);

View file

@ -951,6 +951,11 @@ export class GBConversationalService {
* Sends a message in a user with an already started conversation (got ConversationReference set)
*/
public async sendOnConversation(min: GBMinInstance, user: GuaribasUser, message: string) {
if (user.conversationReference.startsWith('spaces')) {
await min['googleDirectLine'].sendToDevice(user.userSystemId, null, user.conversationReference, message);
}
else {
const ref = JSON.parse(user.conversationReference);
MicrosoftAppCredentials.trustServiceUrl(ref.serviceUrl);
await min.bot['createConversation'](ref, async (t1) => {
@ -960,6 +965,7 @@ export class GBConversationalService {
});
});
}
}
public static kmpSearch(pattern, text) {
pattern = pattern.toLowerCase();

View file

@ -92,7 +92,7 @@ export class FeedbackDialog extends IGBDialog {
user.systemUser = await sec.getUserFromAgentSystemId(agentSystemId);
await min.userProfile.set(step.context, user);
if (agentSystemId.charAt(2) === ":") { // Agent is from Teams.
if (agentSystemId.charAt(2) === ":" || agentSystemId.indexOf("@") > -1) { // Agent is from Teams or Google Chat.
const agent = await sec.getUserFromSystemId(agentSystemId);
await min.conversationalService['sendOnConversation'](min, agent,
Messages[locale].notify_agent(step.context.activity.from.name));

View file

@ -276,7 +276,7 @@ export class WhatsappDirectLine extends GBService {
} else {
GBLog.info(`USER (${id}) TO AGENT ${agent.userSystemId}: ${text}`);
if (user.agentSystemId.charAt(2) === ":") { // Agent is from Teams.
if (user.agentSystemId.charAt(2) === ":" || agent.userSystemId.indexOf("@") > -1) { // Agent is from Teams or Google Chat.
await this.min.conversationalService['sendOnConversation'](this.min, agent, text);
}
else {
@ -487,10 +487,8 @@ export class WhatsappDirectLine extends GBService {
}
public async sendToDeviceEx(to, text, locale) {
const minBoot = GBServer.globals.minBoot as any;
text = await minBoot.conversationalService.translate(
minBoot,
text = await this.min.conversationalService.translate(
this.min,
text,
locale
);