twilio / twilio-node

Node.js helper library
MIT License
1.39k stars 507 forks source link

Media of SMS returned from media resource is an empty array even if numMedia is > 0 #636

Closed haseebanwar closed 3 years ago

haseebanwar commented 3 years ago

This issue is similar to https://github.com/twilio/twilio-node/issues/68. Opening it because it was closed without providing any clear solution.

Issue Summary

I am having a little issue in fetching media associated with an SMS right away when it is sent or when an incoming MMS hits our Twilio number. I know that media doesn't get attached instantaneously to the SMS and it takes some seconds.

I have a chat application in which I've to show outgoing and incoming MMS in real-time. Suppose, someone sends an MMS to my Twilio number, I catch it from the webhook and then I try to fetch the media associated with it. The media then returned from client.messages(sid).media.list() is an empty array. One way around it is to use setTimeout (to wait for some seconds until the media is available via the API) and then emit the socket event to the chat application, which is not a very good approach.

So my question is there any other good approach available for achieving the same without a timeout. Does Twilio has a webhook that notifies if the media is ready to be fetched via the API. Or any other good approach?

thinkingserious commented 3 years ago

Hello @haseebanwar,

Would this webhook be helpful for your use case?

With best regards,

Elmer