loopback-connector-nexmo
v0.5.3
Published
LoopBack connector for Nexmo
Downloads
10
Maintainers
Readme
loopback-connector-nexmo
Customizing Nexmo configuration for examples
By default, examples from this module assumes the user has a Nexmo account. To run the example you will need
to provide your apiKey
and apiSecret
.
The connector support the following aspects of the Nexmo REST API:
Installation
In your LoopBack project:
$ npm install loopback-connector-nexmo
Using the Connector
To use the connector, define the datasource using the connector in your datasources.json
file:
"nexmo": {
"name": "nexmo",
"connector": "loopback-component-nexmo",
"apiKey": "YOUR_NEXMO_API_KEY",
"apiSecret": "YOUR_NEXMO_API_KEY"
}
Next, attach the created datasource to a model in the model-config.json
file:
"nexmo": {
"dataSource": "nexmo",
"public": true
}
Now, using the created model, you can send an SMS or make a call using the send
method of the model:
Nexmo.sendSms(options, callback);
Sending a SMS
{
sender: 'YOUR_PHONE_NUMBER',
recipient: 'TARGET_PHONE_NUMBER',
message: 'TEXT_MESSAGE',
options: {}
}
Running the Example
To run the example in the /example/example.js
directory, you must set the following values in the file:
var KEY = 'YOUR_NEXMO_KEY';
var SECRET = 'YOUR_NEXMO_SECRET';
var TO = 'YOUR_TELEPHONE_NUMBER';
var FROM = 'TARGET_PHONE_NUMBER';
Next, from the from the /loopback-connector-nexmo/
directory, install the loopback
module using the following command:
$ npm install loopback
Finally, run the example app using the following command from the /loopback-connector-nexmo/
directory:
$ node ./example/example.js
Version
0.5.2
License
MIT - Interactive Object https://interactive-object.com