I'm using Programmable chat. I'm trying to show ReadAt meta data to users. I know when the user is getting the message on the frontend since I'm listening to messageAdded on the current Channel in the Twilio Javascript SDK. I'm storing the message by listening to Webhook on the preMessageSend to make sure that the message is saved in DB. When I get this message, the problem is I'm not getting the messageId which I'm getting on the Javascript SDK message. Can someone help me in understanding how to correlate both the messages?
Asked
Active
Viewed 107 times
1 Answers
1
According to the Twilio developer docs:
Pre-Event Webhooks will fire before an action has been committed to the Chat instance, blocking publication until a response is received. This gives your backend (or Function) the opportunity to intercept, modify, or reject any action across the instance, making these hooks useful for spam/language filtering, complex permission schemes, or other business logic. Pre-event webhooks are fired only for actions from the Chat SDK; the REST API actions will never fire them.
So I suspect the messageId is not created until after this webhook.

Ben Hulan
- 537
- 2
- 7
-
Yup, if you are storing the message, you want to use the Post MessageSend webhook, which will include the SID. You can see the [documentation for the request bodies here](https://www.twilio.com/docs/chat/webhook-events#onmessagesent). – philnash May 31 '19 at 01:25