From 29a1d99d05edc6f86dad672edafdb1d42e26bd3b Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Sun, 6 Oct 2024 20:05:14 -0300 Subject: [PATCH] fix: Fixed prefilledVariables in startTypebot --- CHANGELOG.md | 6 ++++++ .../chatbot/typebot/controllers/typebot.controller.ts | 11 +++-------- .../chatbot/typebot/services/typebot.service.ts | 3 +++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b780e70..5976b8f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 2.1.3 (develop) + +### Fixed + +* Fixed prefilledVariables in startTypebot + # 2.1.2 (2024-10-06 10:09) ### Features diff --git a/src/api/integrations/chatbot/typebot/controllers/typebot.controller.ts b/src/api/integrations/chatbot/typebot/controllers/typebot.controller.ts index 1f03197f..e0818a68 100644 --- a/src/api/integrations/chatbot/typebot/controllers/typebot.controller.ts +++ b/src/api/integrations/chatbot/typebot/controllers/typebot.controller.ts @@ -5,7 +5,7 @@ import { TypebotService } from '@api/integrations/chatbot/typebot/services/typeb import { PrismaRepository } from '@api/repository/repository.service'; import { WAMonitoringService } from '@api/services/monitor.service'; import { Events } from '@api/types/wa.types'; -import { Auth, configService, HttpServer, Typebot } from '@config/env.config'; +import { configService, Typebot } from '@config/env.config'; import { Logger } from '@config/logger.config'; import { BadRequestException } from '@exceptions'; import { Typebot as TypebotModel } from '@prisma/client'; @@ -609,13 +609,7 @@ export class TypebotController extends ChatbotController implements ChatbotContr } } - const prefilledVariables = { - remoteJid: remoteJid, - instanceName: instance.instanceName, - serverUrl: configService.get('SERVER').URL, - apiKey: configService.get('AUTHENTICATION').API_KEY.KEY, - ownerJid: instanceData.number, - }; + const prefilledVariables: any = {}; if (variables?.length) { variables.forEach((variable: { name: string | number; value: string }) => { @@ -674,6 +668,7 @@ export class TypebotController extends ChatbotController implements ChatbotContr stopBotFromMe, keepOpen, 'init', + prefilledVariables, ); // const response = await this.typebotService.createNewSession(instanceData, { diff --git a/src/api/integrations/chatbot/typebot/services/typebot.service.ts b/src/api/integrations/chatbot/typebot/services/typebot.service.ts index b6de1b8d..2f30e091 100644 --- a/src/api/integrations/chatbot/typebot/services/typebot.service.ts +++ b/src/api/integrations/chatbot/typebot/services/typebot.service.ts @@ -356,6 +356,7 @@ export class TypebotService { stopBotFromMe: boolean, keepOpen: boolean, content: string, + prefilledVariables?: any, ) { if (session && expire && expire > 0) { const now = Date.now(); @@ -397,6 +398,7 @@ export class TypebotService { remoteJid: remoteJid, pushName: msg.pushName, botId: findTypebot.id, + prefilledVariables: prefilledVariables, }); if (data.session) { @@ -524,6 +526,7 @@ export class TypebotService { remoteJid: remoteJid, pushName: msg?.pushName, botId: findTypebot.id, + prefilledVariables: prefilledVariables, }); if (data?.session) {