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 publicTypebot = const publicTypebotWithMatchedCondition = botsWithWhatsAppEnabled.find(
botsWithWhatsAppEnabled.find(
(publicTypebot) => (publicTypebot) =>
publicTypebot.settings.whatsApp?.startCondition && publicTypebot.settings.whatsApp?.startCondition &&
messageMatchStartCondition( messageMatchStartCondition(
incomingMessage ?? '', incomingMessage ?? '',
publicTypebot.settings.whatsApp?.startCondition publicTypebot.settings.whatsApp?.startCondition
) )
) ?? botsWithWhatsAppEnabled[0] )
const publicTypebot =
publicTypebotWithMatchedCondition ??
botsWithWhatsAppEnabled.find(
(publicTypebot) => !publicTypebot.settings.whatsApp?.startCondition
)
if (isNotDefined(publicTypebot)) return if (isNotDefined(publicTypebot)) return