Writing Twiml based on user messages - python

First post on here. Im working on an application in python using the twilio voice api. Id need to be able to create twiml xml data based on user messages. Hence twiml creation and hosting programmatically on the fly. Is there anyone here that can point me in the right direction. For all i know twilml bin doesnt allow that. Thank you

Twilio developer evangelist here.
You are right that TwiML Bins don't allow to generate dynamic responses (outside of some light templating). However, you are building with Python, so you can build a web application that responds to Twilio webhooks with dynamically generated TwiML.
I'd recommend working through this tutorial on receiving and responding to incoming SMS messages in Python to understand how the process works and how to use the Twilio Python library to generate dynamic TwiML.

Related

Dialogflow - sending media from python flask app to twilio

I am trying to figure out whether it is possible to send a response back to the user from my python flask app to twilio, which is integrated with dialogflow.
Using Twilio and python only, and using messaging response I can send images back to the user.
However, once I link the integration with dialogflow, I'm not sure what to pass back to dialogflow for it to recognise the image link.
Currently I am using fulfillment text to send text from python to Twilio/dialogflow.
Please help.
Thanks for your reply. I have managed to solve this issue. For others experiencing a similar issue, using Client.messages.create function, it allows you to attach a file, using the mediaUrl parameter.

How can I check if Someone is Live on twitch with the Twitch api python

I want to have a discord bot that posts in my server when I'm live but everyone one I've used does not work so I decided to make my own. I wanna use the twitch Api to do it and in python but I cant find any tutorials that work or any recent ones. Does anyone know how I can check if a streamer is live with the twitch api python?
If you aren't already familiar with the Twitch API it's recommended that you review their documentation before getting started as there will be some steps to take to get Auth when requesting the information for any Twitch account using the API.
https://dev.twitch.tv/docs/api/
Once you've got your tokens and authentication setup detecting the online status of your stream can be done be trying to read the streams end-point.
https://dev.twitch.tv/docs/api/reference#get-streams
If you're offline that end-point will return blank and when you're online it will return with the information relating to your stream.
You can set your script to check if the end-point is returning any values or not and have it send an online message if you're online or do nothing when you're not.
Hope this helps.

Python Twilio without using flask or django?

As far as I know, this question hasn't really been asked.
I want to use twilio to send and receive messages from a python app. Sending isn't a problem, but I know receiving uses webhooks. Every tutorial and even the twilio documentation uses flask. Im wondering if I can create a program to receive information from twilio without using flask or is flask/django required.
Thanks
You need something that can accept HTTP requests
Webhooks are user-defined HTTP callbacks. They are usually triggered by some event, such as receiving an SMS message or an incoming phone call. When that event occurs, Twilio makes an HTTP request (usually a POST or a GET) to the URL configured for the webhook.
To handle a webhook, you only need to build a small web application that can accept the HTTP requests.
It needs to be something that Twilio can access through HTTP. So while you can probably use any web framework you want, you are going to need one.
https://www.twilio.com/docs/sms/tutorials/how-to-receive-and-reply-python

How do I extract the data from telegram deep linking?

I'm currently developing a bot for telegram using the Python API and I'm trying to use deep linking to have command parameters running when the user presses the Start button.
For example, my link is http://t.me/mybot?start=parameter
How can I process the parameter that was entered ?
Lots of thanks! :)
You need to set up a webhook for incoming messages to receive such updates. Telegram notifies you automatically when somebody clicks a link like http://t.me/mybot?start=parameter. This is webhook documentation:
https://core.telegram.org/bots/api#setwebhook
Check Telegram deep linking documentation (https://core.telegram.org/bots#deep-linking) for an example.
Use, context.update.startPayload to get the pay load data.

Daily Update from DialogFlow fulfillment python in google assistant

I'm developing an application with Dialogflow and Actions on Google which requires to send daily birthday notification in Google Assistant.
I'm following this documentation to send daily updates. But I'm having trouble because of the language barrier.
I'm developing backed in Python and using fulfillment to serve the request, but that documentation is in Node.js. So I need help to send daily updates.
I've done up to Console setup. Please guide me for further process.(Which JSON req. should I sent?)
If you look down that documentation page a bit here and click the JSON tab, you'll see the specific format you need to configure the subscription to your birthday updates.
Since you're not using a client library, you'll need to write the Python code yourself to respond with the appropriate JSON.

Categories