Skip to content

dshemendiuk/sendpulse-api-request

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)
});

About

A simple SendPulse REST client library and example for Node.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%