npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

africastalking-client

v1.0.7

Published

AfricasTalking voice client SDK

Downloads

760

Readme

AfricasTalking Client SDK

Provides convenient access to the Africa's Talking Voice APIs from your web apps.

Documentation

Take a look at the API docs here.

Install

NPM (Recommended)

You can install the package from npm by running:

$ npm install --save africastalking-client

You can import the method like so:

import Africastalking from 'africastalking-client'

CDN

The SDK is also accessible via our hosted cdn which can be included into your web page using the <script> tag

<script src="https://unpkg.com/[email protected]/build/africastalking.js"></script>

You can access the global variable Africastalking from your browser.

Capability Token

You need to instantiate your client with a capability token. It is generated by making an API POST request from to https://webrtc.africastalking.com/capability-token/request with the following parameters:

Request Parameters

NB: API requests require an apiKey in your request header for authentication.

| Parameters | Description | |----------|------------------| | usernameStringRequired | Your Africa’s Talking application username | | clientNameStringRequired | Your unique name used to identify and call your browser client(without space characters) | | phoneNumberStringRequired | Your Africa’s Talking phone number (in international format i.e. +254XXXYYY) | | incomingBooleanOptional | Enable the client to recieve incoming calls. Defaults to true | | outgoingBooleanOptional | Enable the client to make outgoing calls. Defaults to true | | expireStringOptional | Period of time it takes the token to expire, in seconds. Default is 86400s |

API Response

{
    "clientName": "somsom",
    "incoming": true,
    "lifeTimeSec": "86400",
    "outgoing": true,
    "token": "ATCAPtkn_206675b68efaff83d1ac2d027dd5bff18fd7cb64fgjhd5d0bdcsac44a883678afe7"
}

Usage

You can then initialize the client using the token.

const client = new Africastalking.Client(token)

Events

client.on('incomingcall', function (params) {
    alert(`${params.from} is calling you`)
}, false);

client.on('hangup', function (hangupCause) {
    alert(`Call hung up (${hangupCause.code} - ${hangupCause.reason})`)
}, false);

Event Types

| Events | Description | |----------|------------------| | ready | Client is ready to make or recieve calls | | notready | Client cant make or recieve calls, | | calling | Your client is making a call | | incomingcall | Your client is recieving a call | | callaccepted | Call has been accepted | | hangup | Call has ended | | offline | Token has expired | | closed | Connection to africastalking servers closed |

Methods

$("button").click(function() { 
    client.call("+254XXXXXYYY"); 
}); 

$("button").click(function() { 
    client.dtmf("1"); 
}); 

$("button").click(function() { 
    client.muteAudio(); 
}); 

Client Methods

| methods | Description | |----------|------------------| | call | Make a call to a phone number or browser client | | answer | Answer a call | | hangup | End an ongoing call | | dtmf | pass dtmf digits to Africastalking API | | muteAudio | Disables audio media sent during a call | | unmuteAudio | Enable audio media sent during a call | | hold | Puts a call on-hold | | unhold | Resumes a call |