简体   繁体   中英

How to send the location object on whatsapp using twilio?

can I send a location using MessagingResponse?

when i try the below approach i get AttributeError: 'Message' object has no attribute 'persistent_action'

from flask import Flask, request
import requests
from twilio.twiml.messaging_response import MessagingResponse

app = Flask(__name__)
@app.route('/bot', methods=['POST'])
def bot():
    resp = MessagingResponse()
    msg = resp.message()
    if request.values.get('Latitude'):
        lat = request.values.get('Latitude')
        long = request.values.get('Longitude')
        location = 'geo:'+lat+','+long
        loc = [location]
        msg.persistent_action(loc)
        return str(resp)
if __name__ == '__main__':
app.run()

It appears based on the documentation, that the only way to send location via WhatsApp, at least currently, is via the REST API.

Location Messages with WhatsApp

  • See code example: "Send a WhatsApp message with location information"

How To Send Location Details on WhatsApp in Node JS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM