I put the twilio call on hold by following snippet
var twilio = new TwilioRestClient(Settings.AccountSid, Settings.AuthToken);
twilio.RedirectCall(callSid, Settings.HoldMusic, "GET");
But i want to retrieve the holded call back.. Can you please any one help me with code snippet
It sounds to me like what you'd like to achieve is tracking the status of a call that is on hold as described in this FAQ.
You can use the StatusCallbackEvent parameter on outbound calls made via the REST API. If you're indeed using the C# helper library it would look something like this:
var options = new CallOptions();
options.Url = "http://demo.twilio.com/docs/voice.xml";
options.From = "+18668675309";
options.Method = "GET";
options.StatusCallback = "https://www.myapp.com/events";
options.StatusCallbackMethod = "POST";
options.StatusCallbackEvents = new string[] { "initiated", "ringing", "answered", "completed" };
Also, depending on your use case, there is now a dedicated Hold feature available when using <Conference> as detailed in this post.
Related
Given the response on batching given in this StackOverflow question at Can I add multiple events to a calendar?
It's not clear how to use the C# SDK to and pass parameters into the requests. The examples I see are about retrieving data via batch, but I don't see a clear way to pass parameters in.
My previous code (before patch), I would just call AddAsync or UpdateAsync on the Request() method. But with batch, I can't have those Add/Update methods. So this was my code:
await _graphClient.Me.Calendars[_calendarID].Events
.Request()
.AddAsync(#event);
But I don't see a clear why to add the updated event object to the calendar. How to pass in the parameter correctly?
var batch = new BatchRequestContent();
// The response given is a GET METHOD
var request = _graphClient.Me.Calendars[_calendarID].Events
.Request()
.GetHttpRequestMessage();
// UPDATE the request to POST along with data in content
// (Am I wrong here in doing it this way?)
request.Method = HttpMethod.Post;
request.Content = new StringContent(JsonConvert.SerializeObject(#event));
batch.AddBatchRequestStep(request);
var response = await _graphClient.Batch.Request().PostAsync(batch);
The above code also doesn't like the JSON that it's given into the request.Content property. Please do let me know what is the correct way to supply data to the request, and if I'm completely wrong on writing a post. Thank you!
OK, solved it! Realized that I had to change the HttpMethod to Patch but there was no enumeration rather you had to explicitly set it with a string.
var batch = new BatchRequestContent();
var serializer = new Microsoft.Graph.Serializer();
Code to ADD an Event though a batch:
var request = this.GraphClient.Me.Calendars[_calendarID].Events
.Request()
.GetHttpRequestMessage();
request.Method = HttpMethod.Post;
request.Content = serializer.SerializeAsJsonContent(outlookEvent);
batch.AddBatchRequestStep(request);
Code to UPDATE an Event through a batch:
var request = this.GraphClient.Me.Calendars[_calendarID].Events[outlookEvent.Id]
.Request()
.GetHttpRequestMessage();
request.Method = new HttpMethod("PATCH");
request.Content = serializer.SerializeAsJsonContent(outlookEvent);
batch.AddBatchRequestStep(request);
Once you've added all your adds and updates, you can just call
await this.GraphClient.Batch.Request().PostAsync(batch);
You are mostly on the right path.
Instead of using the direct JsonConvert.SerializeObject, you should create an instance of the Microsoft.Graph.Serializer class and use that to do the serialization. It is configured to create JSON objects that are compatible with Microsoft Graph.
How to call to a phone number using Twilio.Device?
I am doing the click to call feature for my widget.
I am able to get the Capability token required in setting up the Twilio.Device. I am able also to connect the Twilio.Device to twilio by setup function provided in client javascript library.
What can I use to call a number using Twilio.Device?
Its been a while since I played with it, but looking back at the code then once you have the token and are connected to Twilio it's just a case of setting the number you want to call and then initiating the call. Something like this:
document.getElementById('button-call').onclick = function () {
// get the phone number to connect the call to
var params = {
Caller: document.getElementById('phone-number').value
};
console.log('Calling ' + params.Caller + '...');
Twilio.Device.connect(params);
};
You have to make sure your token allows outgoing calls. My token.php file contains the following:
$capability = new ClientToken($TWILIO_ACCOUNT_SID, $TWILIO_AUTH_TOKEN, 'ttl=20');
$capability->allowClientOutgoing($TWILIO_TWIML_APP_SID);
$token = $capability->generateToken();
I think this is all fairly standard stuff from the quickstart files. I only had a quick go with it, but I don't remember it being complicated. Have fun!
New to Google Apps Script, trying to retrieve data from a URL with UrlFetchApp.fetch but the URL length is limited to 2kB per call (https://developers.google.com/apps-script/guides/services/quotas).
Thus, with a long URL I get the error Limit Exceeded: URLFetch URL Length..
Example:
var url = 'http://www.longurlmaker.com/go?id=EXLVPCEEVMCJMZAHPCWLLUKQSDBNNSRSQDOGFTLAFNJRMJZCMVNYQXOIAQWOJOHZRVFXOQYTEHLRRKTEFGDVDSEEIBTRPARGVWDJNBDSJOJBYDG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XUFYUITGVGJOMDZMCOOQDXCEWJUOWPUTKZRFIKLDRVSDZRQBGERJCTOZDIOZYISJHKOPVATMVMQVDGWKLOUOIINLQBLPJEYROMHKNBWINNDRTABFPVTXEHJUIVKSZIKOVSYITVRHIVYCVAILVBJAITVROFJOOUCKMBTGXKNGGMICMRNISWIBPDTEJDSXXVHJXAPVLDBSPKUCBHKUETVUXOZGRRDPNLYLMOGYSHQHRKKTSUNXOJRLXQRPIVEWGDHTSNRKVHRNSBGKWTILDZXBQOQZKVVRYCKRPCBLJTYCVENSYVDBVACLPTKZPFROIBFYEGJNZHQUMDMKYQMTQPFFIQFYWWMEYRDCYMQXUGSGJFQIVDCLSHRBXWZUTMYRDBTCOKZIQSPAXGISJLDCSVDQRDKKPJCTLWVZGVIWNXXKDGCNRGPJBSATWLELUGEGCAGIVOFJMCTQIWDZDSJFLKYHVCSQIXWLYCTTRYCEBWUKTXKWQUBBEAIACBQLYNWWQPQIOTMQQGAJELFUFHWKHEKKFBVEORBFHRNWLZNBGOKLZQGFYCPGGAQMCMQQESWLKJIVIVXPJHAIYGOXIDDPEUCGGTXKLTWVCERLZOAJWBRVIFSRJWGNQJUWCRHOKDKNIBYIPZRMBJHJPZAYVHMMQGJTYQHIURVCSULITCUVLBEBBEAXLMJBTSURJCAETWHMQSVKVPFGRJISOIQZUZBOSWGCYHGSDOEUGZECPKJGURZIZPIUPJIIGPLEWSXAGCUNCZPRJYYDPYMOOUIDDRMKHXOEPMEVOZJQYYHHWGLMEXBSSKWWBIGJFVNUHSQVRZLQYTYVZJHDHIWZSSWUACEGXSBEKRZCRKSPEQKDASG'
var response = UrlFetchApp.fetch(url);
Is there any way I can get around this limit, maybe by using another library to make the GET request?
EDIT
Jack Brown's solution works well if I run the function from the script editor. In order to make the functionality accessible as a google-spreadsheets function, I used the following:
Using the UrlShortener API in a custom Spreadsheet function
You can use Url Shortener API to create a short URL and pass it to URLFetchApp like so:
function shortenUrl() {
var Lurl = 'http://www.longurlmaker.com/go?id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EARFQURNCWSZMYJYITWTGPPSMOTUCQLHRDMHYDUAANZNMJLUDHNJXCCKQVETLQADTNKSQFTRSTEECPYGXMQVPSFFNKZZAZCUMNNDSGULZYPCOOILAZHPRMVFXUFYUITGVGJOMDZMCOOQDXCEWJUOWPUTKZRFIKLDRVSDZRQBGERJCTOZDIOZYISJHKOPVATMVMQVDGWKLOUOIINLQBLPJEYROMHKNBWINNDRTABFPVTXEHJUIVKSZIKOVSYITVRHIVYCVAILVBJAITVROFJOOUCKMBTGXKNGGMICMRNISWIBPDTEJDSXXVHJXAPVLDBSPKUCBHKUETVUXOZGRRDPNLYLMOGYSHQHRKKTSUNXOJRLXQRPIVEWGDHTSNRKVHRNSBGKWTILDZXBQOQZKVVRYCKRPCBLJTYCVENSYVDBVACLPTKZPFROIBFYEGJNZHQUMDMKYQMTQPFFIQFYWWMEYRDCYMQXUGSGJFQIVDCLSHRBXWZUTMYRDBTCOKZIQSPAXGISJLDCSVDQRDKKPJCTLWVZGVIWNXXKDGCNRGPJBSATWLELUGEGCAGIVOFJMCTQIWDZDSJFLKYHVCSQIXWLYCTTRYCEBWUKTXKWQUBBEAIACBQLYNWWQPQIOTMQQGAJELFUFHWKHEKKFBVEORBFHRNWLZNBGOKLZQGFYCPGGAQMCMQQESWLKJIVIVXPJHAIYGOXIDDPEUCGGTXKLTWVCERLZOAJWBRVIFSRJWGNQJUWCRHOKDKNIBYIPZRMBJHJPZAYVHMMQGJTYQHIURVCSULITCUVLBEBBEAXLMJBTSURJCAETWHMQSVKVPFGRJISOIQZUZBOSWGCYHGSDOEUGZECPKJGURZIZPIUPJIIGPLEWSXAGCUNCZPRJYYDPYMOOUIDDRMKHXOEPMEVOZJQYYHHWGLMEXBSSKWWBIGJFVNUHSQVRZLQYTYVZJHDHIWZSSWUACEGXSBEKRZCRKSPEQKDASG'
var url = UrlShortener.Url.insert({
longUrl: Lurl
});
Logger.log('Shortened URL is "%s".', url.id);
var response = UrlFetchApp.fetch(url.id);
Logger.log(response)
}
Make sure you have selected URL shortener API under Resources>Advanced Google Services> URL shortener API v1 (set to on) and also enabled the same in developers console. For more details refer here
EDIT
Google shortener seems to have some issues with a certain type of URL. This is a more generalized solution. You can select different providers by modifying provider key in the payload below. More details can be found here
function shortenUrl(Lurl) {
if(Lurl == undefined){
var Lurl = 'http://www.longurlmaker.com/go?id=EXLVPCEEVMCJMZAHPCWLLUKQSDBNNSRSQDOGFTLAFNJRMJZCMVNYQXOIAQWOJOHZRVFXOQYTEHLRRKTEFGDVDSEEIBTRPARGVWDJNBDSJOJBYDGEJKANCFSKGLCVMTCHQFREHUWRIFTHIAMSKNGMSYXZKZUWTWEKCVOKPKCYPVGYWTRGHXTZWRYGRTCKPHUSCICSSFRIAYHXRYEYVXYROXYGQBQGILYKUBDMGUVHSCEKAJIWGHOVENBUOSBXDAHXBLKIFGQYIVIJERFLYUGCHIXVBZSFZACBMNJRTZPBUYLYPQKNLQQSZOOANHFMIINUWXLPWBRRACQPTADFRUXRIMSVTYIBHWWDTISQKKIKNZAHZDMRYJJGWBCPZKRHHNKAVDRFOZPBYQIYTUQREZYABAQBLHISVSTRWLWKKMLJCUIWOYOTYMUZNKAZSISOBMFXXCHIOTRRNANCYCVWPQWCBWCUFUIGHODEQLMFEEWSEKUDMQABGWEITHCYBLEIZINQTZVYERQJCLNPBNRIKVQDCTCEEGNEPAUIAPHFHXOJIBZKPQSAMJDOCGTHMGLCHGKIVRNDPCNYDMITCBTOKXDNDWVQDGSLMDTIVHLKJYJNLRGNSZBDWFRACMQFTIRFLKOHSARBZAOKSUXLUZOQEFQGRHMKPEQBOFIHFAIEBWOURMFLLUBQASXRZKCPOTRDZAKEBSJDPXXGKCRVXTMXMKPLUSBJLSNLSXPUQZXFXUMHXDDUXPRJAGVVYWEKORVHPLBFKYLHTXPQBSLZICIIJDDIZISOZOWOAYULXFSQDIHFASEIVMQEQUMQCFFCTBRTZLEXRXNVGVAGOFOJSFOIABYCGEFAFWUFHZCZXQUDMVJAAYJSEYBFZ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DPYMOOUIDDRMKHXOEPMEVOZJQYYHHWGLMEXBSSKWWBIGJFVNUHSQVRZLQYTYVZJHDHIWZSSWUACEGXSBEKRZCRKSPEQKDASG'
}
var payload = {
'apikey': 'your API Key', //Create a new Key here http://www.tiny-url.info/request_api_key.html
'provider' : 'tinyurl_com',
'format' : "text",
'url' : Lurl}
var options = {
'method':'POST',
'payload':payload
}
var url = "http://tiny-url.info/api/v1/create"
var response =UrlFetchApp.fetch(url, options)
var turl = response.getContentText()
Logger.log(turl)
response = UrlFetchApp.fetch(turl)
Logger.log(response)
}
Hope that helps!
On March 30, 2018, Google deprecated the URL Shortener service that was used in the accepted answer.
I wrote a script to use the Firebase Dynamic Links Short Links API service.
The docs are here if you want to cook your own.
twilio javascript client set from number , Also how I can get the call sid after connect?
I tried to set the from Number in the call options like the next lines before connect and still the same issue in the javascript
$(document).ready(function () {
Twilio.Device.setup(token);
var connection = null;
$("#call").click(function () {
var params = { "Phone": $('#Phone').val(), "from":$('#Phone').val() };
connection = Twilio.Device.connect(params);
return false;
});
});
-- and inside the server side code vbnet when I am generating the token I added the next code but this doesn't solve the from number issue
Dim options As New CallOptions()
options.Record = True
options.From = model.FromNumber
Dim cap = New TwilioCapability(_settings.AccountSID, _settings.AuthToken)
cap.AllowClientOutgoing(_settings.ClientCallApplicationSID, options)
dim token = cap.GenerateToken()
Twilio evangelist here.
The params collection that you pass into the connect function is just a dictionary of key/value pairs. Those key/values simply get passed as parameters to the Voice URL that Twilio requests when Client makes its connection to Twilio, and you can use those parameters to dynamically generate some TwiML markup. Twilio does not do anything with them.
For example, if this is a PHP application, in the Voice URL you could do something like:
<Response>
<Dial>$_REQUEST['From']</Dial>
</Response>
One note of caution, Twilio already adds a parameter called from (which in the case of Client will be the client identifier set when you made your capability token) to the parameters sent to the Voice URL, so you might want to choose a different key name for your dictionary entry. I normally use a name like target for the key that holds the number that I want to dial.
Hope that helps.
To get the call sid, you can get it in connect event.
Please note that I am using Twilio JS v1.9.7
device.on('connect', function (conn) {
log('Successfully established call!');
//Get the CallSid for this call
callUUID = conn.outboundConnectionId;
console.log('CallSid: ' + callUUID);
});
I am integrating the Carrier (USPS, UPS, DHL, FeDex) API with my application.
For that i need to find different statuses for that shipment like is it delivered or not, which is getting me properly.
Similarly, i need to check whether the shipment required the signature or not?
How do i came to know this using the different API?
Regards,
Salil Gaikwad
Not all APIs support the same functionality. All will tell you the current status and some will provide the shipper/recipient information but I don't believe any will tell you if it was sent signature required.
E.g. for FedEx if you want to know about parcel's tracking events (delivered or not, any problems, delivery time and many other info) use this service endpoint - https://ws.fedex.com:443/web-services/track. The request to FedEx will be look like this (C# sample):
TrackRequest request = new TrackRequest();
request.WebAuthenticationDetail = new WebAuthenticationDetail();
request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential()
{
Key = "ApiKey",
Password = "PasswordKey"
};
request.ClientDetail = new ClientDetail
{
AccountNumber = "...",
MeterNumber = "..."
};
request.TransactionDetail = new TransactionDetail();
request.PackageIdentifier = new TrackPackageIdentifier();
request.PackageIdentifier.Value = "parcel tracking number";
request.PackageIdentifier.Type = TrackIdentifierType.TRACKING_NUMBER_OR_DOORTAG;
request.IncludeDetailedScans = true;
request.IncludeDetailedScansSpecified = true;
request.Version = new VersionId();
When you receive from FedEx - TrackReply, you should check TrackDetails array. There will be tracking info. As for other carriers, the common idea is the same. Almost every carrier use tracking number.