I am building a web application that needs to be able to send SMS messages and check if a number has opted out of SMS. The only option that I have found is to use a web-hook for SMS replies and check there.
I am looking for an option where I can just ping the API and check if a number has been opted-out.
Opt-outs are handled on your side, so you will need to keep track when opt-out keywords are sent toward your application and if so, update your CRM to remove the consumers mobile number from receiving future SMS.
If you attempt to send an SMS to an opted-out consumer, you will receive an error message from Twilio.
ERROR - 21610 - Attempt to send to unsubscribed recipient
Twilio support for opt-out keywords (SMS STOP filtering)
"These messages will also be delivered to your Twilio account, and the defined web hook, so you can update your application logic."
Related
I have a feedback bot that forwards messages from users to a group chat of admins. Admins reply to a message and the bot sends their response back to the person it received the message from.
Telegram has a privacy setting to disable linking a forwarded message to users' account:
example
In this case, the bot is unable to send back the response. I would like to detect that a person has a hidden account and warn them that they won't get a response. I can't seem to figure out what method/property could give me that information.
I recommend to keep track of which user message originated which message in the admin chat rather than relying on the message.forward_from attribute. Since you tagged the python-telegram-bot library, let my point you to this thread on GitHub which has the same topic.
I am creating a Twilio Autopilot program that works on the SMS channel. Currently, I set up the sms channel using the messaging URL and webhooks according to the instructions in the SMS setup section here: https://www.twilio.com/docs/autopilot/guides/how-to-build-a-chatbot.
This works, but I am trying to find a way to retrieve the phone number from the incoming SMS to try and match it to a user to provide context to the bot ahead of time. Is there any way to accomplish this?
I am coding this in Python but any advice would be appreciated regardless of language.
The Autopilot webhook request is documented here and shows the parameters that are sent with each request.
In this case, you are looking for the UserIdentifier parameter in the incoming request, which, in the case of voice or SMS channels, will be the user's phone number.
Note that the request is made in the application/x-www-form-urlencoded format.
According to the Push Notifications guide within the Gmail API . The Gmail API can notify your back-end server application whenever your Gmail mailbox changes.
To do this, you need to setup a Cloud Pub/Sub client and create a topic. After that, you can then configure your Gmail account to send notifications for mailbox updates. The guide says that
To configure Gmail accounts to send notifications to your Cloud Pub/Sub topic, simply use your Gmail API client to call watch() on the Gmail user mailbox similar to any other Gmail API call. To do so, provide the topic name created above and any other options in your watch() request, such as labels to filter on." This quote was taken from the "Getting Gmail mailbox updates
section from the guide linked above. The guide also provides an example of making a watch() request.
My problem is that I need to filter by sender, not label. I am creating a bot that is going to be deployed to a hosting provider, probably GCP.
I am basically looking for a way to get the Gmail API to notify the bot whenever I get an email from a certain sender. I looked at the watch method in the docs and it seems like the only possible filter is label.
So is there an alternative way to get a notification via the Gmail API whenever I get an email from a certain sender?
Update:
Oh ok, so I was reading about publishing messages to topics via the Pub/Sub API, and according to the description of watch in the Gmail API docs, it seems like watch is responsible for getting Gmail to send (or publish) notifications to the topic. The Subscriber overview section of the Pub/Sub API docs say that
To receive messages published to a topic, you must create a subscription to that topic. The subscription connects the topic to a subscriber application that receives and processes messages published to the topic."
So the subscriber application would be the bot. According to the Filtering messages section of the Pub/Sub API docs, you can create a subscription with a filter. It says
"When you receive messages from a subscription with a filter, you only receive the messages that match the filter. The Pub/Sub service automatically acknowledges the messages that don't match the filter. You can filter messages by their attributes."
So, do the messages (or notifications) that Gmail is sending (or publishing) to the topic include a "Sender" attribute? I can't seem to find the attributes that Gmail includes in a notification message...
No attributes are populated by default
See this example notification structure here: https://developers.google.com/gmail/api/guides/push. As outlined in the spec, it's permissible for attributes to be empty so long as data is populated, which it is for Gmail API notifications.
So the answer to your question - if you cannot find the "Sender" attribute - this is because the message does not contain any.
Is there an API which allows me to send a notification to Google Hangout? Or is there even a python module which encapsulates the Hangout API?
I would like to send system notification (e.g. hard disk failure reports) to a certain hangout account. Any ideas, suggestions?
Hangouts does not currently have a public API.
That said, messages delivered to the Google Talk XMPP server (talk.google.com:5222) are still being delivered to users via Hangouts. This support is only extended to one-on-one conversations, so the notification can't be delivered to a group of users. The messages will need to be supplied through an authenticated Google account in order to be delivered.
There is pre-alpha library for sending hangouts messages on python:
https://pypi.python.org/pypi/hangups/0.1
The API have been reverse engineered and is not published (as someone posted in comments). Thus it might change a Google's will.
Also, messages sent using XMPP ceased to be delivered to Hangouts users. I guess this is another cut (of the thousand scheduled).
I send alarms and other notifications with a python script (failures on database server, partitions without free space, etc), using hangouts. It's easy. Look at http://www.administracion-linux.com/2014/07/enviar-mensajes-por-hangout-desde.html to send hangouts.
I made a wokkel (twisted python) bot to send and receive messages from the google xmpp service. Everything (auth, presence) etc works fine. One of the requirements of our project is that we need to send broadcast messages to everyone in the list. Normal messages and replies work fin, but when i send a broadcast message, i get this service unavailable error 503 message.
There are about 1000 user in my contact list. Is this some bug in the code or is it google policy to prevent rapid messaging.
Also, how do other google bots cater to a large contact base ? does google provide a commercial solution for such applications ?
Thanks