twilio outbound voice call from client - not phone - c#

The docs say that the from can be a phone number OR client
https://www.twilio.com/docs/api/voice/making-calls
From: The phone number or client identifier to use as the caller id. If
using a phone number, it must be a Twilio number or a Verified
outgoing caller id for your account.
however - the c# sdk doesnt seem to support the from being a Client - anyway to use a client instead of a phone number? using twilio voice SDK for ios and trying to allow the call receiver to see it as a "missed call" so they can call back.

Twilio evangelist here.
The helper library asks for an IEndpoint as the to parameter. There are a two classes that implement IEndpoint: PhoneNumber, Client.
var to = new Client("Bob");
var from = new PhoneNumber("+15017250604");
var call = CallResource.Create(to,
from,
url: new Uri("http://demo.twilio.com/docs/voice.xml"));
Hope that helps.

Related

Read Twilio sms as REST from pre-bought phone number

I'm trying to figure out twilio. I need to use a predefined phone number, so I bought one. But I do not see any way of actually getting sms's from it as REST. It seems like twilio follows more complicated schemas when getting texts from phone numbers. Like there is an option for WebHook, TwiML Bin, etc. Is there just a REST url I can access to get all the sms's from this number?
I was able to do this:
var messages = MessageResource.Read(limit: 20);
But this seems to allow me to read messages from all my sms's, even those that are not coming from a fixed phone number.
Background: my app will be a windows app, so I need a simplest way to read sms's possible. No web hooks and I do not need to send sms.
OK, I've figured this out. It was very easy:
var messages = MessageResource.Read(limit: 20, to: new Twilio.Types.PhoneNumber("+12345678901"));
Where +12345678901 is your registered phone number in Twilio system in + format.

Will making call or sms requests via the Twilio C# libraries always use HTTPS?

So I have some code that makes a call to the Twilio web API via the Twilio supplied C#.Net Libraries.
private static void SendSMS(Shift_Offer so, Callout co, testdb2Entities5 db)
{
co.status = CalloutStatus.inprogress;
string ShMessage = getShiftMessage(so, co, db);
so.offer_timestamp = DateTime.Now;
string ServiceSID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
var message = MessageResource.Create
(
body: ShMessage,
messagingServiceSid: ServiceSID,
to: new Twilio.Types.PhoneNumber(RCHStringHelpers.formatPhoneNumber(so.employee_phone_number)),
statusCallback: new Uri(TwilioCallBotController.SMSCallBackURL)
);
so.status = message.Status.ToString();
so.twillio_sid = message.Sid;
db.SaveChanges();
}
When I send this message request to the through the C# libraries, will it make the request using HTTPS? I'm concerned about sending the SID in plaintext.
Twilio developer evangelist here.
The API is only available over https at the base URL https://api.twilio.com. Also, all the officialy Twilio libraries, including the C# one, are setup to use https by default.
I've developed a Twilio integration for Dell.
They have some source code available here:
https://github.com/twilio/twilio-csharp
You can see there that they are using HTTP
https://github.com/twilio/twilio-csharp/blob/master/src/Twilio/Http/SystemNetHttpClient.cs.
Here at Dell, I needed to create my own Twilio implementation based on their REST API because of security concerns using HTTP.
Therefore, I highly recommend you to develop by yourself and make sure to use the HTTPS protocol.

Twilio Cant make call but no errors

I am trying make phonecall via Twilio using c# i am using the below code to make call.code executes successfully but i wont receive call.In my twilio page it shows staus as completed and durations.
const string accountSid = "ACe200aeb6115e1f3038a012e1103bd874";
const string authToken = "6XXXXXX";
TwilioClient.Init(accountSid, authToken);
var to = new PhoneNumber("+12025688652");
var from = new PhoneNumber("+919500553163");
var call = CallResource.Create(to,
from,
url: new Uri("https://demo.twilio.com/welcome/voice/"));
Console.WriteLine(call.Sid);
Twilio developer evangelist here.
I believe that you are actually making that call successfully. You are not experiencing the call yourself because of the parameters you have used.
You are making the call from your verified number. This is your real phone number, but when you set it to be the from address that just means Twilio will use it as the caller ID for the call.
For the to address you are using your Twilio number that you have bought within your account. When you make calls to that number, Twilio makes a webhook (HTTP) request to the URL that is set as the voice response in the number's settings. Currently, that is still set to the default, so Twilio retrieves this URL: https://demo.twilio.com/welcome/voice/. If you click through, you will see that this just reads out a message.
The URL you use when you create the call is also the default URL.
So what is happening with the call is that Twilio is using your caller ID to dial your Twilio number and when the call is answered, both sides of the call are reading out that message to each other.
If you want to at least make your own phone ring, then I'd start by reversing the to and from numbers in your API call. If you do that, then you should receive a call on your phone and when you answer it you will hear the demo message. Then, once you've done that you can start writing your own TwiML responses, possibly using Twimlbins to get started or by building your own application.
Let me know if this helps.

how to use pragrammable chat of twilio in c#

can enyone help me out to undersatnd this Here's a link! how to use in c#
i want to know how to use it
how to use pragrammable chat of twilio in c#
var client = new TwilioIpMessagingClient(accountSid, authToken);
Message message = client.CreateMessage(serviceSid, channelSid, memberSid, body);
Console.WriteLine(message);
https://www.twilio.com/docs/api/chat/rest/messages#action-create
Twilio developer evangelist here.
There is a full tutorial for using Twilio Programmable Chat from C# right here.
You might also find that the Chat fundamentals documentation will help. The key is that you need to run a server which you can use to generate an access token for your users so that they can access the Chat service. Once you have done that, you can build the rest of the application in the front end. You can also perform actions from C# using the REST API.

Is it possible to determine From number used when using copilot messaging service

When i send a text to a customer using a messaging service id. The from number is null in the returned MessageResource. Code below.
Is the only way to determine the From by making an additional call out using the message sid? I need the from used for analytics and so I can use the same number to contact an account in case the customer uses multiple contact numbers.
return await MessageResource.CreateAsync
(
to: new PhoneNumber(toNumber),
messagingServiceSid: messengerSid,
body: message
);
Twilio developer evangelist here.
When you use a messaging service to send messages from various numbers then you cannot know at the time of message creation what the number used will be. When you make the request to send the message, Twilio queues that message up to be delivered by the messaging service. If you inspect the status of the message object you receive from the API call you show in your question you will see it is "accepted". At this point the messaging service won't have decided which number to use.
So, you can either make a second request to the API using the message SID that is returned to find out the From number. Or, you could set a StatusCallback URL which would receive a request once the message was sent, including the From number.
Let me know if that helps at all.

Categories