https://discord.gg/botpress logo
How can I automatically detect if WhatsApp message...
# 🤝help
f
Hi everyone, I have a **lead qualification chatbot that contacts new leads via WhatsApp. **Recently, I discovered that for around two months, WhatsApp messages were not being sent because of a payment issue in the WhatsApp Business account (an expired card), leading to many lost leads. I understand that managing the WhatsApp Business account and payment details is my responsibility and a whole other issue, but I wish there was a way in Botpress to automatically detect if WhatsApp messages were failing. I have already implemented an external API that validates WhatsApp numbers before sending messages, so I can confirm whether a phone number is connected to WhatsApp. However, I have not found a way to automatically verify whether the message was actually sent and delivered successfully. I know that the logs show this information, but I am looking for a more automated solution, for example: * A way for Botpress to trigger an event when a WhatsApp message fails to send * A delivery status callback/webhook integration * A built-in monitoring mechanism for WhatsApp channel issues (such as expired payment methods or disconnected accounts) Is there currently a way to automatically check whether WhatsApp messages were sent and delivered, rather than manually reviewing logs? Thanks! PS: Here's the error-message I was getting in the logs:
[whatsapp] WhatsApp message delivery failed. Message ID: ###, Recipient: ###, Errors: Business eligibility payment issue: Business eligibility payment issue - Message failed to send because your WhatsApp Business account has unsettled payments. Visit https://business.facebook.com/... to resolve this issue.
l
you can use a hook to read before incoming to read the incoming message and identify if there are payment related errors then trigger and email - I haven't tested this myself but i am sure this can be done
f
Thank you for the hint. I am, however, not sure if the hook "before incoming" is catching error messages in the logs. It appears that it only catches events originating from a user. https://botpress.com/docs/studio/concepts/hooks
l
This Hook type executes its code before your bot processes an incoming event
f
I just tested it by creating a new "before incoming" hook and logging every event to the console. I found that it did trigger for webhook events that are configured in the workflow, but it did not catch 2 WhatsApp error messages that occurred during this test and are otherwise visible in the logs. So, it appears that using a "before incoming" hook will not be possible for this problem.
I have found the solution! Apparently, Botpress has added some new capabilities/trigger-cards to the WhatsApp integration recently. I've discovered them after updating the integration and tested the trigger card "Message Failed", which successfully triggered when WhatsApp returned an error. I can now use this to build a custom error handling for such cases. Thank you @limited-pencil-78283 for your help and @cold-motherboard-82208 for the update. https://cdn.discordapp.com/attachments/1519263704166830141/1519282015243993098/image.png?ex=6a3cfd23&is=6a3baba3&hm=f48a446d10be1c278af5cbe0c16577045742abde1751fdccac65c3542704e781&
5 Views