🚑 (whatsapp) Fix start whatsapp session when user has multiple whatsapp enabled
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user