Twilio "click to call" C# - c#

Here's my scenario - a user enters his phone number and the number of the person he wants to call.
Via c# Twilio calls the user number then connects to the person he wants to call. I then record the conversation.
I can get it all working and recording for a single phone number.
However, when trying to connect to a second number (the first number does ring, but I get the standard Twilio "application error"), I get the following 502 error:
Twilio was unable to fetch content from: https://xxx.xxx.net/Call/Connect?recipientNumber={number}
Error: Error reading response: Response does not contain content type
Account SID: xxxxxxxxxxxxxxxxxxxxxxxx
SID: xxxxxxxxxxxxxxxxxxxxxx
Request ID: xxxxxxxxxxxxxxxxxxxxx
Remote Host: xxx.xxx.net
Request Method: POST
Request URI: https://xxx.xxx.net/Call/Connect?recipientNumber={number}
SSL Version: TLSv1.2
This stems from basic code:
var response = new VoiceResponse();
response.Say("We are about to connect you.").Dial(recipientNumber).Hangup();
return TwiML(response);
Can anyone advise on where I'm going wrong or what I'm missing?

Turns out it was a conflict of versioning and/or DLL's - removed nuget Twilio package and manually added Twilio DLL's. Problem solved!!!

Related

"Operation returned an invalid status code 'Forbidden'" error on LUIS call

I am getting this error on LUIS call:
"Operation returned an invalid status code 'Forbidden'"
Out of call volume quota. Quota will be replenished in 4.05:29:12.
Your authoring/starter key is only allowed 1000 endpoint queries a month and you have hit the maximum amounts of requests for your LUIS starter key. You need to create a LUIS subscription key (free or paid) and use that key when making endpoint queries. If you are making endpoint queries from a bot or another client application, you need to change the LUIS endpoint key there.

Twilio MessagingResponse not working with csharp DLL 5.16.2

I recently upgraded the Twilio C# DLL we've been using to handle SMS messages. We are now on Twilio.DLL v5.16.2. I have a webhook set up to call a custom URL on our website. That part is working, because I can log the Request coming in (message SID and body and all that good stuff). At the end, we have code to instantiate a MessagingResponse object to send back a confirmation that the message was received. That's not working anymore. I don't get a SMS message on my phone nor do I see an Outgoing API record on the SMS logs page when I'm logged into my project on Twilio.com (whereas I do see the test message I've sent to our number as an Incoming message).
There is no error or exception either.
Any idea how to debug/solve this?
string responseTxt = "TESTING: Got it. Thanks.";
var smsResponse = new MessagingResponse();
var smsMsg = smsResponse.Message(responseTxt);
response.Write(smsMsg);
Twilio developer evangelist here.
I'm not a C# developer, so forgive me if I'm wrong. Also, I don't know what happened with this change.
Anyway, from what I can see, the message body when using the MessagingResponse's Message method appears to be a named argument now. Changing your code to the following should work for the latest version of the DLL.
var smsMsg = smsResponse.Message(body: responseTxt);
Let me know if that helps.
I'm not sure there's much to update as the exact same scenario still stands. But I can reiterate to see if this provides any additional clues.
We have a Twilio SMS service set up. There is a webhook assigned to our number that maps to an HTTP Handler on an ASP.NET website. The code in the handler logs in our database the fact that an SMS message was received and various bits of info (from the Request.Form variables supplied by Twilio, From number, body of the message, num of media, etc.).
Then, the code "replies" to the original SMS sender using the MessagingResponse object. See original code snippet. Really couldn't be much simpler.
Note, this is and has all been working quite well, using the Twilio c# helper library 5.6.
I upgraded the Twilio library to the latest rev (5.25.1) and its dependencies. Copied the new DLLs to our dev webserver. Now the reply message, using the MessagingResponse object, never occurs. The webhook is still called as I can see the new record in the database logging the message details. Just no response. No error, no exception. Just nothing.
If I rollback to our old version of the Twilio library (and its dependencies, thank goodness for Git!), it works again.

Paypal Payments - 500 Error

I am trying to make a automatic payment in my system, and got it to work perfectly in sandbox mode. As soon, as I switch to live mode I am receiving a 500 error. I am not sure if maybe the URL's I've copied are maybe from a legacy site or something.
Here is my params:
My post back error looks like:
{"ClassName":"PayPal.Exception.HttpException","Message":"The remote server returned an error: (500) Internal Server Error.","Data":null,"InnerException":null,"HelpURL":null,"StackTraceString":" at PayPal.HttpConnection.Execute(String payLoad, HttpWebRequest httpRequest)\r\n at PayPal.APIService.MakeRequestUsing(IAPICallPreHandler apiCallHandler)\r\n at PayPal.BasePayPalService.Call(IAPICallPreHandler apiCallHandler)\r\n at PayPal.AdaptivePayments.AdaptivePaymentsService.Pay(PayRequest payRequest, String apiUserName)\r\n at Cashbackeroo.Payment.PayPal.PayPalPaymentService.Pay(PaymentRequest paymentRequest)","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":"8\nExecute\nPayPalCoreSDK, Version=1.7.1.0, Culture=neutral, PublicKeyToken=5b4afc1ccaef40fb\nPayPal.HttpConnection\nSystem.String Execute(System.String, System.Net.HttpWebRequest)","HResult":-2146233088,"Source":"PayPalCoreSDK","WatsonBuckets":null}
Adaptive Accounts
The Adaptive Accounts API allows you to create and manage PayPal accounts for PayPal users. To make an API call, see Adaptive Accounts API call headers and endpoints.
Adaptive Accounts endpoints
To make Adaptive Accounts API calls. include an AppID with your API credentials.
For sandbox testing, specify an AppID of APP-80W284485P519543T.
API
Formats
Endpoints
Adaptive Accounts
SOAP with XML,
NVP, or JSON
Live
https://svcs.paypal.com/AdaptiveAccounts/
Sandbox
https://svcs.sandbox.paypal.com/AdaptiveAccounts/
Try to open the Paypal URL dirrectly in your browser. Does it returns a 500 server error or 200 ok?
Usually when the Paypal servers are down, the response is 500 server error.

How to fetch the messaging of linkedin user

I wanted to fetch the messages that was sent to the other connected linkedin users.
I found a code sample to send the message in this site
https://developer.linkedin.com/documents/sample-code-sending-message
But, I did not any sample to fetch the messages.
However, when I tried to fetch the message with the query "/people/~/mailbox", I got the error
"The remote server returned an error: (403) Forbidden."
In detail error message, I got "Access to mailbox denied".
These 2 documentations has listed only the Primary Endpoints "POST /people/~/mailbox" but has not mentioned about GET.
https://developer.linkedin.com/oauth-10a-overview
https://developer.linkedin.com/documents/authentication#oauth2-redirect-uri
Is there any way to fetch the message? Or Is there any workaround?
Any insights or help will be highly appreciated.
Thanks
I don't think Linkedin Inbox is supported any longer through their API. As per this answer on quora,
API is not publicly available but has been made available to several
partners. The best thing to do is contact LinkedIn's BD team for
access.
I was not able to see any specific mention to this type of access in their documentation.
Furthermore, check out APIGEE Snapshot for LinkedIn's 3 main API categories

Can I receive SMS status without a URL in Twilio API?

This question relates to Twilio and the API for it (C#).
I do not have a website nor a web application, just a need to send SMS notifications to my own private mobile when something happens on a server (NOT a webserver). I have already, successfully, sent SMS to my mobile from a C# dll. I want to check the status of the message. All the references imply website/web application use cases, and getting the status using a URL.
How do I do this in C#? Is there an example of the suggestion made here? No PHP or other web servery technology.
The solution I found, was ridiculously simple. The suggestion (made here) was to hang on to the message id. I discovered the GetSMSMessage method on TwilioRestClient. So querying message status some time after sending will give you the updated status.
By the way, the one thing you'll want to watch out for is that if you query the API too soon, you might get a status of "queued" or "sending" rather than "sent" or "failed", so be sure that your logic is set up to handle these other possible responses.
Also good to keep in mind that if you try to send more than 1 message per-second via a Twilio phone number, Twilio will queue the excess messages and release them at a rate of 1 message per-second per-number. This comes into play because if you have a burst where you send 10 messages in 1 second, but then you go to retrieve the status of the messages after 5 seconds half of the messages will be "sent" and half will be "queued".
If you dont have a callback url. Just call the method
TwilioClient.Init(accountSid, authToken);
var message = MessageResource.Create(
body: "Join Earth's mightiest heroes. Like Kevin Bacon.",
from: new Twilio.Types.PhoneNumber(fromNumber),
to: new Twilio.Types.PhoneNumber(toNumber)
);
Console.WriteLine(message.Sid);
//Get the status from twilio
TwilioClient.Init(accountSid, authToken);
var verificationCheck = MessageResource.Fetch(message.Sid);
Console.WriteLine(verificationCheck.Status);
where Sid is the id you get back from Twilio.

Categories