ballerinax/twilio Ballerina library

2.1.0

Overview

The Twilio API provides capability to access its platform for communications. These APIs connects the software layer and communications networks around the world to allow users to call and message anyone, globally.

This module supports Twilio Basic API version 2010-04-01.

Prerequisites

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

  1. Create a Twilio account.

  2. Obtain a Twilio phone number.

!!! Tip

If you use a trail account, you may need to verify your recipient phone numbers before having any communication with them.

  1. Obtain a Twilio Account Auth Token.

  2. If you want to use WhatsApp service, Configure your Twilio phone number to use WhatsApp services. For instructions, see Twilio Documentation - Manage and Configure Your WhatsApp-enabled Twilio Numbers.

  3. Configure the connector with obtained tokens.

Quickstart

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

Step 1 - Import connector

Import the Twilio module to your Ballerina program as follows. You can use configurable variables to provide the necessary credentials.

Copy
import ballerinax/twilio;

Step 2 - Create a new connector instance

To create a new connector instance, add a configuration as follows:

Copy
configurable string accountSId = ?;
configurable string authToken = ?;

twilio:ConnectionConfig twilioConfig = {
    auth: {
        accountSId: accountSId,
        authToken: authToken
    }
};

twilio:Client twilioClient = new (twilioConfig);

Step 3 - Invoke connector operation

  1. Invoke the connector operation using the client as follows:
Copy
public function main() returns error? {
    twilio:Account response = check twilioClient->getAccountDetails();
}
  1. Use bal run command to compile and run the Ballerina program.

You can find more samples here

Import

import ballerinax/twilio;Copy

Metadata

Released date: over 2 years ago

Version: 2.1.0

License: Apache-2.0


Compatibility

Platform: java11

Ballerina version: slbeta6


Pull count

Total: 1602852

Current verison: 610


Weekly downloads


Source repository


Keywords

Communication/Phone & SMS

Cost/Paid


Contributors

Other versions

See more...