.NET client library for Telerivet REST API
https://www.nuget.org/packages/Telerivet.NET/
This library makes it easy to integrate your .NET application with Telerivet. You can use it to:
- send SMS messages via an Android phone or SMS gateway service
- update contact information in Telerivet (e.g. from a signup form on your own website)
- add or remove contacts from groups
- export your message/contact data from Telerivet into your own systems
- schedule messages to be sent at a later time
- control automated services
- much more
All API methods are fully documented at https://telerivet.com/api/rest/dotnet , as well as in the comments of the C# source files.
.NET 6.0
To install the library, run the following command in the Package Manager Console in Visual Studio:
PM> Install-Package Telerivet.NET -Version 1.7.1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerivet.Client;
using Newtonsoft.Json.Linq;
namespace ExampleNamespace
{
public class ExampleClass
{
public async Task foo()
{
TelerivetAPI tr = new TelerivetAPI("YOUR_API_KEY");
Project project = tr.InitProjectById("PROJECT_ID");
// send message
Message sent_msg = await project.SendMessageAsync(Util.Options(
"content", "hello world",
"to_number", "+16505550123"
));
// import contact and add to group
Contact contact = await project.GetOrCreateContactAsync(Util.Options(
"name", "John Smith",
"phone_number", "5550123",
"vars", Util.Options("email", "[email protected]", "birthdate", "1953-01-04")
));
Group group = await project.GetOrCreateGroupAsync("Subscribers");
await contact.AddToGroupAsync(group);
// query contact information
String namePrefix = "John";
APICursor<Contact> query = project.QueryContacts(Util.Options(
"name", Util.Options("prefix", namePrefix),
"sort", "name"
));
int count = await query.CountAsync();
List<Contact> contacts = await query.Limit(50).AllAsync();
Console.WriteLine(count + " contacts matching " + namePrefix + ":");
foreach (Contact c in contacts)
{
Console.WriteLine(c.Name + " " + c.PhoneNumber + " " + c.Vars.Get("birthdate"));
}
}
}
}