Skip to content

Telerivet/telerivet-dotnet-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.NET client library for Telerivet REST API

http://telerivet.com/api

https://www.nuget.org/packages/Telerivet.NET/

Overview

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.

System Requirements

.NET 6.0

Installation

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

Example Usage

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"));
            }
        }
    }
}

About

.NET client library for Telerivet REST API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages