Call recording SID from twilio - c#

I could make a call and record call conversation.
string callerId =string.Empty;//Twillio Account SID
var dial = new Dial(callerId: callerId, record: record_from_answer
How to retrieve Recording Sid of the current call, once the call recording is complete from Twilio using c#

Twilio developer evangelist here.
Twilio will make a request to your server with the recording information via the RecordingStatusCallback attribute. You can read more about it here
So all you need is create an endpoint that accepts a POST request from Twilio and change your code to something like:
var response = new VoiceResponse();
response.Dial("to-phone-number",
callerId: "your-twilio-number",
record: "record-from-answer",
recordingStatusCallback: new Uri("url_in_your_application_that_processes_recordings")
);
Hope this helps you

Related

Get Call SID-Recording could be done successfull

How to get the Call SID and recording SID of that call once the call recording is done from Twilio 'Dial' method.
var dial = new Dial(callerId: callerId, record: record_from_answer);
Twilio developer evangelist here.
You can't get the call SID and recording SID directly from the Dial method. However, you can set up to receive a webhook when the recording is complete.
For this you need to set the recordingStatusCallback attribute to a absolute or relative URL in your application.
var dial = new Dial(
callerId: callerId,
record: record_from_answer,
recordingStatusCallback: new Uri("https://www.myexample.com/recording")
);
Then, when the recording is ready your application will receive a webhook to that URL with the parameters CallSid and RecordingSid in the request body.
Let me know if that helps at all.

Stripe.NET add bank account using token to Stripe Managed Account

I've searched through Jayme Davis' documentation, and I cannot find how to add a bank account using a token to a Stripe Managed Account. The only way it appears to add a bank account in the documentation, is by using the CustomerBankAccount object, which requires a CustomerID as a parameter, and does not work with an AccountID (i.e. Managed Account ID). I essentially would like to make this request (from Stipe's website) using Stripe.NET and C# code. Any help would be greatly appreciated! Thank you in advance!
curl https://api.stripe.com/v1/accounts/acct_1032D82eZvKYlo2C/external_accounts \
-u sk_test_xxxxxxxxxxxxxxxxxxxxxx: \
-d external_account=btok_xxxxxxxxxxxxxxxxxxx
You can use the ExternalBankAccount property for this and see an example in the test here
var params = new StripeAccountUpdateOptions();
params.ExternalBankAccount = new StripeAccountBankAccountOptions
{
TokenId = _token.Id
}
var accountService = new StripeAccountService();
StripeAccount response = accountService.Update("acct_XXX", params);

Download Twilio Recordings using C#

I am working on one small utility using Twilio API which intend to download the recording of the call as soon as call ends ( can be done using webhooks ? ). I am not sure if twilio supports this kind of webhooks or not.
The second approach that i have in mind is to create nightly job that can fetch all the call details for that day and download the recordings.
Can anyone suggest me which is the best approach to follow. I checked the webhooks but i am not sure if they provide the call ended event.
I would appreciate if anyone can provide me code sample on how to get the recordings for particular date and download them using C# from twilio.
Twilio developer evangelist here.
You can get recording webhooks, but how you do so depends on how you record the call.
Using <Record>
Set a URL for the recordingStatusCallback attribute on <Record> and when the recording is ready you will receive a webhook with the link.
Using <Dial>
If you record a call from the <Dial> verb using the record attribute set to any of record-from-answer, record-from-ringing, record-from-answer-dual, record-from-ringing-dual then you can also set a recordingStatusCallback.
Using <Conference>
If you record a conference then you can also set a recordingStatusCallback.
Recording an outbound dial
If you record the call by setting Record=true on an outbound call made with the REST API then you can also set a webhook URL by setting a RecordingStatusCallback parameter in the request.
Retrieving recordings from the REST API
You can also use your second option and call the REST API to retrieve recordings. To do so, you would use the Recordings List resource. You can restrict this to the recordings before or after a date using the list filters.
Here is a quick example of how you would use the Twilio C# library to fetch recent recordings:
using System;
using Twilio;
class Example
{
static void Main(string[] args)
{
// Find your Account Sid and Auth Token at twilio.com/user/account
string AccountSid = "AC81ebfe1c0b5c6769aa5d746121284056";
string AuthToken = "your_auth_token";
var twilio = new TwilioRestClient(AccountSid, AuthToken);
var recordings = twilio.ListRecordings(null, null, null, null);
foreach (var recording in recordings.Recordings)
{
Console.WriteLine(recording.Duration);
// Download recording.Uri here
}
}
}
Let me know if this helps at all.

How to get callbackurl from twilio API against a twilio number

My question is basically about existence of API.
Is there any api from which I can get CallBackUrl against a number?
I have bought a Twilio number (and planning to buy more). Against that number i have configured a CallBackUrl.
Now I need to get the Callbackurl from API. Like I will provide create twilio client
var twilioClient = new TwilioRestClient(accountSid, authToken);
then need a API in which I will pass twilio number and it will return back the url
like
twilioUrl = twilioClient.GetCallBackUrl(mytwilioNumber);
is there Any possibility of such thing
Twilio evangelist here.
You can use the GetIncomingPhoneNumber method to get the details of a specific phone number, including the voice and message request URL's:
var result = client.GetIncomingPhoneNumber("PHxxxxxxxxxxxxxxxxxxxxxxx");
if (result.RestException == null)
{
Console.WriteLine(result.VoiceUrl);
Console.WriteLine(result.SmsUrl);
Console.WriteLine(result.StatusCallback);
}
Hope that helps.

User Master Account to send SMS on behalf of a Sub Account

I'm developing a feature for our product that will allow users to send SMS messages via Twilio and we handle all of the account issues. We have our Master Account and all of our customers will be sub accounts under us.
In an effort to not have to keep track of 1000+ auth tokens, we decided to use our Master Account credentials to send the SMS message however we still want it to roll up under the sub account. According to Twilio, this shouldn't be an issue.
My problem is that there is very little (that I've found) documentation for the c# library they provide. I'm not sure if what I've done is the correct way to accomplish what I described above and since I'm on a trial account until the project is finished and can be rolled out to production I have no way of testing.
var twilio = new TwilioRestClient("Master SID", "Master Auth Token");
var response = twilio.SendSmsMessage(sender, recipient.ConvertToE164Format(), message, null, "Subaccount SID");
The comment on this overload isn't really clear on if passing the subaccounts SID here will send the message as if I had logged into their account and sent it.
// applicationSid:
// Twilio will POST SmsSid as well as SmsStatus=sent or SmsStatus=failed to
// the URL in the SmsStatusCallback property of this Application. If the StatusCallback
// parameter above is also passed, the Application's SmsStatusCallback parameter
// will take precedence.
The callback url will be the same across all accounts so I don't need/care about that value.
Short Version:
If I log in with my Master Account details but pass the subaccount SID in the SendSmsMessage() method, which account does the message come from?
Twilio support finally got back to me and confirmed my fears that this wouldn't work. I do have to pull the subaccount information down and reinstantiate the twilioRestClient with the new credentials which I was hoping I could get away with not doing. Just a few extra lines.
var twilio = new TwilioRestClient("Master SID", "Master Auth Token");
var subAccount = twilio.GetAccount("SubAccount SID");
var subAccountClient = new TwilioRestClient(subAccount.Sid, subAccount.AuthToken);
var response = subAccountClient.SendSmsMessage(sender, recipient.ConvertToE164Format(), message);
return response.Sid;

Categories

Resources