🔊 Add debug logs
This commit is contained in:
@@ -54,16 +54,19 @@ export default async function handler(
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const ctx = globalThis[Symbol.for('@vercel/request-context')]
|
const ctx = globalThis[Symbol.for('@vercel/request-context')]
|
||||||
if (ctx?.get?.().waitUntil) {
|
if (ctx?.get?.().waitUntil) {
|
||||||
|
console.log('Using waitUntil')
|
||||||
ctx
|
ctx
|
||||||
.get()
|
.get()
|
||||||
.waitUntil(processWhatsAppReply({ entry, workspaceId, credentialsId }))
|
.waitUntil(processWhatsAppReply({ entry, workspaceId, credentialsId }))
|
||||||
return res.status(200).json({ message: 'Message is being processed.' })
|
return res.status(200).json({ message: 'Message is being processed.' })
|
||||||
}
|
}
|
||||||
|
console.log('Not using waitUntil')
|
||||||
const { message } = await processWhatsAppReply({
|
const { message } = await processWhatsAppReply({
|
||||||
entry,
|
entry,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
credentialsId,
|
credentialsId,
|
||||||
})
|
})
|
||||||
|
console.log('Message:', message)
|
||||||
return res.status(200).json({ message })
|
return res.status(200).json({ message })
|
||||||
}
|
}
|
||||||
return methodNotAllowed(res)
|
return methodNotAllowed(res)
|
||||||
@@ -83,7 +86,9 @@ const processWhatsAppReply = async ({
|
|||||||
const phoneNumberId = entry.at(0)?.changes.at(0)?.value
|
const phoneNumberId = entry.at(0)?.changes.at(0)?.value
|
||||||
.metadata.phone_number_id
|
.metadata.phone_number_id
|
||||||
if (!phoneNumberId) return { message: 'No phone number id found' }
|
if (!phoneNumberId) return { message: 'No phone number id found' }
|
||||||
return resumeWhatsAppFlow({
|
console.log('Received message:', receivedMessage)
|
||||||
|
console.log('sessionId', `wa-${phoneNumberId}-${receivedMessage.from}`)
|
||||||
|
const { message } = await resumeWhatsAppFlow({
|
||||||
receivedMessage,
|
receivedMessage,
|
||||||
sessionId: `wa-${phoneNumberId}-${receivedMessage.from}`,
|
sessionId: `wa-${phoneNumberId}-${receivedMessage.from}`,
|
||||||
phoneNumberId,
|
phoneNumberId,
|
||||||
@@ -94,4 +99,6 @@ const processWhatsAppReply = async ({
|
|||||||
phoneNumber: contactPhoneNumber,
|
phoneNumber: contactPhoneNumber,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
console.log('Message:', message)
|
||||||
|
return { message }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user