Displaying Missed Calls In Twilio Call log - c#

I am implementing voice call feature using Twilio SDK in one of my application. I don't know how can I get the missed call logs in Twilio.
I am calling from my mobile to Twilio number. As soon as the client started ringing I have disconnected the call from my mobile and wanted to show that as Missed call in my call logs.
here the issue I am having is when I want to display the "missed call" it's not working. I see the call statuses but it seems like almost every call is being marked as "completed"
How can I get missed calls in Twilio call log
Please help if anyone had done this.

When you dile add two parameters
'action'=> "www:yourwebsite.com/your/url"
'method' => "GET"
This will submit a Get request to "www:yourwebsite.com/your/url"
if ($request->DialCallStatus == 'no-answer')
{
Call status = "You Missed a call from" . $request->number;
}

Related

Why does my Twilio MessagingResponse not work?

The following Twilio code doesn't work. This is my webhook handler in an ASP.NET (Core) 6.0 app.
[AllowAnonymous]
[HttpPost]
[Route("webhook-url")]
public IActionResult PostTwilioMessageReceived([FromForm] TwilioMessageReceivedFormModel formModel)
{
// logging code etc.
var response = new Twilio.TwiML.MessagingResponse();
response.AddText($"You sent '{formModel.Body}' but our systems are dumb and can't process this yet.");
return new TwiMLResult(response);
}
There are no errors. I don't receive the message, and my delivery status webhook doesn't appear to be called.
The method above is called as I see it in my logs.
Note - There is no "to" address. I have adapted sample code from Twilio's documentation which also does nothing to either read the sender address or configure the response with a recipient or other correlation ID.
https://www.twilio.com/docs/whatsapp/tutorial/send-and-receive-media-messages-whatsapp-csharp-aspnet#generate-twiml-in-your-application
I've modified my logging to make doubly sure my webhook is being called. It is. And in Twilio's log there's no acknowledgement of the reply my webhook attempts to produce.
To be clear, the code above is using Twilio's libraries.
The TwiML output of your application would be:
<Response>You sent '...' but our systems are dumb and can't process this yet.</Response>
Unfortunately, that isn't valid TwiML, instead it should look like this:
<Response>
<Message>You sent '...' but our systems are dumb and can't process this yet.</Message>
</Response>
This will respond with a message to the sender. To do this, use the .Message method instead of .AddText:
response.Message($"You sent '{formModel.Body}' but our systems are dumb and can't process this yet.");
Everything else looks fine in your code AFAIK.
Aside: If all you need to do is to respond to the current sender with a single message, you can also respond with plain text and the text/plain content type.
Edit by OP
I also changed the return line to:
return this.TwiML(response);
Which was the advice of Twilio support. I didn't try it my original way, but assumed that if there was some kind of magic that's pre-addressing the response, or correlating it in some way, then it might be in using the helper function on the base controller. Thanks.
It's hard to say what caused this without seeing an error or message log. You should be able to see something in the "Monitor" in the console (more details here).
I've had similar issues in the past with Node.js and the problem was there that I forgot to set the content-type of the response to text/xml. But I'm not sure if this is required in your C# code.

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.

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.

HTTP Status Code suddenly changed to 202 Method Accepted

I am using Rest web service that have 3 method (put , get , post) and im using c#.net.
When i publish in IIS 7,5, and im invoke the get method, what i got is method accepted 202.
It should be return status code 200 OK and the data what i want.
Is there anything wrong here ?
Method Accepted 202
That depends on what your API is set to respond with.
200 would be default but perhaps if it is expecting something else it is responding with a 202.
You have made a call but something is incorrect and processing may not have completed as expected.
Without knowing the API we cannot confirm what was wrong with your request or the processing of it.

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