1

I'm following the example here: https://www.twilio.com/docs/quickstart/csharp/twiml/greet-caller-by-name

Although I've set it up slightly differently. Rather than code it directly in the cshtml I have a controller action reading from my database to retrieve the name of the person with the mobile number passed in. Anyway....

When I phone my Twilio number, I've set it up (the automated voicemail) to POST to a webpage I've specified (https://www.XXX.co.uk/Twilio/Voicemail) and say "Hi [user name]" as opposed to "Hi there" (if it can't find a user). However it currently doesn't find the user because the parameter ("FROM") doesn't get POSTed successfully.

If I manually post using Fiddler and specify: Content-Type: application/x-www-form-urlencoded

in the request, it works. If I take this out, it doesn't work (so i assume Twilio doesn't include this when POSTing?). My action signature looks like this:

[HttpPost] public ActionResult Voicemail(FormCollection collection) {

And I'm tracing 'collection'.

Any advice?

Thanks.

UPDATE

I've also tried with: public ActionResult Voicemail(VoiceRequest request) { string mobileNumber = request.From;

but I still don't get the POSTed values.

Captain_Planet
  • 1,228
  • 1
  • 12
  • 28
  • Are you sure you've configured the webhook to do a POST and not a GET? – Marcos Placona Aug 18 '16 at 16:15
  • Yes, definately set to POST. I've also tried using VoiceRequest instead of FormCollection but still the same. (I've tried editing my original post and adding the code) – Captain_Planet Aug 19 '16 at 07:22
  • One thing I DON'T do (mentioned here: https://www.twilio.com/docs/libraries/csharp/creating-aspnet-mvc-webhook-project) is inherit TwilioController in my class ( : TwilioController). Not sure if that would make any difference tbh, and I'm away from my dev machine at the moment. – Captain_Planet Aug 19 '16 at 07:24
  • I need to retest it this evening - i think one of my attempts worked (according to my logs), and the reason i didn't get the correct message response was because the POST mobile number is (+4477xxxx) and I store it in myb database as (077xxxx) so they didn't match up.... – Captain_Planet Aug 19 '16 at 07:56
  • That is a very real possibility. All the numbers come in with their country codes. – Marcos Placona Aug 19 '16 at 18:54
  • 1
    Thanks Marcos. Just to confirm, FormCollection did NOT work. VoiceRequest DID work. And i then needed to check the number properly due to the request prepending +44. Thanks for the help. – Captain_Planet Aug 20 '16 at 12:13

1 Answers1

0

Answered above in comments:

One thing I DON'T do (mentioned here: https://www.twilio.com/docs/libraries/csharp/creating-aspnet-mvc-webhook-project) is inherit TwilioController in my class : TwilioController. Not sure if that would make any difference tbh, and I'm away from my dev machine at the moment.

I need to retest it this evening - i think one of my attempts worked (according to my logs), and the reason i didn't get the correct message response was because the POST mobile number is (+4477xxxx) and I store it in myb database as (077xxxx) so they didn't match up

Just to confirm, FormCollection did NOT work. VoiceRequest DID work. And i then needed to check the number properly due to the request prepending +44 country code.

Megan Speir
  • 3,745
  • 1
  • 15
  • 25