Why is vcard not being received in replied sms when using MessagingResponse?

Viewed 222

When I use MessagingResponse.message with media_url parameter or when I append a Media instance to a pre created Message object and return as the answer to an sms in my webhook (already registered on twilio), the vcard which I'm attaching to the answer is not received by the destination.

When I use Client.create and use the media_url the vcard is received successfully.

I've tried with two different accounts and the result is the same. The problem in using Client.create approach is: it'll create a new message trip and it'll cost $0.02. If i just reply with MessagingResponse, it'll cost $0.0075.

I've found this, but I think it is not related: iOS failing to render vcf file

Any concerns about why could I solve this?

My configuration:

  • Programming language: python 2.7.12
  • Web Framework: Flask 0.12.2
  • Twilio API version: 6.3.0
  • Endpoing SO: Windows 10

Test code

from flask import Flask, request, send_from_directory
from twilio.twiml.messaging_response import MessagingResponse, Message, Media
from twilio.rest import Client

app = Flask(__name__, static_url_path="")

@app.route('/vcards/<path:path>')
def send_vcards(path):
    return send_from_directory('vcards', path)

@app.route("/", methods=['GET', 'POST'])
def hey_there():
    """Respond to incoming messages"""
    # Calls with client works fine.
    # client = Client("SID", "TOKEN")
    # client.messages.create(to=request.form["From"], from_="+TWILIO_NUMBER", body="Test with no vcard")
    resp = MessagingResponse().message(body="hey, there!", 
                                       to=request.form["From"])
    resp.append(Media("http://server:port/vcards/test.vcf"))

    return str("Ok")

if __name__ == "__main__":
    app.run(debug=True)

Update

I just found that the cost is associated with sending media, not with the reply/start of a message. If any media is sent (with media_url or media attaching), it will cost $0.02.

Solution

resp = MessagingResponse()
message = Message(to=request.form["From"])
message.body("hey, there!")
message.media("server:port/vcards/test.vcf")
resp.append(message)

The solution was given by twilio support. The way it work is this link:

Twilio MMS Examples Page

0 Answers
Related