Skip to content

Instantly share code, notes, and snippets.

@mplacona
Created July 29, 2016 11:27
Show Gist options
  • Save mplacona/7837b7e681fb7af1a70f1b10a70390b6 to your computer and use it in GitHub Desktop.
Save mplacona/7837b7e681fb7af1a70f1b10a70390b6 to your computer and use it in GitHub Desktop.
using System;
using System.Globalization;
using System.Linq;
using System.Web.Mvc;
using Twilio;
using Twilio.TwiML;
using Twilio.TwiML.Mvc;
namespace TwilioBaseApp.Controllers
{
// PROMO
public class HomeController : TwilioController
{
// http://your_ngrok_url/SayHello
// Message
public ActionResult SayHello()
{
var twiml = new TwilioResponse();
return TwiML(twiml.Message("Thanks for coming in here's some <3 MKNET"));
}
// http://your_ngrok_url/Answer
public ActionResult Answer()
{
var twiml = new TwilioResponse();
return TwiML(twiml.DialConference("party room"));
//return TwiML(twiml.Say("Congratulations! You've just won a cool gift"));
}
// Get all telephone numbers (Distinct) & Initiate Call
public void CallBack()
{
var client = new TwilioRestClient(St.AccountSid, St.AuthToken);
var numbers = client.ListMessages("your_twilio_number").Messages.Select(m => m.From).Distinct();
foreach (var number in numbers)
{
client.InitiateOutboundCall("+your_twilio_number", number, "http://your_ngrok_url/Answer");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment