Skip to main content

How do I send a template message using the API?

Comments

13 comments

  • Hafizh Fauzan

    Hi, when i tried the CURL, it says "Mapped Bot Not Found", is there any solution with this? Thanks

    3
  • María Citlali Hernández Escareño

    Hi

    when I try to use the new template messaging API I am getting the next error: 
    payload: {
        code: 1008,
        reason: "Required parameter is missing:Missing mandatory parameter 'to'"
      }
    But I can't find nothing related to "to" parameter in https://www.gupshup.io/developer/docs/bot-platform/guide/whatsapp-api-documentation#templateAPIEndpoint

    Thanks and I appreciate any help.

     

    2
  • Kauntal Patel

    Hi Juan,

    We have updated the CURL given in this FAQ.

    For your direct answer, here is the payload:

    {"type":"document","document":{"link":"https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf","filename": "Sample funtional resume"}}
    1
  • Juan Souteras

    How can I specify the name of the document in a template message?

    1
  • Carlos

    in reply to @María Citlali Hernández Escareño and @varshitha s

    I get this error when I try to send templates from sandbox.

    payload: {
        code: 1008,
      reason: "Required parameter is missing:Missing mandatory parameter 'to'"
    }

     But it does not appear when the application is live.

    I guess the templates can't be used from sandbox.

    1
  • Luis Ernesto Mendoza Sánchez

    2023 and the error:
    Required parameter is missing:Missing mandatory parameter 'to'...

    persist

     

    1
  • Satya B

    Is it solved Hafizh Fauzan?

    0
  • Juan Souteras

    Great! I will try it.

    Thanks!

    0
  • Almashines India

    In reply to @Hafizh Fauzan,

    In case of error message "Mapped Bot Not Found", try adding src.name param in curl request.

    0
  • Andrey Pysin - AiApps.Pro

    Hi,

    The problem was solved by converting list to json:

    Python example:

    import requests
    import json
    url = 'https://api.gupshup.io/sm/api/v1/template/msg'
    headers = {'apikey': 'XXXXX', 'Content-Type': 'application/x-www-form-urlencoded'}
    template = {'id': 'XXXXX', 'params': ['var1', 'var2']}
    template_json_object = json.dumps(template)
    data = {'source': 'XXXXX', 'destination': 'XXXXX', 'template': template_json_object}
    requests.post(url, data=data, headers=headers)
    CURL example:
    curl --location --request POST 'http://api.gupshup.io/sm/api/v1/template/msg' \
    --header 'apikey: XXXXX' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data-urlencode 'source=XXXXX' \
    --data-urlencode 'destination=XXXXX' \
    --data-urlencode 'template={"id": "XXXXX", "params": ["var1","var2"]}'
    --
    Best regards, Andrey
    AiApps.Pro
    0
  • varshitha s

    @María Citlali Hernández Escareño
    Did u solve ua issue ?
    if yes can u please tell, i'am dealing with similar issue

    0
  • Kamaljeet Sahoo

    @Almashines India
    I ran to a similar problem where I was not able to send the template message through the API 
    Adding src.name resulted in successful response but not able to see the message coming on whatsapp 
    What wrong could I be doing ?
    Attached an image below for reference 

    0
  • Amrita Bhatia

    @Kamaljeet Sahoo try enabling template messaging in Dashboard > App > Settings if you haven't already.

    0

Please sign in to leave a comment.