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

@ -439,8 +439,8 @@ export class GBConversationalService {
var filetype = href.split('.').pop();
if (videos.indexOf(filetype) > -1) {
var out = '<video autoplay loop alt="' + text + '">'
+ ' <source src="' + href + '" type="video/' + filetype + '">'
+ '</video>'
+ ' <source src="' + href + '" type="video/' + filetype + '">'
+ '</video>'
return out;
} else {
return renderer.oldImage(href, title, text);
@ -466,7 +466,7 @@ export class GBConversationalService {
text = text.replace('! [', '![').replace('] (', '](');
text = text.replace(`[[embed url=`, process.env.BOT_URL + '/').replace(']]', ''); // TODO: Improve it.
text = text.replace(`](kb`, "]("+ process.env.BOT_URL + '/kb'); // TODO: Improve it.
text = text.replace(`](kb`, "](" + process.env.BOT_URL + '/kb'); // TODO: Improve it.
// According to the channel, formats the output optimized to it.
@ -951,14 +951,20 @@ 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) {
const ref = JSON.parse(user.conversationReference);
MicrosoftAppCredentials.trustServiceUrl(ref.serviceUrl);
await min.bot['createConversation'](ref, async (t1) => {
const ref2 = TurnContext.getConversationReference(t1.activity);
await min.bot.continueConversation(ref2, async (t2) => {
await t2.sendActivity(message);
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) => {
const ref2 = TurnContext.getConversationReference(t1.activity);
await min.bot.continueConversation(ref2, async (t2) => {
await t2.sendActivity(message);
});
});
});
}
}
public static kmpSearch(pattern, text) {

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
);