npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

direct7

v0.0.8

Published

Npm SDK for Direct7 Platform REST API

Downloads

49

Readme

Direct7 Node.js SDK

Node.js SDK to seamlessly incorporate communication features into your Node.js applications via the Direct7 REST API. This SDK empowers you to effortlessly initiate SMS,Whatsapp, Slack, Viber messages and 2 factor authentication features.

Documentation

The documentation for the Direct7 REST API can be found here Direct7 API Reference.

Installation

Install the SDK using npm

npm i direct7

Usage

To get started you need to have an active Direct7 account, If you haven't yet registered, please proceed to Sign up

Authentication

In order to initiate API requests, create a client object using your Direct7 API token. To obtain an API token, kindly visit the following link: https://app.d7networks.com/api-tokens.

const Client = require('direct7')
const client = new Client(apiToken="Your API token")

Examples

SMS

For comprehensive information on SMS request parameters, please refer SMS API Reference

Send an SMS

const Client = require('direct7')
const client = new Client(apiToken="Your API token")

 const response = await client.sms.sendMessage(
            'SignOtp',
            'https://the_url_to_recieve_delivery_report.com',
            {
                recipients: ["+recipient1", "recipient2"],
                content: "Greetings from D7 API",
                unicode: false
            }
        );
console.log(response);

Send a Unicode SMS Message

const Client = require('direct7')
const client = new Client(apiToken="Your API token")

 const response = await client.sms.sendMessage(
      'SignOtp',
      'https://the_url_to_recieve_delivery_report.com',
      { 
        recipients: ["+91999XXXXXXX"],
        content: 'لوحة المفاتيح العربية!',
        unicode: true 
      }
    );
console.log(response);

Check SMS Request Status

const Client = require('direct7')
const client = new Client(apiToken="Your API token")

 // request_id is the id returned in the response of sendMessage
const response = await client.sms.getStatus({request_id:"0015e146-4edb-4302-91fe-cdcf868a6cf2"});
console.log(response);

Verify

For comprehensive information on verify API, please refer Verify API Reference

Send OTP

const Client = require('direct7')

const client = new Client(apiToken="Your API token")

const response = await client.verify.sendOTP({
            originator: "SignOTP", recipient: "+9199999XXXXX",
            content: "Greetings from D7 API, your mobile  verification code is: {}",
            expiry: 600,
            data_coding: "text"
        })

console.log(response);

Re-Send OTP

const Client = require('direct7')
const client = new Client(apiToken="Your API token")

const response = await client.verify.resendOTP({otp_id : "bc4f5e29-dcfa-4d81-9cb1-d6c5002a96bd"})
console.log(response);

Verify OTP

const Client = require('direct7')
const client = new Client(apiToken="Your API token")

const response = await client.verify.verifyOTP({otp_id: "b4c3ac5d-df5f-4df7-85b9-aba64c5da228", otp_code: "749679"});

console.log(response);

Check OTP Status

const Client = require('direct7')
const client = new Client(apiToken="Your API token")

// otp_id is the id returned in the response of send_otp
const response = await client.verify.getStatus({otp_id: "d4c6b4e9-532d-4be7-9e9e-897f97847fbd"});
console.log(response);

Whatsapp

For comprehensive information on Whatsapp API, please refer Whatsapp API Reference

Send Whatsapp Free-form Message (Location Details)

const Client = require('direct7')

const client = new Client(apiToken="Your API token")

const response = await client.whatsapp.sendWhatsAppFreeformMessage({
            originator : "91906152XXXX", recipient : "91999999XXXX", message_type: "LOCATION",  longitude : "11.93803129081362", latitude:"44.61088653615994", location_address:"Address", location_name:"Name"
        });

console.log(response);

Send Whatsapp Templated Message.

const Client = require('direct7')
const client = new Client(apiToken="Your API token")

const response = await client.whatsapp.sendWhatsAppTemplatedMessage({
            originator : "91906152XXXX", recipient : "91999999XXXX",
            template_id : "marketing_media_image", body_parameter_values : {"0": "Customer"}, media_type : "image",
            media_url : "https://d7networks.com/static/resources/css/img/favicon.d27f70e6ebd0.png"
        });
console.log(response);

Check Whatsapp Request Status

const Client = require('direct7')
const client = new Client(apiToken="Your API token")

// request_id is the id returned in the response of send_message
const response = await client.whatsapp.getStatus({request_id: "987efe2a-c68f-4cfb-8301-662b574d21c0"});
console.log(response);

Number Lookup

For comprehensive information on Number Lookup API, please refer Number Lookup Reference

Search Your Phone Number Details

const Client = require('direct7')
const client = new Client(apiToken="Your API token")

const response = await client.number_lookup.searchNumberDetails({recipient : "+91999999XXXX"});
console.log(response);

Viber

For comprehensive information on Viber API, please refer Viber API Reference

Send a Viber Message

const Client = require('direct7')
const client = new Client(apiToken="Your API token")

const response = await client.viber.sendViberMessage({
            recipients : ["+9199999XXXXX"],
            content : 'Hello, this is a test message!',
            label : 'PROMOTION',
            originator : 'SignOTP',
            call_back_url : 'https://the_url_to_recieve_delivery_report.com'
        });

console.log(response);

Check Viber Request Status

const Client = require('direct7')
const client = new Client(apiToken="Your API token")

// request_id is the id returned in the response of send_viber_message
const response = await client.viber.getStatus({request_id:"002ad5b1-c142-4273-8d82-56da6ea5f5c3"});
console.log(response);

Slack

For comprehensive information on Slack API, please refer Slack API Reference

Send Slack Message

const Client = require('direct7')
const client = new Client(apiToken="Your API token")

const response = await client.slack.sendSlackMessage({
            content : 'Hello, this is a test message!',
            work_space_name : 'WoekSpaceName',
            channel_name : 'ChannelName',
            report_url : 'https://the_url_to_recieve_delivery_report.com'
        });
console.log(response);

Check Slack Request Status

const Client = require('direct7')
const client = new Client(apiToken="Your API token")

// request_id is the id returned in the response of send_slack_message
const response = await client.slack.getStatus({request_id: "002ad5b1-c142-4273-8d82-56da6ea5f5c3"});
console.log(response);

FAQ

How do I get my API token?

You can get your API token from the Direct7 dashboard. If you don't have an account yet, you can create one for free.

Supported nodejs versions

The SDK supports node 18 and higher.

Supported APIs

As of now, the SDK supports the following APIs:

| API | Supported? | | ----------------- | :--------: | | SMS API | ✅ | | Verify API | ✅ | | Whatsapp API | ✅ | | Number Lookup API | ✅ | | Viber API | ✅ | | Slack API | ✅ |

How do I get started?

You can find the platform documentation @ Direct7 Docs.

How do I get help?

If you need help using the SDK, you can create an issue on GitHub or email to [email protected]

Contributing

We welcome contributions to the Direct7 npm SDK. If you have any ideas for improvements or bug fixes, please feel free to create an issue on GitHub.