skip to Main Content

Hi I am trying to send an image with Whatsapp api, I did my template like this one:

Hola *{{1}}* πŸ¦Έβ€β™€οΈπŸ¦Έβ€β™‚οΈ

Hemos cargado una nueva noticia en la intranet, si quieres visualizar la misma haz click en el 
siguiente enlace: {{2}}

πŸš— *Jis Parking*

and my code is this one:

{
"to": "xxxxx",
"recipient_type": "individual",
"type": "template",
"template": {
    "namespace": "88b39973_f0d5_54e1_29cf_e80f1e3da4f2",
    "name": "noticia",
    "language": {
        "code": "es"
    },
    "components": [
        {
            "type": "body",
            "parameters": [
                {
                    "type": "text",
                    "text": "Richard"
                },
                {
                    "type": "image",
                    "image": {
                        "link": "image_url"
                    }
                }
            ] 
        }
    ]
   }
 }

I added the image_url and it’s weird because I see all good and the api displays this error:

{
  "error": {
    "message": "(#100) The parameter messaging_product is required.",
    "type": "OAuthException",
    "code": 100,
    "fbtrace_id": "AxtiGLSBvAZltlMkJAw-GIk"
  }
}

I wonder what am I doing wrong? Thanks!

2

Answers


  1. Hey did you upload the image first?

    To get an id or a link first you need to upload the media using the API which would return a media object with ID and a link.

    I use the Whatsapp Ruby SDK for connecting with the API which looks like this:

    uploaded_media = medias_api.upload(sender_id: SENDER_ID, file_path: "tmp/whatsapp.png", type: "image/png")
    media = medias_api.media(media_id: uploaded_media.data&.id).data
    
    Login or Signup to reply.
  2. First, the current error says you need to add the below parameter in your request,

    "messaging_product" : "whatsapp"
    

    Second, I notice in your request, that the image type is not supported in body type component, the body type supports these 3 types of values text, currency, date_time, for more details review the documentation,

    If you want to add an image to your message, you have to create a new template with a header type as image, for ex:

    enter image description here

    After that, you can add an image to the header component, for more details review the documentation.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search