How to subscribe twilio number's error messages? - twilio

I have a Twilio account with a several numbers, and I have a Java back-end with Postgres DB. Is it possible to subscribe with twilio-api to get errors of this numbers on the date or in real time?

The best way to capture SMS errors such as Error 30005 Message Delivery - Unknown destination handset, and other 3000x errors is using Message Status Callbacks. You can find more details below. It is an additional URL you point Twilio to when making a request to the /Messages resource. These types of errors don't appear in the debugger because they can be quite a few of them, based on the customers use case. The new Message Insights tool allows you to visually filter on these errors from the Twilio Console (but there is no API).
A way to mitigate 30005 errors is using the Twilio Lookup API, to confirm the number is a mobile number and capable of receiving an SMS before sending the message.
Track Delivery Status of Messages

Related

How to see all numbers that have sent opt-out keyword text messages to a Twilio phone number?

How to see all numbers that have sent opt-out keyword text messages (eg. https://support.twilio.com/hc/en-us/articles/223134027-Twilio-support-for-opt-out-keywords-SMS-STOP-filtering-#h_01FBWGDY78H0PYY28VC341JPKE) to a Twilio phone number? Anyway to view these numbers via API request?
When I go to Phone Numbers > Active Numbers > (my phone number of interest) > Messages Log > View all my messaging logs, I can only search by date, to/from, and message SID. Any way to search by message content?
I would like to be able to answer the questions "Who has unsubscribed from messages from this number?", "Who has STARTed receiving messages?", etc. Is there anywhere I can see this info?
Twilio developer evangelist here.
That information is not available through the API. My recommendation is that you hook up your webhook and inspect messages that are sent to your Twilio number for the opt out/in keywords that we support (these messages are still sent through to your application). You can then keep a record of which numbers have opted out or back in again. If you have been sending messages, but not keeping this record, then you can tell if a number has opted out by catching error 21610 when you try to send a message to a number.

Showing Read At for Twilio Programmable chat

I'm using Programmable chat. I'm trying to show ReadAt meta data to users. I know when the user is getting the message on the frontend since I'm listening to messageAdded on the current Channel in the Twilio Javascript SDK. I'm storing the message by listening to Webhook on the preMessageSend to make sure that the message is saved in DB. When I get this message, the problem is I'm not getting the messageId which I'm getting on the Javascript SDK message. Can someone help me in understanding how to correlate both the messages?
According to the Twilio developer docs:
Pre-Event Webhooks will fire before an action has been committed to the Chat instance, blocking publication until a response is received. This gives your backend (or Function) the opportunity to intercept, modify, or reject any action across the instance, making these hooks useful for spam/language filtering, complex permission schemes, or other business logic. Pre-event webhooks are fired only for actions from the Chat SDK; the REST API actions will never fire them.
So I suspect the messageId is not created until after this webhook.

Voice/SMS testing API or call lists

I am building an app using Twilio to send out text messages and phone calls. It works great but I know there are limits to the amount of messages to send out per number in any given day. The app is going to be used to send out messages in the thousands at times, for instance to alert contacts about weather cancellations.
Since I am still developing, I do not want to send out real messages to thousands of real numbers a bunch of times while I test and configure my code.
Is there any phone apis, lists, etc. of dummy numbers that can be used as my example contacts that will at least return some form of TRUE that the number exists and received my call/message? Or return something else if I hit a use limit because of the number of messages I am sending.
I think I could get everything setup with a list of 1000 numbers since I can plan out every 250-500 calls, do this or that.
Twilio developer evangelist here.
There are no lists like that that I know of.
You do have a set of test credentials that you can use to send messages to a few "magic" numbers that will behave as if the message was successful (or failed for some reason). However there's only one success message here.
The thing about the limits of 200-250 messages per number per day is that they aren't hard limits. They are just around the level that carriers will start to consider blocking your messages. At that point you will likely still get a positive response from the Twilio API as a message is queued to be sent, but it may or may not fail at delivery time.
I recommend you look into Twilio's messaging services, they allow you to create a number pool that messages are sent from. If you are sending a number of the same messages at the same time, you can also check out Twilio Notify for sending notifications. I recently wrote up a blog post on how to set up a messaging service, number pool and Notify for bulk SMS.
Let me know if that helps at all.

Twilio: How to get answers from message log with just phone number

I want to get received messages of the same day of a phone number with the help of API or anything.
(I have purchased ofcourse a phone number)
**
Requirement :
**
I have a twilio app which sends 5 questions to 1000 user and users reply's to it. Like a survey. App is deployed on Azure.
I will get 5000 messages in log.
I am planning to retrieve messages by phone number and update my database from the user.
Implemented :
Implemented this https://www.twilio.com/docs/guides/sms/how-to-receive-and-reply-in-csharp. Any other idea for the requirement is also appreciated.
Twilio developer evangelist here.
I see that you've implemented the basic flow for responding to incoming SMS messages. If you are implementing surveys across a number of users my advice would be to expand on that application.
Firstly, you would need to run through your database to get all your users' phone numbers and send the first question to all of them using the Twilio REST API to send each a text message.
Then, when you receive an incoming message from one of your respondents you can find out the number that sent the message by inspecting the From parameter on the incoming request body. You can then look up your user in your database by phone number and save that response for them. Then you can use the TwiML <Message> to respond to the user and send them the next question.
This way you can collect the responses as they come in, rather than call the REST API to list all responses.
Let me know if that helps at all.

Twilio Parallel Process Result Page Update

I'm wanting to update a div or some area on a page that allows the user to progress, after a Twilio text goes out and receives either a 1 (true) or 0 (false) from a remote user. I'd like to give the user 5 minutes to answer the text, and have the page display the conditional result based on that answer.
Anybody know of a way to poll a result in order to display the two options? The user sends back a 1 to Twilio, which somehow goes to my server with parameters. I'm still learning how that can be done.
So I am looking for two items:
How to receive parameters from remote SMS using Twilio, passed to my server page, basically text number, sessionID, and user choice (1 or 0)
same page display of updated response from above. I'd like to not rely on page refresh.
Twilio developer evangelist here.
When you receive an SMS message on a Twilio phone number, Twilio makes an HTTP request to your application, at a URL that you supply, with all the details about the message, including the number it was from and the body of the message.
I would recommend checking out the quick start guides that we have on the site that will get you up and running sending and receiving messages using Twilio.
Once you've got the receiving messages bit sorted you then need to connect that incoming message to the browser the user was using. I'd take a look at either Server Sent Events (which I wrote about in a different context here) or web sockets, both ways of connecting the server to the browser without needing to poll or refresh. You'll have to figure out how to create channels for your users so that they only receive their own update to the page.

Resources