sdk-nodejs
SDK in NodeJS for CALLR API For more examples see the the nodejs examples (https://github.com/THECALLR/examples-nodejs) repo.
Quick start
Install via NPM
npm install callr
Or get sources from Github
Authenticating for older SDK versions 1.x
- Please see the documentation here for how to authenticate using older
1.x
versions of the SDK.
Different methods of authentication
When you initialise the callr api object with your chosen authentication method, you can also pass in any options like the following:
var options = ...var callr = ;var api = <authentication method> options;...
Init with login and password
var callr = ;var api = callr;
Init with Api-Key token
var callr = ;var api = callr;
Init with User session token
var callr = ;var api = callr;
Init with Login As
var callr = ;var options = loginas: type: 'user' // available types: user, account target: '<login>' // available targets: <login> for type user, // <hash> for type account var api = callr options;
Set Login As after Init
var callr = ;var api = 'login' 'password';... api; // available types: user, account // available targets: <login> for type user, // <hash> for type account
API return value management
Set your success/error callback to get data returned by the API
api;
Usage
Sending SMS
Without options
api;
Method
Personalized sender
Your sender must have been authorized and respect the sms_sender format
api;
Method
If you want to receive replies, do not set a sender - we will automatically use a shortcode
api;
Method
Force GSM encoding
var optionSMS = force_encoding: 'GSM' ; api;
Method
Objects
Long SMS (availability depends on carrier)
var text = 'Some super mega ultra long text to test message longer than 160 characters ' + 'Some super mega ultra long text to test message longer than 160 characters ' + 'Some super mega ultra long text to test message longer than 160 characters';api;
Method
Specify your SMS nature (alerting or marketing)
var optionSMS = nature: 'ALERTING' ; api;
Method
Objects
Custom data
var optionSMS = user_data: '42' ; api;
Method
Objects
Delivery Notification - set webhook URL to receive notifications
var optionSMS = webhook: endpoint: 'http://yourdomain.com/webhook_endpoint' ; api;
Method
Objects
Inbound SMS - set webhook endpoint to receive inbound messages (MO) and replies
Do not set a sender if you want to receive replies - we will automatically use a shortcode.
var optionSMS = webhook: endpoint: 'http://yourdomain.com/webhook_endpoint' ; api;
Method
Objects
Get an SMS
api;
Method
Objects
REALTIME
Create a REALTIME app with a callback URL
var options = url: 'http://yourdomain.com/realtime_callback_url'; api;
Method
Objects
Start a REALTIME outbound call
var target = number: '+33132456789' timeout: 30; var callOptions = cdr_field: '42' cli: 'BLOCKED'; api;
Method
Objects
Inbound Calls - Assign a phone number to a REALTIME app
api;
Method
Objects
DIDs
List available countries with DID availability
api;
Method
Objects
Get area codes available for a specific country and DID type
api;
Method
Objects
Get DID types available for a specific country
api;
Method
Objects
Buy a DID (after a reserve)
api;
Method
Objects
Cancel your order (after a reserve)
api;
Method
Cancel a DID subscription
api;
Method
View your store quota status
api;
Method
Objects
Get a quote without reserving a DID
api;
Method
*Objects/
Reserve a DID
api;
Method
Objects
View your order
api;
Method
Objects
Conferencing
Create a conference room
var params = open: true ;var access = ; api;
Method
Objects
Assign a DID to a room
api;
Method
Create a PIN protected conference room
var params = open: true ;var access = pin: '1234' level: 'GUEST' pin: '4321' level: 'ADMIN' phone_number: '+33123456789' ; api;
Method
Objects
Call a room access
api;
Method
Media
List your medias
api;
Method
Create an empty media
api;
Method
Upload a media
var media_id = 0; api;
Method
Use Text-to-Speech
var media_id = 0; api;
Method
CDR
Get inbound or outbound CDRs
var from = 'YYYY-MM-DD HH:MM:SS';var to = 'YYYY-MM-DD HH:MM:SS'; api;
Method
Objects
SENDR
Broadcast messages to a target
var target = number: '+33123456789' timeout: 30; var messages = 131 132 'TTS|TTS_EN-GB_SERENA|Hello world! how are you ? I hope you enjoy this call. good bye.'; var options = cdr_field: 'userData' cli: 'BLOCKED' loop: 2; api;
Without options
var target = number: '+33123456789' timeout: 30; var messages = 131 132 134; api;
Method
Objects
Fatal error management
try api; catch e console;
Authentication for older versions
- Deprecated method for authenticating with
1.x
versions of the SDK.
For authenticating with older versions of the API SDK can be done the following way:
var callr = ;var api = 'login' 'password';...
Or when passing options
var callr = ;var options = loginas: type: 'user' // available types: user, account target: '<login>' // available targets: <login> for type user, // <hash> for type account var api = 'login' 'password' options;...