2
0

🚑 (whatsapp) Fix start whatsapp session when user has multiple whatsapp enabled

This commit is contained in:
Baptiste Arnaud
2023-10-03 10:13:25 +02:00
parent 317a15b708
commit 60c06aa9a9

View File

@@ -59,15 +59,20 @@ export const startWhatsAppSession = async ({
publicTypebot.settings.whatsApp?.isEnabled publicTypebot.settings.whatsApp?.isEnabled
) )
const publicTypebotWithMatchedCondition = botsWithWhatsAppEnabled.find(
(publicTypebot) =>
publicTypebot.settings.whatsApp?.startCondition &&
messageMatchStartCondition(
incomingMessage ?? '',
publicTypebot.settings.whatsApp?.startCondition
)
)
const publicTypebot = const publicTypebot =
publicTypebotWithMatchedCondition ??
botsWithWhatsAppEnabled.find( botsWithWhatsAppEnabled.find(
(publicTypebot) => (publicTypebot) => !publicTypebot.settings.whatsApp?.startCondition
publicTypebot.settings.whatsApp?.startCondition && )
messageMatchStartCondition(
incomingMessage ?? '',
publicTypebot.settings.whatsApp?.startCondition
)
) ?? botsWithWhatsAppEnabled[0]
if (isNotDefined(publicTypebot)) return if (isNotDefined(publicTypebot)) return