Cauthon
Cauthon

Reputation: 520

Send WhatsApp Template message with Twilio

In their docs, Twilio say that all I need to do in order to send a WhatsApp template message is to simply send the message, and they will recognize that it's a saved template message and use it:

To send a templated message, include the full body of the message in the API call. Twilio will send the message as a templated message if it matches one of the approved templates.

However, the example they give is by using their Client object (see the example here).

I don't use that object, in my WhatsApp bot I use MessageResponse like this:

def bot():
    ...
    resp = MessagingResponse()
    msg = resp.message()
    msg.body(some_text)
    return str(resp)

I tried changing some_text to the text that appears in my template message, but this doesn't work. Any ideas?

Upvotes: 0

Views: 1386

Answers (1)

philnash
philnash

Reputation: 73100

Twilio developer evangelist here.

When you are sending a message using TwiML in response to an incoming message you don’t need to use a template. As the message is in response to another message you are in the 24 hour conversation window and you can send any message.

Upvotes: 1

Related Questions