fix: Fixed prefilledVariables in startTypebot

This commit is contained in:
Davidson Gomes 2024-10-06 20:05:14 -03:00
parent ebbba7b7e9
commit 29a1d99d05
3 changed files with 12 additions and 8 deletions

View File

@ -1,3 +1,9 @@
# 2.1.3 (develop)
### Fixed
* Fixed prefilledVariables in startTypebot
# 2.1.2 (2024-10-06 10:09)
### Features

View File

@ -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<HttpServer>('SERVER').URL,
apiKey: configService.get<Auth>('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, {

View File

@ -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) {