Twilio API - How to Opt-Out a phone number - sms

When a new user signs up, we're going to give them a checkbox where they can Opt-IN or Opt-OUT of receiving SMS messages.
I can easily track this on my own by making sure our application doesn't send texts their way, but I'm wondering if it makes more sense for me to just add them as opted out on Twilio?
I'm still playing around with this idea, but regardless I'm not seeing any API endpoints (https://www.twilio.com/docs/api) for Opt-In or Opt-Out.
Questions:
How would I Opt-Out a phone number if I choose to go that route?
Is it better to manage this list on my end, or to use Twilio for this (if it's possible), or to be redundant and manage my own list in addition to Twilio enforcing it?

Twilio developer evangelist here.
There is no API for developers to opt users' phone numbers in or out of messages so you should maintain that opt out list yourself within your own application as you described at the start of your question.
Twilio does make it possible for users to completely opt out of messages from a number (or messaging service) using the industry standard opt out words (STOP, STOPALL, UNSUBSCRIBE, CANCEL, END, and QUIT). When a user sends one of those words on their own to your number then Twilio will cease sending messages to that person. You will receive the message as a webhook so you can watch for those keywords and update your application's opt out list too.
I recommend that if you want users to opt out of messages that you get them to do so as part of your system rather via the STOP mechanic. That way, to re-enable messages they can do so through your system and not have to send an opt in message (START, YES and UNSTOP) to open up to messages again.

Related

Slack API - persistent message visible only to a set of users in a public channel

I'm planning to write a slack app, and I need to render messages depending on who read them.
I'm thinking something like: the App should have some options, and user's clients should render the messages depending on the options chosen by the user.
Is there a way to post a persistent message (I mean not an ephemeral message) which is shown only to a user (or a set of users)?
Or
Is it possible to post a message shown differently depending on the user who read it?
I don't need to send private or sensitive data, so if the solution to my problem is a message containing all the content for all the users in the channel, it is perfectly fine. It's just matter of user experience.
I have two constraints:
The user experience for those who don't use the App should not be impacted
I need the messages from the App to be rendered in reply to messages sent by the users, so solutions like "open a new channel" or "send direct messages" are not suitable for my needs.
Thank you all (but the Slack team which, in case let us doing that, it makes that not clear in the documentation :D )
This is not possible unless you create your own client to show/display the messages.
Custom slack apps usually augment to the existing functionality. How do you expect to override the functionality of Native Slack 'Desktop, Mobile & Web' Client.
I am happy to discuss this further, if you have some approach in mind.

How do I notify users on Slack that aren't in the channel?

What we are trying to do
I am working on automation which posts messages to a Slack channel using Incoming Webhooks on a custom Slack App. The messages mentions people.
What works
We can send a message just fine, it has formatted content, and usernames are correctly resolved using the link-names flag.
What isn't working
The whole point of the notification is to inform a dynamic set of people about something they should care about. The set of people we tag varies hugely (think people who contributed to a pull request) and so not all possible recipients are in the channel these automated messages go to.
We assumed that given the usernames are being directly #-mentioned, they would be notified by Slack. However, two of the users we've tested with and #-mentioned confirm they never received a notification they had been tagged.
This is different to "human" behaviour, where if you #-mention someone in Slack, you get a little message reminding you that person isn't in this channel and offers to invite them or let them know.
As far as we can tell, sending the message programmatically is doing the equivalent of "Do nothing" in the picture above. I want to do either of the other two options, preferably "Let them know".
How can I notify people they've been mentioned? I've looked at all the API documentation and nothing discusses notifying users who aren't in the channel that they are mentioned.
This can't be an uncommon issue.... right?
Notes:
We aren't directly calling chat.postMessage, it's just the only documentation on link_names I could find to link to. We are using Incoming Webhooks, which has minimal documentation on the parameters - it seems to be the same as chat.postMessage.
We would prefer not to move off Incoming Webhooks, but we can do a custom integration with the API if we have to.
You need to invite the user to the channel first, using the Python client that's:
client.channels_invite(
channel=channel_id,
user=user_id
)

Sending/Receiving multi-recipient SMS - Twilio API

I am writing an app that will facilitate the sending and receiving of SMS messages via a web application. I would like to allow for multiple recipients (not bulk, just a few recipients at most).
I understand that in order to send to multiple recipients, I have to make multiple API calls, and that is fine. The problem I am having is receiving text messages via the Webhook callback. If the SMS was sent to multiple recipients, I cannot see the other recipients in the callback, just myself as the recipient.
Because of this, I have no idea whether this message was intended for just me, or for other recipients as well. This is a problem, because I would like to show threaded conversations similar to Google hangouts, or the SMS applications on all Andorid and iPhones.
I cannot figure out a way to track conversations, if I can't tell if a received message was sent to just me, or a group of recipients. Any suggestions? I do not yes use Twilio on a production server, so if this is not possible to do using Twilio, but is possible using another service, that would be an option for me as well.
Twilio developer evangelist here.
Twilio doesn't fully support group messaging the way that you are used to it when using a phone. That actually relies on MMS under the hood to keep the members of the group chat synced up.
Where you make multiple API calls to send messages to each user, that is manifested as just a single message with no group attached. Thus, any reply to that message comes solely from that person you sent the message to. There is no group at all at this point.
The link that Alex shared in the comments is the closest way you can get group messaging to work. It relies on everyone messaging one Twilio number and the application behind it fanning the messages out to all the recipients. The blog post also comes with some handy subscribe/unsubscribe administration for the group.

SMS sent from twilo blocked by tmobile I believe

So to help debug we even take it out of our code and put it on twilio portal that lets us test the API. When I send to most of our group everyone gets the text message, but when we send to someone with tmobile, the message says it's delivered on twilio logs, but the person never gets it.
If we test and send him an 'Hello world' message, he gets it, but when we test with out SMS
'XXXXXX wants to make plans with you on the HotSauce App. :tada::hot_pepper:
Get the app now to join in on the action. https://rts2t.app.goo.gl/FGYB'
The message doesn't get delivered. Maybe there's a whitelist for Tmobile we can get on?
FYI, we have a USA number and this is a USA person and we are on the paid version, not trial.
I've encountered the same issue working on another app, and unfortunately I do not think there's a conclusive single answer. Carriers intentionally keep their spam filtering techniques secret so that they cannot be gamed. From Twilio's support page on the topic:
There is no standard practice for carrier filtering across all carriers. For some, filtering can range from a simple static list of prohibited terms to advanced machine learning systems that work in real time. Regardless of the system, carriers keep their filtering systems closely guarded secrets. In turn, Twilio cannot say definitively how these systems work or why a particular message was filtered.
Note that not all carriers report errors to Twilio, so some messages may appear to go through even though they were not delivered. You may or may not see error 30007 in the Twilio console when a message is blocked.
I don't believe any type of universal white-list exists, and once a number has been black-listed by a carrier there is no easy process to have it white-listed. However, short-code numbers are generally less prone to getting spam filtered (though they are more expensive).
While there isn't any one thing you can do to guarantee delivery, there are several things you can try:
Make the language of the text message more conversational as opposed to promotional
Don't obscure the url with a link shortener
Don't over-use a single number by implementing something like Twilio co-pilot
Include clear opt-out instructions

Is it posible to send multiple message to Google Home through DialogFlow?

On facebook Chatbot or others platform we can send message directly to the user.
So for one question we can send multiple answer.
Now, that i'm developing for Google Home, I need to do the same.
I didn't find this opttion.
Dialogflow HTTP call to my server is the only output available.
So is there anything i missed to send message back to user in case I have a multiple messages answer?
(Or do I have to bufferise very message my hook creates before sending it back?)
Thanks
The conversation model for the Google Assistant is different - you can only send a message to the user in response to the user sending you a message. You can only send a single response, but it may have multiple parts (up to two Simple responses, containing messages, plus other features such as cards and carousels).
If you need to send multiple things back - you may need to rethink how you're doing it or how much you're sending back at a time. The Assistant is primarily for audible responses, and a long audible response is generally not a good UX.

Resources