Twilio whatsapp location

268 Views Asked by At

Please let me know how to send and recive the location through twilio and python. like longitude and latitude and I need users to be able to share their current location with the bot.

1

There are 1 best solutions below

0
On

go to the site package & search for 'C:\Users\yuvraj.yamgar\anaconda3\envs\new_project\Lib\site-packages\rasa\core\channels\twilio.py' for this path open that twilio.py

  @twilio_webhook.route("/webhook", methods=["POST"])
    async def message(request: Request) -> HTTPResponse:
        sender = request.form.get("From", None)
        text = request.form.get("Body", None)

        lat = request.form.get("Latitude",None)
        long = request.form.get("Longitude",None)
        city =  request.form.get("city",None)
        metadata = self.get_metadata(request)
        
        if lat is not None and long is not None:
        
            if text is None:
                text = '/locationdata'
            if metadata is None:
                metadata ={'LocationData':{'lat':lat,'long':long,'state':city}}
                print(type(metadata),'printing type of')
                string = str(metadata)
                print(string,"location")
                text = string
                print(lat,long,city)
            else:
                metadata =[self.get_metadata(request),{'LocationData':{'lat':lat,'long':long,'state':city}}]

use this code you will get lat & long