C#
Clone or download
jbonner89 and ekarson add OutboundPrefixPriceWithOrigin class (#441)
* add OutboundPrefixPriceWithOrigin class

* fix typo
Latest commit 5f777ce Aug 9, 2018
Permalink
Failed to load latest commit information.
src/Twilio add OutboundPrefixPriceWithOrigin class (#441) Aug 9, 2018
test/Twilio.Test [Librarian] Regenerated @ e337be13bc02c074a1c656e2fc59a42e0972e381 Aug 9, 2018
.gitattributes Instruct git to leave the line endings alone May 12, 2015
.gitignore Add Doxyfile Feb 23, 2017
.travis.yml Add Dockerfile and related changes to build the Docker image (#427) Jul 5, 2018
CHANGES.md [Librarian] Regenerated @ e337be13bc02c074a1c656e2fc59a42e0972e381 Aug 9, 2018
CONTRIBUTING.md Adding Beta and Preview products to main artifact Jul 27, 2017
Dockerfile Add Dockerfile and related changes to build the Docker image (#427) Jul 5, 2018
Doxyfile Add Doxyfile Feb 23, 2017
LICENSE.md [Librarian] Regenerated @ a4cb3dcc12627f0ab0fcc6104a6bed708e9375c4 Jan 22, 2018
Makefile Tag and push Docker latest image when deploying with TravisCI (#434) Jul 31, 2018
README.md Add Dockerfile and related changes to build the Docker image (#427) Jul 5, 2018
Twilio.sln Switch to netstandard1.4, make tests run on .NET 3.5 also Feb 13, 2017
UPGRADE.md Revert "Revert "Document Sync breaking change in 5.9.x (#398)"" (#400) Nov 17, 2017
VERSIONS.md [Librarian] Regenerated @ 61e059e9694883693c4919778c1e37947fdb3168 Jul 27, 2017
appveyor.yml Move artifact in build script Apr 14, 2017
build.ps1 Fix Exception Handling in SystemNetHttpClient + Unit test http clients ( Aug 25, 2017
issue_template.md [Librarian] Regenerated @ c1a7d536285c92cf710a2947929f704a27409602 Oct 20, 2017

README.md

Build status NuGet

Recent Update

As of release 5.6.0, Beta and Developer Preview products are now exposed via the main twilio-csharp artifact. Releases of the alpha branch have been discontinued.

If you were using the alpha release line, you should be able to switch back to the normal release line without issue.

If you were using the normal release line, you should now see several new product lines that were historically hidden from you due to their Beta or Developer Preview status. Such products are explicitly documented as Beta/Developer Preview both in the Twilio docs and console, as well as through in-line code documentation here in the library.

Twilio REST API and TwiML Libraries for .NET

Twilio provides a simple HTTP-based API for sending and receiving phone calls and text messages. Learn more at http://www.twilio.com

Adding Twilio libraries to your .NET project

The best and easiest way to add the Twilio libraries to your .NET project is to use the NuGet package manager.

With Visual Studio IDE

From within Visual Studio, you can use the NuGet GUI to search for and install the Twilio NuGet package. Or, as a shortcut, simply type the following command into the Package Manager Console:

Install-Package Twilio

With .NET Core Command Line Tools

If you are building with the .NET Core command line tools, then you can run the following command from within your project directory:

dotnet add package Twilio

Sample Usage

The examples below show how to have your application initiate and outbound phone call and send an SMS message using the Twilio .NET helper library:

TwilioClient.Init("ACCOUNT_SID", "AUTH_TOKEN");

var call = CallResource.Create(
    new PhoneNumber("+11234567890"),
    from: new PhoneNumber("+10987654321"),
    url: new Uri("https://my.twiml.here")
);
Console.WriteLine(call.Sid);

var message = MessageResource.Create(
    new PhoneNumber("+11234567890"),
    from: new PhoneNumber("+10987654321"),
    body: "Hello World!"
);
Console.WriteLine(message.Sid);

TwiML Generation

// TwiML classes can be created as standalone elements
var gather = new Gather(numDigits: 1, action: new Uri("hello-monkey-handle-key.cshtml"), method: HttpMethod.Post)
    .Say("To speak to a real monkey, press 1. Press 2 to record your own monkey howl. Press any other key to start over.");

// Attributes can be set directly on the object
gather.Timeout = 100;
gather.MaxSpeechTime = 200

// Arbitrary attributes can be set by calling set/getOption
var dial = new Dial().SetOption("myAttribute", 200)
                     .SetOption("newAttribute", false);

// Or can be created and attached to a response directly using helper methods
var response = new VoiceResponse()
    .Say("Hello Monkey")
    .Play(new Uri("http://demo.twilio.com/hellomonkey/monkey.mp3"))
    .Append(gather)
    .Append(dial);
    
// Serialize the TwiML objects to XML string
Console.WriteLine(response);

/*
<?xml version="1.0" encoding="utf-8"?>
<Response>
  <Say>Hello Monkey</Say>
  <Play>http://demo.twilio.com/hellomonkey/monkey.mp3</Play>
  <Gather numDigits="1" action="hello-monkey-handle-key.cshtml" method="POST" timeout="100" maxSpeechTime="200">
    <Say>To speak to a real monkey, press 1. Press 2 to record your own monkey howl. Press any other key to start over.</Say>
  </Gather>
  <Dial myAttribute="200" newAttribute="false"></Dial>
</Response>
*/

Migrating from earlier versions

See the migration guide here. Also, if you were using the Twilio.Mvc package, that has been replaced by the Twilio.AspNet.Mvc package which is compatible with this version of the library.

Alpha Version

The alpha version is no longer necessary. All Twilio products are available in the main-line library.

Docker Image

The Dockerfile present in this repository and its respective twilio/twilio-csharp Docker image are currently used by Twilio for testing purposes only.

Getting help

If you need help installing or using the library, please contact Twilio Support at help@twilio.com first. Twilio's Support staff are well-versed in all of the Twilio Helper Libraries, and usually reply within 24 hours.

If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!

Twilio REST API Documentation

Twilio TwiML Documentation