I am sending SMS through Twilio trial account using ASP.NET C#. I registered the numbers in my twilio account as I'm using trial account. Not getting any error but SMS is also not getting sent.But while checking SMS log in account it's showing Sent/Delivered. Any leads?
Please find my code snippet:
public void smsTwilio()
{
const string accountSid = "accountSid";
const string authToken = "authToken";
TwilioClient.Init(accountSid, authToken);
var to = new PhoneNumber("+91XXXXXXXXXX");
var message = MessageResource.Create(
to,
from: new PhoneNumber("+1XXXXXXXXXX"),
body: "This is the ship that made the Kessel Run in fourteen parsecs?");
Console.WriteLine(message.Sid);
}
Twilio developer evangelist here.
With a Twilio Trial account, you should be able to text any numbers anywhere supported by Twilio. However, it's worth making sure you have the correct geo permissions enabled. You can do that by heading to this page and checking the "India" checkbox.
Next up, there are a few limitations when sending SMS messages to Indian mobile devices, which you can read more here. These are limitations established by carriers in the country as opposed to Twilio. The important ones that are likely to be affecting you now are:
They cannot be sent to any phone number in India’s Do Not Call Registry
They are only delivered between the hours of 9 A.M. and 9 P.M. local Indian time
No more than one message every 20 minutes from the same Sender ID to the same destination number with the same message body.
Lastly, from within a phone number, you can click on "Messages Log" and see what's going on with the messages you're trying to send if they've been delivered correctly.
Hope this helps you.
It seems you are trying to send a sms internationally, from a US(+1) number to an India number(+91) . this is blocked by default on trial twilio numbers.
You can try an initiate your twilio trial with an Indian number
Related
I am using Twilio with dotnet (using endpoints not Twilio library), when I send sms, they are delivered correctly, but when in my message there is a phone number, it looks it was sent, I can see in my Twilio's console that his status is delivered, also the response of the post is ok. But in my cellphone i dont receive the message. For example if the message is "Hello world" -> everithing okay and I receive the message. I fthe message is "Please call(888) 888 - 888 for Customer Service", in Twilio's console everything is okay but I dont receive the message. Is there an specific format for a phone number in Twilio messages?
I want to deliver voice message using Twilio. I also use text to voice twimlets as well. Here is the code
TwilioClient.Init(accountSid, authToken);
string responseurl = "http://twimlets.com/echo?Twiml=%3CResponse%3E%0A%3CSay%3EDear%20John%20Smith%3C%2FSay%3E%0A%3CSay%3E%0AThis%20is%20a%20test%20for%20happy%20programing%20IVR.%20Why%20this%20is%20so%20hard%3F%3F%0A%3C%2FSay%3E%0A%3CPlay%3E%0Ahttp%3A%2F%2Fwww.pacdv.com%2Fsounds%2Fpeople_sound_effects%2Fapplause-4.mp3%0A%3C%2FPlay%3E%0A%3CSay%3EGood%20Bye%3C%2FSay%3E%0A%3C%2FResponse%3E&";
var call = CallResource.Create(to,from,url: new Uri(responseurl));
<Response>
<Say>Dear John Smith</Say>
<Say>
This is a test for happy programing IVR. Why this is so hard??
</Say>
<Play>
http://www.pacdv.com/sounds/people_sound_effects/applause-4.mp3
</Play>
<Say>Good Bye</Say>
</Response>
Here is the problem, When I pick up the call, I will hear all voicemail played. When it goes to the voicemail, It will cut the first 7 seconds recording off.
Anyone knows how to solve this problem?
Thanks
Twilio developer evangelist here.
The issue is that when your voicemail answers the phone it starts by reading its own message. At the same time, Twilio is reading the message out too, so when the voicemail starts recording the message is halfway through.
There are two ways you can get around this. Either you build a loop into your message to ensure that it all gets recorded. Or you can use Twilio's Answer Machine Detection to only start the message when it is sure that a human or machine has answered.
To use the AMD you need to pass another parameter when you create the call:
var call = CallResource.Create(
to, from,
url: new Uri(responseurl)
machineDetection: "DetectMessageEnd"
);
machineDetection can be either "Enable" or "DetectMessageEnd". "Enable" will call your webhook URL as soon as Twilio knows if it is human or machine, "DetectMessageEnd" will wait if it is a machine until the voicemail's message has ended, allowing you to play your message and have it fully recorded.
When Twilio requests your webhook URL, it will have an extra parameter too, AnsweredBy. You can use this to decide what course to take depending on whether a human or machine answered.
Let me know if this helps at all.
This question already has answers here:
How do I generate a random integer in C#?
(31 answers)
Closed 7 years ago.
I know how to generate a random number in C#. I read some article, How to send voice mail in Twilio. But my problem needs to send the message like this
"Hey this is your access code 123456"
The number 123456 will be different for different user.
How do I generate dynamic "Hey this is your access code 123456"?
Twilio evangelist here.
How you do this depends on whether or not you are responding to an inbound text message or initiating a new message to send to a user.
If its the former, you can use TwiML to tell Twilio how to respond to the inbound message. IN your case that TwiML would look like this:
<Response>
<Message>Hey this is your access code [YOUR_RANDOM_NUMBER]</Message>
</Response>
If its the latter, you can use the Twilio C# helper library to send the message:
// instantiate a new Twilio Rest Client
var client = new TwilioRestClient(AccountSid, AuthToken);
client.SendMessage(
"YYY-YYY-YYYY", // From number, must be an SMS-enabled Twilio number
person.Key, // To number, if using Sandbox see note above
string.Format("Hey this is your access code {0}","[YOUR_RANDOM_NUMBER]")
);
I'd suggest checking out our Quickstarts which will walk you through the basics of sending and receiving SMS messsages and making and receiving phone calls using C#:
https://www.twilio.com/docs/quickstart/csharp/sms/hello-monkey
Hope that helps.
Edit 2:
Client Library: After reviewing it is not easily suggested that this is for the .NET client library.
DLL: Google.Apis.Admin.email_migration_v2.dll
What steps will reproduce the problem?
Generate a process which contains a
Google.Apis.Admin.email_migration_v2.AdminService instance for each
unique Google Apps Gmail mailbox that will have messages sent to it.
All of the AdminService objects generated use the same OAuth2.0
credentials and application name. Each AdminService object generated
will only send messages to one Google Apps user’s mailbox. For
example, if we were sending messages to five different Google Apps
Gmail mailboxes we would generate five AdminService objects to send
messages; one for each user’s mailbox.
Biggest thing to note is that each AdminService object created is created on a separate process.
AdminService objects were given a FileDataStore object to change the location of where the refresh token is stored; C:\ProgramData\SomeFile\SomeFile.
Supplied appropriate scopes to the credentials.
Begin sending mail messages on each process. Using one thread to send messages in each process, so only one message is sent at a time to each user’s mailbox.
Each message sent gets its own instance of MailItem and MailResource.InsetMedia
The MailResource.InsertMedia object is generated for each item by calling AdminService.Mail.Insert(MailItem, string, Stream, string) method.
When our code makes the call to MailResource.InsertMediaUpload.UploadAsync(CancellationTokenSource).Result is where we can receive the error.
The error is caught and handled (logged) from the return type of the aforementioned call; the type is Google.Apis.Upload.IUploadProgress. The exception is handled using the IUploadProgress.Exception property.
What is the expected output? What do you see instead?
The expected output would be a successful message response or the exception property of the IUploadProgress to be null after the return of the task. Instead we are receiving the following error message:
The service admin has thrown an exception:
Google.GoogleApiException:Google.Apis.Requests.RequestError
Limit reached. [412]
Errors [Message[Limit reached.] Location[If-Match - header] Reason[conditionNotMet] Domain[global]]
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
at Google.Apis.Upload.ResumableUpload`1.d__e.MoveNext()
What version of the product are you using?
Google.Apis.Admin.Email_Migration_v2 (1.8.1.20)
What is your operating system?
Windows Server 2008 R2 Enterprise (SP1)
What is your IDE?
Visual Studio 2013 Premium
What is the .NET framework version?
4.0.30319
Please provide any additional information below.
Non-consecutive messages can fail (with the 412 http status code
provided above) during the process of sending the messages. Once we
receive this error other messages sent after the failed message(s)
can succeed. (Items can fail at any point during the process
beginning, middle or end.)
Each message sent has nearly identical content. The size of the
messages range from 1KB to 100KB including the size of all associated
attachments, not all messages have attachments.
Reprocessing the failed items at a later time results in successful
message responses and the appropriate items are sent to the user’s
Google Apps Gmail Inbox.
The maximum number of Google Apps user’s mailboxes sent to at one
time was ten.
After checking the quotas of our Google Developers Console project:
We were nowhere near the specified limit of 20 requests a second for
the Email Migration API; maxed out at sending 7 requests a second.
Only 2% of the maximum daily requests had been reached.
All messages sent had the same label; the label was well under the
225 character limit. Actually all of the labels/sub-labels applied
together only surmounted to 40 characters.
This error message can still be received when sending to only one
Google Apps user’s mailbox; only using one process and one thread.
Each process is normally sending anywhere from 1000-5000 messages.
I have not found a lot of specific documentation to explain this particular error in enough detail to remedy the problem at hand.
Questions:
So what exactly does this 412 http status code mean? What limit is being encountered that this message is referring to?
Shouldn’t we be receiving some form of 5XX error from the server if we are hitting a limit? In which case wouldn’t the built in exponential back off policy kick in?
a. Unless the server is checking the POST request for a pre-condition about a server side limit then telling the client to back off which is what a 412 error seems to typically indicate. In that case please give as much detail as possible for question 1.
Sorry for the extensive post! Thanks for your time! I will also be creating a defect/issue in Google's .NET issue tracker and providing a link.
Edit 1:
For anyone interested in following this issue here is a link to the submitted item in Google's issue tracker for .NET.
Submitted Issue
For reference it is issue 492.
I am not quite sure where you see the "the specified limit of 20 requests a second for the Email Migration API". Reminder: the QPS limit you see in the Google Developers Console project is not the actual default limit. You can change that limit to anything you want, and thus, that's not the actual limit for the API. It is really just for managing the consumption of the API quota (some APis will have a much higher QPS where you can adjust it to lower for different projects across your console).
According to the email migration APi documentation, the QPS is 1 request per second (the link is here: https://developers.google.com/admin-sdk/email-migration/v2/limits).
I have experienced 412 errors when the QPS limit is being hit, and I have also seen the 412 error returned when I am uploading too much data to a single domain. How much data are you loading all at once? I would suggest doing an exponential backoff to see if the issue would disappear.
I believe I have found an answer to this problem, though I will advise a disclaimer, I do not work for Google and cannot be 100% sure of the accuracy; you've been warned. This should at least hold true for the .NET version of Google's Email Migration v2 API. I cannot guarantee how other APIs work because I do not use them..
Through working with this API in spurts for well over eight months now, it appears that if an application or multiple applications are to send messages to a single Google Apps user/mailbox consistently, at a faster rate than which Google servers can process, then at some rate you should start to get a bunch of GoogleApiExceptions stating "412 - Limit Reached" when sending new messages. What we have gathered through using our application is that each Google Apps user/mailbox has its own pending items queue. When you send a message to Google Apps it is first put into this queue before being processed by a Google Server and put into the user's mailbox. If this queue becomes full and you attempt to send another message you will receive a 412 error.
Options are to wait before sending another message, you'll have to wait however long the Google server takes to process the next message in the user's queue before sending another; which is unpredictable. The better option in my opinion is to start sending messages to another Google Apps user; because each user appears to have its own message queue. Be sure to stop sending to the user who is consistently getting 412 errors. This will give the Google server some time to process that user's packed message queue. Note each pending messages queue appeared to hold about 100-150 items before throwing 412 errors.
503 errors appear to occur when sending messages into a user's mailbox queue at a higher rate than 1 request per second. As Emily has stated "the QPS limit you see in the Google Developers Console project is not the actual default limit" it is truly 1 QPS per Google Apps user.
As for the exponential back-off it is supposed to be implemented automatically see this. Note Peleyal appears to be the gentleman in charge of the API; can be noted from the download page for the API.
This took us a little while to figure out so cheers if you're having this issue! Please if you find any contradicting information correct any mistakes found in this answer or make your own!!
I am working on a site and it has to have a newsletter sending functionality. A couple of weeks ago I posted a question on stackoverflow, and the good people suggested that I do a console app which I call from the site and it sends the mails. I did this, and it works locally, but I wasn't able to get it working on the server (security issue). Been trying to make this work for the past 3 days. So then, I decidet to try and change how the email is sent.
To make a long story short, now I split all the emails in "groups" of 50, and then make a new MailMessage object, and mailMessage.To.add(sample#sample.com) emails to it. Then I send it 50 by 50.
It works for now, but my question is, how "BAD" is this solution? I tryed adding the emails to bcc, but for some reason (for me) this works only locally ( !?! ).
And one more thing which I couldn't find on line, what is the maximum number of mails I can add to the MailMessage object?
Thank you for your time!
Andrej
its very bad since each user which receives your newsletter will have access to the 49 other contacts (where do i sign up?)
If you are having problems with multiple BCC's, contact you SMTP host.
Did you try sending each separately? if it is taking to long to send, you can build a multi-threaded solution which will help.
The correct way is to send each one his mail and you create a queue in memory on in database for store mail before send.
Remember send all emails in 1 time if you use public smtp server is bad thing, you can be banned for that server,this means you must schedule such as 1000 mail at time or less.
i have wrote this years ago if you need i can post same code