• Stars
    star
    22
  • Rank 1,048,934 (Top 21 %)
  • Language
    C#
  • License
    MIT License
  • Created over 12 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A .NET SDK to make voice calls & send SMS using Plivo and to generate Plivo XML

plivo-dotnet

UnitTest

The Plivo .NET SDK makes it simpler to integrate communications into your .NET applications using the Plivo REST API. Using the SDK, you will be able to make voice calls, send SMS and generate Plivo XML to control your call flows.

Supported .NET versions: This SDK was written targeting at .NET Standard 1.3 & .NET Standard 2.0, and thus works with .NET Framework 4.6+ and .NET Core 1.0+. Check here to know about all the other supported platforms.

Installation

You can install this SDK either by referencing the .dll file or using NuGet.

Use the following line to install the latest SDK using the NuGet CLI.

PM> Install-Package Plivo -Version 5.43.2

You can also use the .NET CLI to install this package as follows

> dotnet add package Plivo --version 5.43.2

Getting started

Authentication

To make the API requests, you need to create a PlivoApi instance and provide it with authentication credentials (which can be found at https://manage.plivo.com/dashboard/).

var api = new PlivoApi("<auth_id>", "<auth_token>");

The Basics

The SDK uses consistent interfaces to create, retrieve, update, delete and list resources. The pattern followed is as follows:

api.Resource.Create(params);
api.Resource.Get(params);
api.Resource.Update(identifier, params);
api.Resource.Delete(identifier);
api.Resource.List();

Using api.Resource.List() would list the first 20 resources by default (which is the first page, with limit as 20, and offset as 0). To get more, you will have to use limit and offset to get the second page of resources.

Examples

Send a message

internal class Program
{
    public static void Main(string[] args)
    {
        var api = new PlivoApi("<auth_id>", "<auth_token>");
        var response = api.Message.Create(
            src:"14156667778",
            dst:"14156667777",
            text:"Hello, this is a sample text from Plivo"
        );
        Console.WriteLine(response);
    }
}

Make a call

internal class Program
{
    public static void Main(string[] args)
    {
        var api = new PlivoApi("<auth_id>", "<auth_token>");
        var response = api.Call.Create(
            to:new List<String>{"the_to_number"},
            from:"the_from_number",
            answerMethod:"GET",
            answerUrl:"https://answer.url"
        );
        Console.WriteLine(response);
    }
}

Lookup a number

internal class Program
{
    public static void Main(string[] args)
    {
        var api = new PlivoApi("<auth_id>", "<auth_token>");
        var response = api.Lookup.Get("phone_number_here");
        Console.WriteLine(response);
    }
}

Generate Plivo XML

class MainClass
{
    public static void Main(string[] args)
    {
        Plivo.XML.Response response = new Plivo.XML.Response();
        response.AddSpeak("Hello, world!",
                          new Dictionary<string, string>() { });
        Console.WriteLine(response.ToString());
    }
}

This generates the following XML:

<Response>
  <Speak>Hello, world!</Speak>
</Response>

More examples

Refer to the Plivo API Reference for more examples.

Reporting issues

Report any feedback or problems with this version by opening an issue on Github.

Local Development

Note: Requires latest versions of Docker & Docker-Compose. If you're on MacOS, ensure Docker Desktop is running.

  1. Export the following environment variables in your host machine:
export PLIVO_AUTH_ID=<your_auth_id>
export PLIVO_AUTH_TOKEN=<your_auth_token>
export PLIVO_API_DEV_HOST=<plivoapi_dev_endpoint>
export PLIVO_API_PROD_HOST=<plivoapi_public_endpoint>
  1. Run make build. This will create a docker container in which the sdk will be setup and dependencies will be installed.

The entrypoint of the docker container will be the setup_sdk.sh script. The script will handle all the necessary changes required for local development. It will also package the sdk and reinstall it as a dependecy for the test program.

  1. The above command will print the docker container id (and instructions to connect to it) to stdout.
  2. The testing code can be added to <sdk_dir_path>/dotnet-sdk-test/Program.cs in host
    (or /usr/src/app/dotnet-sdk-test/Program.cs in container)
  3. The sdk directory will be mounted as a volume in the container. So any changes in the sdk code will also be reflected inside the container. However, when any change is made, the dependencies for the test program need to be re-installed. To do that:
    • Either restart the docker container
    • Or Run the setup_sdk.sh script
  4. To run test code, run make run CONTAINER=<cont_id> in host.

<cont_id> is the docker container id created in 2. (The docker container should be running)

Test code can also be run within the container using make run. (CONTAINER argument should be omitted when running from the container)

More Repositories

1

voicechat

VoiceChat is a set of APIs to create conference rooms on the fly to be used in the browser. Its built using the Plivo WebSDK and APIs.
JavaScript
818
star
2

plivoframework

Open Source Telephony Application Prototyping Framework
Python
416
star
3

sharq-server

A flexible rate limited queueing system
Python
160
star
4

plivo-php

Plivo PHP Helper Library
PHP
110
star
5

plivo-node

A Node library for communicating with the Plivo API and generating Plivo XML.
JavaScript
98
star
6

plivo-python

A Python library for communicating with the Plivo API and generating Plivo XML.
Python
64
star
7

sharq

The core SHARQ Library that powers SHARQ Server
Python
50
star
8

plivo-ruby

Plivo Ruby Helper Library
Ruby
49
star
9

plivo-examples-php

PHP
40
star
10

plivo-java

Plivo Java helper Library
Java
35
star
11

plivo-go

A Go SDK to make voice calls & send SMS using Plivo and to generate Plivo XML
Go
32
star
12

plivo-browser-sdk2-examples

Example app for the Plivo Browser SDK v2
JavaScript
29
star
13

plivo-examples-node

Plivo node.js examples
JavaScript
27
star
14

plivo-examples-ruby

Ruby
26
star
15

plivo-examples-python

Python
21
star
16

directdial

Direct Dial application
C#
18
star
17

opsworks

The missing OpsWorks CLI
JavaScript
18
star
18

actions-sms

Plivo github actions
TypeScript
13
star
19

plivo-ios-sdk2-examples

Examples for the IOS SDK version 2
Objective-C
10
star
20

plivo-examples-java

Examples of how to use the plivo-java helper at http://www.github.com/plivo/plivo-java
Java
9
star
21

plivo-android-sdk2-examples

plivo-android-sdk2-examples
Java
7
star
22

plivo-examples-dotnet

Plivo DotNet examples
C#
6
star
23

phone-ivr-python

Build a phone tree using Plivo. This is a Flask application to create a phone tree.
Python
6
star
24

easytrunk

Python
4
star
25

apps

Applications for Plivo Cloud
Python
4
star
26

click2call-webRTC

JavaScript
4
star
27

phone-tts-python

Build a text to speech application using Plivo in Python.
Python
3
star
28

Plivo-Browser-SDK-v2

JavaScript
3
star
29

plivoaskme

Slack Q&A bot enhanced with OpenAI
Python
3
star
30

plivo-ios-quickstart-app

Swift
3
star
31

plivo-android-quickstart-app

Java
2
star
32

2fa-node-demo

CSS
2
star
33

plivo-salesforce

Apex
2
star
34

PlivoVoiceKit-ios

Swift
2
star
35

plivo-salesforce-example

A complete Salesforce demo showing how to use the Plivo Salesforce helper library to make calls and send text messages from within Salesforce.
Apex
2
star
36

2fa-python-demo

CSS
2
star
37

django-admin-multi-flexselect

2
star
38

2fa-php-demo

CSS
2
star
39

django-recaptcha

Captcha Field/Widget for Django
Python
1
star
40

django-registration

Django Registration package
Python
1
star
41

sharq-client

SharQ Client
Python
1
star
42

actions-call

Plivo GitHub Actions to make a phone call
TypeScript
1
star
43

browser-check

JavaScript
1
star
44

zookeeper-docker

Run zookeeper cluster with Docker
Python
1
star