it seems like the status delivered is not available for MMS. I get the sent status in my callback for a MMS just fine, but not delivered. Why? I use node.
My call looks like this :
var sms = {
to,
from,
body: message.message,
statusCallback: 'callbackurl',
mediaUrl: [
'imageurl1',
'imageurl2',
]
}
clientTwilio.messages.create(sms)
.then((sms) => {
});
I receive the MMS as expected.
Twilio developer evangelist here.
When Twilio alerts you of the status of the message, it does so using the data it gets back from the network you send the message with. If the delivery information is not available, Twilio can only mark the message as sent.
Related
I have developed an application that sends thousands of SMS using Twilio Notify Service.
const bindings = phoneNumbers.map(number =>
this.createBinding('sms', number)
);
await this.notifyService.notifications.create({
toBinding: bindings,
body
});
The code above doesn't give me a feedback of whether the messages were received or not, but as I can see in Twilio dashboard, some messages fail with error codes 30005, 30003, 30006 and 52001.
I'd like to consume all those error logs and unsubscribe the numbers with error codes. I'm thinking of creating a job that runs every night to do that.
I've tried to list all the alerts:
client.monitor.alerts.each(alert => {
console.log(alert.errorCode);
});
But it seems to fetch only some alerts with error code 52001.
How can I consume all the errors with Twilio API? Is there any other way to be notified of those errors?
When receive message from my twilio account.
i got message with different number like 400012 or 641011 like this
but not my twilio number which i use to send message is not display in my inbox when i receive message
can i do something so that whenever someone receive message from my twilio number the number in inbox showing is also twilio number?
var client = new twilio.RestClient(twilio_account_sid, twilio_auth_token);
client.messages.create({
body: msg,
to: to, // Text this number
from: twilio_number // From a valid Twilio number
}, function(err, message) {
if(err) {
console.error(err.message);
}else{
console.log("here send sms ... ... ...");
}
});
my code is simple like above
Twilio developer evangelist here.
There are some limitations when sending messages to certain countries from a Twilio number. India is particularly restrictive and will not let you retain your original number. Users can still send messages to your Twilio number, they will just receive them from a shortened number like the ones you shared.
You can read up on the restrictions for sending messages to India in this support article and by checking out the SMS guidelines for India.
The restrictions for the other countries you need to send to will be different. For example, in Malaysia your long code phone number is preserved. Check out the restrictions for your countries here: https://www.twilio.com/sms/guidelines
Let me know if that helps at all.
Good Day,
How do I properly receive an SMS on my web app using twilio without responding back to the sender.
I read about this.. https://support.twilio.com/hc/en-us/articles/223134127-Receive-SMS-messages-without-Responding but I need to use the webhook to send the sms to my webapplication too, if I do receive it without setting a response, It will generate an Error - 11200 (HTTP retrieval failure) how do I prevent this? also by setting up respones.
my code is
var resp = new twilio.twiml.MessagingResponse();
resp.message('<Response></Response>');
res.writeHead(200, {
'Content-Type':'text/xml'
});
res.end(resp.toString());
sadly this one sends <Response></Response> to the sender instead.. im using nodejs by the way.. Thanks!
Those who are finding this in 2021,
If you need to just recieve message from twilio and not send any message to user then you can use this code.
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end();
For more refer this doc,
Receive SMS and MMS Messages without Responding
I have not tried yet but I think if you comment out this line:
// resp.message("<Response></Response>");
no message will be sent.
Update after reading Phil's comment:
This: resp.message('<Response></Response>');
is equivalent with sending the folowing XML to Twilio:
<Response>
<Response></Response>
</Response>
in which case the sender will receive a message like: <Response></Response>
If you comment out the line
// resp.message("<Response></Response>");
or if you do resp.message("");
is equivalent with sending the folowing XML to Twilio:
<Response />
in which case no message will be sent to the sender.
I'm using the Twilio client js in my browser in order to make calls.
In the server I build the Twiml:
const dial = twiml.dial({
/*action: `http://270311bb.ngrok.io/twilio/callend`,*/
callerId: availableNum.phoneNumber || availableNumbers[0].phoneNumber
}, (n) => {
n.number(request.body.number, {
statusCallback: `http://270311bb.ngrok.io/twilio/${request.body.agentId}/status`
});
});
I also tried with the 'action' parameter.
In my status/callend route I get the callstatus only as completed or no-answer, even if the called number is busy, or not connected.
Twilio developer evangelist here.
The StatusCallbackEvent's that you can receive from a call are only initiated, ringing, answered, or completed. Busy or not connected calls are also completed calls. Can you try querying the call from the API when you receive the completed event and see what status the actual call in.
I'm new in twilio and trying to understand how can i catch twilio's events in my backend (nodejs). For exemple each time i send a message, i want the console logs "Message sent" just for testing.
I read the twilio webhook documentation , however i can't really understand how to apply it in a nodejs environment.
Thanks for helping.
Twilio developer evangelist here. I think you will find this Twilio tutorial great, as it will walk you through exactly what you're trying to do, and will show you how to add events to the console.
But the gist of what you want to do it is the following:
// Create a new REST API client to make authenticated requests against the
// twilio back end
var client = new twilio.RestClient('TWILIO_ACCOUNT_SID', 'TWILIO_AUTH_TOKEN');
// Pass in parameters to the REST API using an object literal notation. The
// REST client will handle authentication and response serialzation for you.
client.sms.messages.create({
to:'YOUR_NUMBER',
from:'YOUR_TWILIO_NUMBER',
body:'Twilio message from Node.js'
}, function(error, message) {
// The HTTP request to Twilio will run asynchronously. This callback
// function will be called when a response is received from Twilio
// The "error" variable will contain error information, if any.
// If the request was successful, this value will be false
if (!error) {
// The second argument to the callback will contain the information
// sent back by Twilio for the request. In this case, it is the
// information about the text messsage you just sent:
console.log('Success! The SID for this SMS message is:');
console.log(message.sid);
console.log('Message sent on:');
console.log(message.dateCreated);
} else {
console.log('Oops! There was an error.');
}
});
Full documentation for the Node library can be found here.
Hope this helps you out.