0

We have a fairly sophisticated Flow (called Messaging Flow) set up in Twilio Studio. We are able to assign that Flow to a number's "A MESSAGE COMES IN" action using the Twilio web app: Set Studio Flow

How can the same be accomplished using the Twilio Studio REST Api?

I've poured over the docs and I can't find it, and Google is coming up short.

A code sample using the Twilio c#/.Net helper library would be fantastic.

Thanks!

agileMike
  • 453
  • 3
  • 14

1 Answers1

1

This is absolutely possible and can be done via the incomingPhoneNumbers Object. You would set the voiceURL property to the "webhook" URL of the studio flow.

// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;


class Program
{
    static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var incomingPhoneNumber = IncomingPhoneNumberResource.Update(
            voiceUrl: new Uri("https://www.your-new-voice-url.com/example"),
            pathSid: "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(incomingPhoneNumber.FriendlyName);
    }
}

See also the documentation.

tripleee
  • 175,061
  • 34
  • 275
  • 318
Matthew
  • 51
  • 1
  • Thanks, I've accepted this as the answer, but I wanted to respond to incoming sms messages and so used smsUrl instead of voiceUrl. – agileMike Jan 20 '22 at 01:07