diff --git a/CHANGELOG.md b/CHANGELOG.md index bd553925..16afcd1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Read messages from whatsapp in chatwoot * Add support to use use redis in cacheservice * Add support for labels +* Command to clearcache from chatwoot inbox ### Fixed @@ -32,6 +33,11 @@ * Fix looping when deleting a message in chatwoot * When receiving a file from whatsapp, use the original filename in chatwoot if possible * Correction in the sendList Function +* Implement contact upsert in messaging-history.set +* Improve proxy error handling +* Refactor fetching participants for group in WhatsApp service +* Fixed problem where the typebot final keyword did not work +* Typebot's wait now pauses the flow and composing is defined by the delay_message parameter in set typebot # 1.6.1 (2023-12-22 11:43) diff --git a/src/whatsapp/services/typebot.service.ts b/src/whatsapp/services/typebot.service.ts index f91bcc81..9a9a54bf 100644 --- a/src/whatsapp/services/typebot.service.ts +++ b/src/whatsapp/services/typebot.service.ts @@ -450,8 +450,6 @@ export class TypebotService { async function processMessages(instance, messages, input, clientSideActions, eventEmitter, applyFormatting) { for (const message of messages) { - const wait = findItemAndGetSecondsToWait(clientSideActions, message.id); - if (message.type === 'text') { let formattedText = ''; @@ -467,7 +465,7 @@ export class TypebotService { await instance.textMessage({ number: remoteJid.split('@')[0], options: { - delay: wait ? wait * 1000 : instance.localTypebot.delay_message || 1000, + delay: instance.localTypebot.delay_message || 1000, presence: 'composing', }, textMessage: { @@ -480,7 +478,7 @@ export class TypebotService { await instance.mediaMessage({ number: remoteJid.split('@')[0], options: { - delay: wait ? wait * 1000 : instance.localTypebot.delay_message || 1000, + delay: instance.localTypebot.delay_message || 1000, presence: 'composing', }, mediaMessage: { @@ -494,7 +492,7 @@ export class TypebotService { await instance.mediaMessage({ number: remoteJid.split('@')[0], options: { - delay: wait ? wait * 1000 : instance.localTypebot.delay_message || 1000, + delay: instance.localTypebot.delay_message || 1000, presence: 'composing', }, mediaMessage: { @@ -508,7 +506,7 @@ export class TypebotService { await instance.audioWhatsapp({ number: remoteJid.split('@')[0], options: { - delay: wait ? wait * 1000 : instance.localTypebot.delay_message || 1000, + delay: instance.localTypebot.delay_message || 1000, presence: 'recording', encoding: true, }, @@ -517,6 +515,13 @@ export class TypebotService { }, }); } + + const wait = findItemAndGetSecondsToWait(clientSideActions, message.id); + + console.log('wait', wait); + if (wait) { + await new Promise((resolve) => setTimeout(resolve, wait * 1000)); + } } if (input) { @@ -534,7 +539,7 @@ export class TypebotService { await instance.textMessage({ number: remoteJid.split('@')[0], options: { - delay: 1200, + delay: instance.localTypebot.delay_message || 1000, presence: 'composing', }, textMessage: {