A Transmitly channel provider that enables sending SMS communications with Twilio
To use the Twilio channel provider, first install the NuGet package:
dotnet add package Transmitly.ChannelProvider.Twilio
Then add the channel provider using AddTwilioSupport()
:
using Transmitly;
//...
var communicationClient = new CommunicationsClientBuilder()
.AddTwilioSupport(options =>
{
options.AccountSid = "ACCOUNT_SID";
options.AuthToken = "AUTH_TOKEN";
})
//Pipelines are the heart of Transmitly. Pipelines allow you to define your communications
//as a domain action. This allows your domain code to stay agnostic to the details of how you
//may send out a transactional communication.
.AddPipeline("first-pipeline", pipeline =>
{
//AddSms is a Channel that is core to the Transmitly library.
//AsAudienceAddress() is also a convience method that helps us create an audience address
//Audience addresses can be anything, email, phone, or even a device/app Id for push notifications!
pipeline.AddSms(sms=>{
//Transmitly is a bit different. All of our communication content is configured by templates.
//Out of the box, we have static or string templates, file and even embedded template support.
//There are multiple types of templates to get you started. You can even create templates
//specific to certain cultures!
sms.Body.AddStringTemplate("Hey, check out Transmit.ly to manage your app communications!");
});
})
.BuildClient();
//Dispatch (send) the transactional sms to our friend Joe (888-555-1234) using our configured Twilio account and our "first-pipeline" pipeline.
var result = await communicationsClient.DispatchAsync("first-pipeline", "888-555-1234".AsAudienceAddress(), new { });
- See the Transmitly project for more details on what a channel provider is and how it can be configured.
Copyright © Code Impressions, LLC - Provided under the Apache License, Version 2.0.