Why is my Twilio conference call responding like a voice call and hanging up?

157 Views Asked by At

In my proof of concept code, I am successfully creating a conference call and am able to enter the waiting room and hear the hold music until another participant joins. However, when I move this code into a .NET Core production type solution in visual studio, it responds by reading the Room # and immediately hanging up. I believe it has something to do with .NET Core but have not been able to pinpoint the root cause.

Proof of concept code

using Twilio.TwiML;
using Twilio.AspNet.Mvc;
using System.Web.Mvc;
using Twilio.TwiML.Voice;

namespace MakeAndReceiveCalls.Controllers
{
    public class PhoneController : TwilioController
    {
        [HttpPost]
        public ActionResult MakeConferenceCall()
        {
            var response = new VoiceResponse();
            var dial = new Dial();
            dial.Conference("Room 1234");
            response.Append(dial);

            return Content(response.ToString());
        }
    }
}

Production Code

using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Twilio.AspNet.Core;
using Twilio.TwiML;
using Twilio.TwiML.Voice;

namespace RL.Domain.AudioConference.API.Controllers
{
    [Route("v1/[Controller]")
    public class AudioConferenceController : TwilioController
    {       
        [HttpPost("MakeConferenceCall")]
        public ActionResult MakeConferenceCall()
        {
            var response = new VoiceResponse();
            var dial = new Dial();
            dial.Conference("Room 1234");
            response.Append(dial);

            return Content(response.ToString());
        }
    }
}
2

There are 2 best solutions below

0
On BEST ANSWER

Changing the return type from:

ActionResult
return Content(response.ToString());

To:

TwiMLResult
return TwiML(response);

Fixed the issue. Not sure why the first approach worked in my proof on concept.

1
On

Check your returned HTTP MIME type when you return TwiML.

https://www.twilio.com/docs/voice/twiml#twilio-understands-mime-types