New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

africastalking-client

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

africastalking-client

AfricasTalking voice client SDK

  • 1.0.7
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
113
decreased by-25.66%
Maintainers
1
Weekly downloads
 
Created
Source

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

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/africastalking-client@1.0.6/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.

ParametersDescription
username
String
Required
Your Africa’s Talking application username
clientName
String
Required
Your unique name used to identify and call your browser client(without space characters)
phoneNumber
String
Required
Your Africa’s Talking phone number (in international format i.e. +254XXXYYY)
incoming
Boolean
Optional
Enable the client to recieve incoming calls. Defaults to true
outgoing
Boolean
Optional
Enable the client to make outgoing calls. Defaults to true
expire
String
Optional
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
EventsDescription
readyClient is ready to make or recieve calls
notreadyClient cant make or recieve calls,
callingYour client is making a call
incomingcallYour client is recieving a call
callacceptedCall has been accepted
hangupCall has ended
offlineToken has expired
closedConnection to africastalking servers closed

Methods

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

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

$("button").click(function() { 
    client.muteAudio(); 
}); 
Client Methods
methodsDescription
callMake a call to a phone number or browser client
answerAnswer a call
hangupEnd an ongoing call
dtmfpass dtmf digits to Africastalking API
muteAudioDisables audio media sent during a call
unmuteAudioEnable audio media sent during a call
holdPuts a call on-hold
unholdResumes a call

Keywords

FAQs

Package last updated on 08 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc