mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
fix: now in typebot we wait until the terminal block to accept the user's message, if it arrives before the block is sent, it is ignored
This commit is contained in:
parent
ff31ef912e
commit
56df0caab0
@ -10,6 +10,7 @@
|
||||
* Removed excessive verbose logs
|
||||
* Optimization in instance registration
|
||||
* Correction of variables breaking lines in typebot
|
||||
* Now in typebot we wait until the terminal block to accept the user's message, if it arrives before the block is sent, it is ignored
|
||||
|
||||
### Break changes
|
||||
* jwt authentication removed
|
||||
|
@ -9,7 +9,9 @@
|
||||
"start:prod": "bash start.sh",
|
||||
"dev:server": "clear && tsnd --files --transpile-only --respawn --ignore-watch node_modules ./src/main.ts",
|
||||
"test": "clear && tsnd --files --transpile-only --respawn --ignore-watch node_modules ./test/all.test.ts",
|
||||
"lint": "eslint --fix --ext .ts src"
|
||||
"lint": "eslint --fix --ext .ts src",
|
||||
"db:migrate:postgres": "npx prisma migrate dev --name init --schema ./prisma/postgresql-schema.prisma",
|
||||
"db:migrate:mysql": "npx prisma migrate dev --name init --schema ./prisma/mysql-schema.prisma"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -70,13 +70,13 @@ model Session {
|
||||
}
|
||||
|
||||
model Chat {
|
||||
id Int @id @default(autoincrement())
|
||||
remoteJid String @db.VarChar(100)
|
||||
labels Json? @db.JsonB
|
||||
createdAt DateTime? @default(now()) @db.Timestamp
|
||||
updatedAt DateTime? @updatedAt @db.Timestamp
|
||||
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||
instanceId String
|
||||
id Int @id @default(autoincrement())
|
||||
remoteJid String @db.VarChar(100)
|
||||
labels Json? @db.JsonB
|
||||
createdAt DateTime? @default(now()) @db.Timestamp
|
||||
updatedAt DateTime? @updatedAt @db.Timestamp
|
||||
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||
instanceId String
|
||||
}
|
||||
|
||||
model Contact {
|
||||
@ -256,6 +256,7 @@ model TypebotSession {
|
||||
sessionId String @db.VarChar(100)
|
||||
status String @db.VarChar(100)
|
||||
prefilledVariables Json? @db.JsonB
|
||||
awaitUser Boolean @default(false) @db.Boolean
|
||||
createdAt DateTime? @default(now()) @db.Timestamp
|
||||
updatedAt DateTime @updatedAt @db.Timestamp
|
||||
Typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
|
||||
|
@ -309,6 +309,7 @@ export class TypebotService {
|
||||
pushName: data.pushName || '',
|
||||
instanceName: instance.instanceName,
|
||||
},
|
||||
awaitUser: false,
|
||||
typebotId: data.typebotId,
|
||||
instanceId: instance.instanceId,
|
||||
},
|
||||
@ -337,6 +338,7 @@ export class TypebotService {
|
||||
clientSideActions,
|
||||
this.eventEmitter,
|
||||
applyFormatting,
|
||||
this.prismaRepository,
|
||||
).catch((err) => {
|
||||
console.error('Erro ao processar mensagens:', err);
|
||||
});
|
||||
@ -420,10 +422,10 @@ export class TypebotService {
|
||||
clientSideActions,
|
||||
eventEmitter,
|
||||
applyFormatting,
|
||||
prismaRepository,
|
||||
) {
|
||||
for (const message of messages) {
|
||||
if (message.type === 'text') {
|
||||
console.log('message.content.richText', message.content.richText);
|
||||
let formattedText = '';
|
||||
|
||||
for (const richText of message.content.richText) {
|
||||
@ -471,7 +473,6 @@ export class TypebotService {
|
||||
});
|
||||
}
|
||||
|
||||
console.log(clientSideActions);
|
||||
const wait = findItemAndGetSecondsToWait(clientSideActions, message.id);
|
||||
|
||||
if (wait) {
|
||||
@ -497,6 +498,15 @@ export class TypebotService {
|
||||
text: formattedText,
|
||||
});
|
||||
}
|
||||
|
||||
await prismaRepository.typebotSession.update({
|
||||
where: {
|
||||
id: session.id,
|
||||
},
|
||||
data: {
|
||||
awaitUser: true,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
eventEmitter.emit('typebot:end', {
|
||||
sessionId: session.id,
|
||||
@ -522,6 +532,8 @@ export class TypebotService {
|
||||
},
|
||||
});
|
||||
|
||||
if (session && !session.awaitUser) return;
|
||||
|
||||
try {
|
||||
if (session && expire && expire > 0) {
|
||||
const now = Date.now();
|
||||
@ -712,13 +724,12 @@ export class TypebotService {
|
||||
},
|
||||
data: {
|
||||
status: 'opened',
|
||||
awaitUser: false,
|
||||
},
|
||||
});
|
||||
|
||||
const content = this.getConversationMessage(msg.message);
|
||||
|
||||
console.log('content', content);
|
||||
|
||||
if (!content) {
|
||||
if (unknownMessage) {
|
||||
this.waMonitor.waInstances[instance.instanceName].textMessage({
|
||||
@ -755,11 +766,8 @@ export class TypebotService {
|
||||
sessionId: session.sessionId.split('-')[1],
|
||||
};
|
||||
}
|
||||
console.log('reqData', reqData);
|
||||
const request = await axios.post(urlTypebot, reqData);
|
||||
|
||||
console.log('request', request.data);
|
||||
|
||||
await this.sendWAMessage(
|
||||
instance,
|
||||
session,
|
||||
|
Loading…
Reference in New Issue
Block a user