ballerinax/vonage.voice Ballerina library

1.5.2

Overview

The Vonage Voice API v1.3.6 connector(https://nexmo-api-specification.herokuapp.com/api/voice) OpenAPI specification. The Voice API lets you create outbound calls, control in-progress calls and get information about historical calls. More information about the Voice API can be found at https://developer.nexmo.com/voice/voice-api/overview.

Key Features

  • Programmatic access to create and manage resources via REST API
  • Access analytics, reports, and performance metrics
  • Manage user accounts and profiles
  • Secure authentication with API key or OAuth support

Prerequisites

Before using this connector in your Ballerina application, complete the following:

Quickstart

To use the Vonage Voice connector in your Ballerina application, update the .bal file as follows:

Step 1: Import connector

First, import the ballerinax/vonage.voice module into the Ballerina project.

Copy
import ballerinax/vonage.voice as vv;

Step 2: Create a new connector instance

You can initialize the client as follows. You can now provide the JWT obtained above in the configuration. Create a voice:ClientConfig with the JWT token obtained, and initialize the connector with it.

Copy
vv:ClientConfig config = {
    auth: {
        token: "JWT"
    }
}

vv:Client baseClient = check new Client(config);

Step 3: Invoke connector operation

  1. Now you can use the operations available within the connector. Note that they are in the form of remote operations.

    Following is an example on how to create an outbound call using the connector. You can now make a call from your own machine. Vonage will call you and read out a text-to-speech message.

    Create an outbound call

    Copy
    public function main() {
        vv:EndpointPhoneTo endpointPhoneTo = {
            'type: "phone", 
            number: "9477.....96"
        };
        vv:EndpointPhoneFrom endpointPhoneFrom = {
            'type: "phone", 
            number: "9477.....96"
        };
        vv:NCCO ncco = {
            action: "talk",
            text: "This is a text to speech call from Vonage"
        };
        vv:CreateCallRequestNcco payload = {
            to: [endpointPhoneTo],
            'from: endpointPhoneFrom,
            ncco: [ncco]
        };
        vv:CreateCallResponse|error response = baseClient->createCall(payload);
        if (response is vv:CreateCallResponse) {
            log:printInfo(response.toString());
        } else {
            log:printError(response.message());
        }
    }

    Following is an example on how to get details of your calls using the connector.

    Get details of your calls

    Copy
    public function main() {
        vv:GetCallsResponse|error response = baseClient->getCalls();
        if (response is vv:CreateCallResponse) {
            log:printInfo(response.toString());
        } else {
            log:printError(response.message());
        }
    }
  2. Use bal run command to compile and run the Ballerina program.

Import

import ballerinax/vonage.voice;Copy

Other versions

See more...

Metadata

Released date: 3 days ago

Version: 1.5.2

License: Apache-2.0


Compatibility

Platform: any

Ballerina version: 2201.8.0

GraalVM compatible: Yes


Pull count

Total: 25

Current verison: 0


Weekly downloads


Source repository


Keywords

Type/Connector

Vendor/Vonage

Area/Communication

Communication/Call & SMS

Cost/Paid


Contributors