sendpulse-api-request
v0.0.2
Published
A simple SendPulse API client library for Node.js
Downloads
8
Readme
SendPulse API Request
A simple SendPulse API client wrapper for Node.js.
Install
npm install sendpulse-api-request
Usage
This module helps you with authorization and you just perform requests to native SendPulse API methods endpoints with specific parameters.
const sendpulse = require("sendpulse-api-request");
const TOKEN_STORAGE = "/tmp/";
/*
* Initialization with SendPulse credentials https://login.sendpulse.com/settings/#api
*/
sendpulse.init("USER_ID", "USER_SECRET", TOKEN_STORAGE, function() {console.log});
/*
* Get a list of WhatsApp chats (https://sendpulse.com/integrations/api/chatbot/whatsapp#/chats/get_chats)
*/
sendpulse.sendRequest("/whatsapp/chats", "GET", {"bot_id": "XXXXXXXXXXXX"}, function(data) {
console.log(JSON.stringify(data))
});
/*
* Send a WhatsApp message to a phone number (https://sendpulse.com/integrations/api/chatbot/whatsapp#/contacts/post_contacts_sendByPhone)
*/
sendpulse.sendRequest("/whatsapp/contacts/sendByPhone", "POST", {
"bot_id": "XXXXXXXXXXXX",
"phone": "1XXXXXXXXXX",
"message": {
"type": "text",
"text": {
"body": "sample text"
}
}
}, function(data) {
console.log(data)
});