2
0

🐛 (whatsapp) Fix webhook when having 2 phone numbers in same WA account

This commit is contained in:
Baptiste Arnaud
2024-02-26 13:54:41 +01:00
parent fe98f2a9b6
commit ce17ce5061
2 changed files with 10 additions and 0 deletions

View File

@ -18,6 +18,7 @@ type Props = {
receivedMessage: WhatsAppIncomingMessage
sessionId: string
credentialsId?: string
phoneNumberId?: string
workspaceId?: string
contact: NonNullable<SessionState['whatsApp']>['contact']
}
@ -27,6 +28,7 @@ export const resumeWhatsAppFlow = async ({
sessionId,
workspaceId,
credentialsId,
phoneNumberId,
contact,
}: Props): Promise<{ message: string }> => {
const messageSendDate = new Date(Number(receivedMessage.timestamp) * 1000)
@ -54,6 +56,13 @@ export const resumeWhatsAppFlow = async ({
}
}
if (credentials.phoneNumberId !== phoneNumberId) {
console.error('Credentials point to another phone ID, skipping...')
return {
message: 'Message received',
}
}
const reply = await getIncomingMessageContent({
message: receivedMessage,
typebotId: typebot?.id,