Generate random number using c# and send voice call through twilio [duplicate] - c#

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.

Related

Jamaa SMPP Long Message

I am very new to SMS and stumbled upon JamaaSMPP. But I am having trouble with regards to sending a message that is longer than 160 characters. I've read that I need to send or use PDU? But I am not sure how and what to do.

SMS not getting sent from Twilio using C#

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

Twimlets voice mail is cut off

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.

Working with IRC protocol, is it possible to know if the user who sent the message is voice or op?

I am using the C# library SmartIrc4net for creating an IRC bot.
when parsing a PRIVMSG message received from the chat server in IRC (this is generic, not specific to my library choice), is there any way to know if the user is a Voice or Op?
I have access to many fields like nick, message and such but I see no way of distinguishing a normal user from a voice or op...is that feasible?
Thanks!
Since you are receiving a PRIVMSG, you might want to distinguish in which channel the users has to be an operator or a voiced user.
You might want to check ChannelUser class, which contains the methods isOp and isVoice

How to Check Email Address Exists or Not ? using C#, ASP.NET [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How to check if an email address exists without sending an email?
Hi All,
I have a email functionality in my asp.net Web Application, Email Addresses are taken from a database. Is it possible to check whether E-Mail address really exists OR not. How can I do it ?.. I have searched in forums and Google got some related info which says using VRFY, RCPT Commands... but I didn't understand how can those commands be used in .NET using C#.. There are some third party tools but my client will not buy those tools..
I have SMTP mail server details,, ?? Is there any way this can be achieved ?
The only way is to open an SMTP connection and first try the VRFY, if this results in no, it does not exist, BUT if it is Yes it might only be that the server do not tell so the second step is to send the commands to send an email but after RCPT TO you abort, do not send the data command as some servers might actually send the email then even if you abort.
If it does not protest after RCPT TO you might as well try to send for real because that will then be the only way to test further, but some servers will accept the address and only fail later or even fail with a return message that will not be detected in the SMTP session at all.
So you cannot 100 % test an email without actually sending to the address and have the recipient either return the email to you or click a link to confirm the address.

Categories

Resources