How to receive the media id from the Whatsapp Business Cloud API?
I have deployed my webhook and connected my WABA. Once I send an image to this business account. It did not return the media id from the response. Actually, the JSON returned to me like this:
{ "entry": [ { "changes": [ { "field": "messages", "value": { "contacts": [ { "profile": { "name": "XXXXXXX" } } ], "messages": [ { "from": "XXXXXXXXXX", "id": "wamid.aisjdoiajsodiajsodasd\u003d", "timestamp": "1657527108", "type": "image" } ], "metadata": {} } } ], "id": "124071984791824" } ], "object": "whatsapp_business_account" }
Or should I try the Whatsapp On-premises API? https://developers.facebook.com/docs/whatsapp/on-premises/reference/media/media-id
You have to chooose the image_id from the request you receive.
like , let media_id=req.body.entry[0].changes[0].value.messages[0].image.id;
you can store this id in DB and use the endpioint where you can get the url for media_id. Then you can download the image from the URL received and uploaded it anywhere you want.