Node.js Library v2

View Repo

The Flowroute Node.js Library v2 provides methods for interacting with Messages v2 of the Flowroute API.



First, start a command shell session and clone the flowroute-messaging-nodejs Github repository.

git clone

After cloning the flowroute-messaging-nodejs repository, switch to the newly-created flowroute-messaging-nodejs directory. To check that Node.js is installed, run the following:

node --version

This SDK has been tested with Node v6.10.3 for Mac OS X. To install npm's request package for making http calls, run the following:

npm install request



In Flowroute's approach to building the Messaging (v2) API wrapper, HTTP requests are handled by the APIController, which contains the functions used to perform tasks with the Node.js SDK.


In your Node.js file, import the Messaging SDK and set up your callback function. The callback parameter prints the response out to the screen. It points back to the callback function added to the Node.js file.

var flowroute = require('./flowroutemessaginglib');
//Set up your callback function
var cb =  function(err, response){



Replace AccessKey and SecretKey with your API credentials from the Flowroute Manager.

flowroute.configuration.username = "AccessKey";
flowroute.configuration.password = "SecretKey";




The method accepts the msg, to, from, body, and callback parameters which you can learn more about in the API reference.

#Create and send the message
var msg = {"to": "12066418000", "from": "12064205780", "content": "That rug really tied the room together."};
flowroute.MessagesController.createMessage(msg, cb);

Example Response

{"data": {"id": "mdr1-d858379c1bee4dd3bfe5c556f7cef70f"}}


The method accepts the record_id and callback parameters which you can learn more about in the API reference.

#Get the MDR
flowroute.MessagesController.getMessageLookup("d858379c1bee4dd3bfe5c556f7cef70f", cb);

Example Response
"data": {
 "attributes": {
   "body": "That rug really tied the room together.",
   "direction": "outbound",
   "timestamp": "2016-06-13T20:34:29.095045+00:00",
   "amount_nanodollars": 4000000,
   "from": "12064205780",
   "message_encoding": 0,
   "has_mms": false,
   "to": "12066418000",
   "amount_display": "$0.0040",
   "callback_url": null,
   "message_type": "long-code"
 "type": "message",
 "id": "mdr1-d858379c1bee4dd3bfe5c556f7cef70f"


©2004 - 2024 BCM One. All right reserved. Legal | Privacy Policy | Blog | News | Contact