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

afilnet

v2.2.1

Published

An easy way to use Afilnet API services to send SMS, email and voice notifications.

Downloads

12

Readme

SMS, Email and Voice notifications

Easy to use

This package is designed to be an easy way to use Afilnet API services. You can send SMS, email and voice notifications using your Afilnet account.

You only need an Afilnet account with enought credits. If you do not have an account, you can create it in a few minutes.

Example

var afilnet = require('afilnet');

afilnet.login(
	"[email protected]", 
	"password",
	function(result){
		if (result){
			console.log("User logged");
		}
		else {
			console.log("Bad credentials");
		}
	}
);

//You must login correctly or all services will return error bad user/pass

//SEND SIMPLE SMS
afilnet.sms.send(
    'to',
    'message',
    'from',
    'scheduledatetime', //Optional, you can set it null
    'output',   //Optional, you can set it null
    function(result){
        console.log(result);
    }
);

//SEND EMAIL FROM TEMPLATE
afilnet.email.sendFromTemplate(
    'to',
    'idTemplate',
    'params',
    'scheduledatetime', //Optional, you can set it as null
    'output', //Optional, you can set it as null
    function(result){
        console.log(result);
    }
);

//SEND VOICE TO GROUP
afilnet.voice.sendToGroup(
    'countryCode',
    'idGroup',
    'msg',
    'scheduledatetime', //Optional, you can set it as null
    'output', //Optional, you can set it as null
    function(result){
        console.log(result);
    },
);

Index


Afilnet

Afilnet Cloud Marketing Logo

Afilnet is a company dedicated to Cloud Marketing.

With this module we seek to facilitate the use of the services we offer through our API.

We offer support to our clients if they have some trouble with their accounts or our services.

If you notice some error or bugs, feel free to contact us.

Website

We are available in 3 different languages:

back to top


Setup

ATTENTION: You need an Afilet account with credits to use this module

If you dont have an account, visit our web page and create it.

After that, you will have to buy some credits to be able to send the notifications

We have a promo to test the services which give you 10 credits for free

Once you have an account, we are ready to setup the module in your app:

The first step is require the module.

var afilnet = require('afilnet');

Then login with your account credentials. (You must login correctly or all services will return error bad user/pass)

afilnet.login(
	"[email protected]", 
	"password",
	function(result){
		if (result){
			console.log("User logged");
		}
		else {
			console.log("Bad credentials");
		}
	}
);

If you have been successfully logged in, we are ready to use the services :)

back to top


Afilnet API Services

There are 4 channels availables:

This library use the structure:

afilnet.channel.service(params, callbackFunction);

User has two services:

  • getBalance (Get balance of your account)
  • getUsername (Return username of the logged account) This service return a variable, so it doesn't require callback function

SMS, Email and Voice have the same services:

  • send (Send to a single user)
  • sendFromTemplate (Send to a single user using a template)
  • sendToGroup (Send to a defined group)
  • sendToGroupFromTemplate (Send to a defined group using a template)
  • getDeliveryStatus (Get delivery status of a message)

User

If you want to check User parameters you only need to call the object user and the service required.

Services

//GET BALANCE
afilnet.user.getBalance(callback);

//GET USERNAME
var accountUsername = afilnet.user.getUsername();

Example

var accountUsername = afilnet.user.getUsername();

afilnet.user.getBalance(
    function(result){
        if (result.status=="SUCCESS"){
            console.log("I have " + result.result + " credits");
        } else { // == "ERROR"
            console.log("Error: "+ result.error);
        }
    }
);

SMS

If you want to use SMS you only need to call the object sms and the service required.

Services

//SEND
afilnet.sms.send(
    'from',
    'to', 
    'msg',
    'scheduledatetime', // (optional) 
    'output', // (optional)
    callback
);

//SEND FROM TEMPLATE
afilnet.sms.sendFromTemplate(
    'to', 
    'idTemplate', 
    'params', // (optional) 
    'scheduledatetime', // (optional) 
    'output', // (optional)
    callback
);

//SEND TO GROUP
afilnet.sms.sendToGroup(
   'from', 
   'countryCode', 
   'idGroup', 
   'msg', 
   'scheduledatetime', // (optional) 
    'output', // (optional)
    callback
);

//SEND TO GROUP FROM TEMPLATE
afilnet.sms.sendToGroupFromTemplate(
    'countryCode', 
    'idGroup', 
    'idTemplate', 
    'scheduledatetime', // (optional) 
    'output', // (optional)
    callback
);

// GET DELIVERY STATUS
afilnet.sms.getDeliveryStatus('ids', callback);

Example

var to = "34600000000";
var message = "Hey Luke, I want to tell you something... I am your father.";
var from = "Darth Vader";

afilnet.sms.send(
    from,
    to,
    message,
    null,
    null,
    function(result){
        if (result.status=="SUCCESS"){
            console.log("Nooooo!!!!!11");
        } else { // == "ERROR"
            console.log("I have not received any sms :(");
        }
    }
);

back to top


Email

If you want to use Email you only need to call the object sms and the service required.

Services

//SEND
afilnet.email.send(
    'subject',
    'to', 
    'msg',
    'scheduledatetime', // (optional) 
    'output', // (optional)
    callback
);

//SEND FROM TEMPLATE
afilnet.email.sendFromTemplate(
    'to', 
    'idTemplate', 
    'params', // (optional) 
    'scheduledatetime', // (optional) 
    'output', // (optional)
    callback
);

//SEND TO GROUP
afilnet.email.sendToGroup(
    'subject', 
    'idGroup', 
    'msg', 
    'scheduledatetime', // (optional) 
    'output', // (optional)
    callback
);

//SEND TO GROUP FROM TEMPLATE
afilnet.email.sendToGroupFromTemplate(
    'idGroup', 
    'idTemplate', 
    'scheduledatetime', // (optional) 
    'output', // (optional)
    callback
);

// GET DELIVERY STATUS
afilnet.email.getDeliveryStatus('ids', callback);

Example

var to = "[email protected]";
var subject = "I have a surprise for you - Darth Vader";
var message = "<h2>I am your father.</h2><hr><p>Hehehe surprise.</p><p>Best wishes, Darth Vader.</p>";

afilnet.email.send(
    subject,
    to, 
    message,
    null, // (optional) 
    null, // (optional)
    function(result){
        if (result.status=="SUCCESS"){
            console.log("Nooooo!!!!!11");
        } else { // == "ERROR"
            console.log("I have not received any email :(");
        }
    }
);

back to top


Voice

If you want to use Voice you only need to call the object sms and the service required.

Services

//SEND
afilnet.voice.send(
    'to', 
    'msg',
    'lang', // (optional) 
    'scheduledatetime', // (optional) 
    'output', // (optional)
    callback
);

//SEND FROM TEMPLATE
afilnet.voice.sendFromTemplate(
    'to', 
    'idTemplate', 
    'params', // (optional) 
    'scheduledatetime', // (optional) 
    'output', // (optional)
    callback 
);

//SEND TO GROUP
afilnet.voice.sendToGroup(
   'countryCode', 
   'idGroup', 
   'msg', 
   'scheduledatetime', // (optional) 
   'output', // (optional) 
    callback
);

//SEND TO GROUP FROM TEMPLATE
afilnet.voice.sendToGroupFromTemplate(
    'countryCode', 
    'idGroup', 
    'idTemplate', 
    'scheduledatetime', // (optional) 
    'output', // (optional) 
    callback
);

// GET DELIVERY STATUS
afilnet.voice.getDeliveryStatus('ids', callback);

Example

var to = "346000000";
var message = "Hey Luke, I want to tell you something... I... am... your father.";
var lang = "EN";

afilnet.voice.send(
    to,
    message,
    null,
    null,
    lang,
    function(result){
        if (result.status=="SUCCESS"){
            console.log("Wait, what?!... Nooooo!!!!!");
        } else { // == "ERROR"
            console.log("I have not received any phone call :(");
        }
    }
);

back to top


RESPONSE

All services receive similar parameters but all return same JSON object.

The services will return a JSON object with the next structure:

  • status
  • error (if status=ERROR), here you will receive the error code
  • result (if status=SUCCESS), here you will receive the following values:
    • messageid
    • credits

ERROR CODES

Code | Description --- | --- | --- MISSING_USER | User or email not included MISSING_PASSWORD | Password not included MISSING_CLASS | Class not included MISSING_METHOD | Method not included MISSING_COMPULSORY_PARAM | Compulsory parameter not included INCORRECT_USER_PASSWORD | Incorrect user or password INCORRECT_CLASS | Incorrect class INCORRECT_METHOD | Incorrect method NO_ROUTE_AVAILABLE | There are no available paths for the indicated destination NO_CREDITS | Your balance is insufficient

Example

  • If everything is ok:
{"status":"SUCCESS","result":{"messageid":"id_from_message","credits":"credits_spent"}}
  • If something went bad:
{"status":"ERROR","error":"error_message"}

back to top