Skip to main content

Dotnet development environment setup for Messaging

.Net dev environment setup

You'll need to ensure that you have DotNet installed on your computer. If DotNet (core or framework) isn’t installed, follow the official installation instructions for your operating system to install it. You can check this by running the following:

Telnyx targets the .NET Standard 2.0 . You should be running a supported verison of dotnet/Xamarin/Mono/Framework to leverage the SDK.

dotnet --version

Note: After pasting the above content, Kindly check and remove any new line added

Install the Telnyx.net SDK by running the following:

dotnet add package Telnyx.net

Note: After pasting the above content, Kindly check and remove any new line added

Check out the source on GitHub , or see Package on NuGet

Send Message Async Example

The C# SDK supports Task based API calls.

By updating the Main method to support async calls, we can build a quick example.

Demo below instanciates the Telnyx client

using System;
using Telnyx;
using System.Threading.Tasks;

namespace demo_dotnet_telnyx
{
class Program
{
private static string TELNYX_API_KEY = System.Environment.GetEnvironmentVariable("TELNYX_API_KEY");
static async Task Main(string[] args)
{
Console.WriteLine("Hello World!");
TelnyxConfiguration.SetApiKey(TELNYX_API_KEY);
MessagingSenderIdService service = new MessagingSenderIdService();
NewMessagingSenderId options = new NewMessagingSenderId
{
From = "+19198675309", // alphanumeric sender id
To = "+19198675310",
Text = "Hello, World!"
};
MessagingSenderId messageResponse = await service.CreateAsync(options);
Console.WriteLine(messageResponse.Id);
}
}
}

Note: After pasting the above content, Kindly check and remove any new line added

On this page