mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
fix: Correction in start typebot, create it if not exists
- Corrected an issue where the start typebot function would throw an error if the typebot was not found. - Added a condition to create a new typebot if it doesn't exist. - Updated CHANGELOG.md with the details of the changes. Files affected: - CHANGELOG.md - src/api/integrations/typebot/services/typebot.service.ts
This commit is contained in:
parent
9aa2b1b3bf
commit
aa2da01401
@ -6,6 +6,8 @@
|
||||
* Resolve not find name
|
||||
* Removed DEL_TEMP_INSTANCES as it is not being used
|
||||
* Fixed global exchange name
|
||||
* Add apiKey and serverUrl to prefilledVariables in typebot service
|
||||
* Correction in start typebot, if it doesn't exist, create it
|
||||
|
||||
# 2.0.1-beta (2024-07-17 17:01)
|
||||
|
||||
|
@ -4,7 +4,6 @@ import axios from 'axios';
|
||||
import { Auth, ConfigService, HttpServer, S3, Typebot } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { sendTelemetry } from '../../../../utils/sendTelemetry';
|
||||
import { ServerUP } from '../../../../utils/server-up';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { PrismaRepository } from '../../../repository/repository.service';
|
||||
import { WAMonitoringService } from '../../../services/monitor.service';
|
||||
@ -667,17 +666,6 @@ export class TypebotService {
|
||||
}
|
||||
}
|
||||
|
||||
const findTypebot = await this.prismaRepository.typebot.findFirst({
|
||||
where: {
|
||||
url: url,
|
||||
typebot: typebot,
|
||||
},
|
||||
});
|
||||
|
||||
if (!findTypebot) {
|
||||
throw new Error('Typebot not found');
|
||||
}
|
||||
|
||||
if (
|
||||
!expire ||
|
||||
!keywordFinish ||
|
||||
@ -722,6 +710,31 @@ export class TypebotService {
|
||||
}
|
||||
|
||||
if (startSession) {
|
||||
let findTypebot: any = await this.prismaRepository.typebot.findFirst({
|
||||
where: {
|
||||
url: url,
|
||||
typebot: typebot,
|
||||
},
|
||||
});
|
||||
|
||||
if (!findTypebot) {
|
||||
findTypebot = await this.prismaRepository.typebot.create({
|
||||
data: {
|
||||
enabled: true,
|
||||
url: url,
|
||||
typebot: typebot,
|
||||
expire: expire,
|
||||
keywordFinish: keywordFinish,
|
||||
delayMessage: delayMessage,
|
||||
unknownMessage: unknownMessage,
|
||||
listeningFromMe: listeningFromMe,
|
||||
stopBotFromMe: stopBotFromMe,
|
||||
keepOpen: keepOpen,
|
||||
instanceId: instance.instanceId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
await this.prismaRepository.typebotSession.deleteMany({
|
||||
where: {
|
||||
remoteJid: remoteJid,
|
||||
|
Loading…
Reference in New Issue
Block a user