- Node >= 12x
- WhatsApp account.
- Active Token - Get a Token here.
Using npm:
$ npm i trenalyze
Note: add --save
if you are using npm < 5.0.0
In Node.js:
Note: You'll need to require the Trenalyze npm Module after installation
// Load the full build.
const Trenalyze = require('trenalyze');
Param | Type | Description |
---|---|---|
token | string |
Use your Trenalyze Token from your Dashboard. |
sender | interger |
Enter the WhatApp Number that has already be scanned on the Trenalyze Dashboard. |
debug | boolean |
(OPTIONAL). Default is false. But you can set to be true and the debug message is passed onto the console. |
// Set The Config
const wa = new Trenalyze(YOUR_TRENALYZE_TOKEN_HERE, YOUR_WHATASPP_NUMBER_HERE, true);
Note: Phone number should be in following format 12345678912
, without +
or any other symbols
Param | Type | Description |
---|---|---|
receiver | interger |
Phone number should be in following format 12345678912 , without + or any other symbols. |
message | interger |
Enter the desired text message to send. |
mediaurl | string |
(OPTIONAL). BUT MUST BE DECLARED This should be a valid media/file link. Learn More |
buttons | array |
(OPTIONAL). BUT MUST BE DECLARED You can attach quick replies buttons to your message. Learn More |
// Set the Required Parameters for sending message
const details = {
receiver: '123456789',
message: 'Hello World',
mediaurl: 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png',
buttons: [{
text: 'Click Me',
url: 'https://trenalyze.com'
}]
}
NOTE: When not using mediaurl and buttons set to NULL
mediaurl: '',
buttons: ''
Param | Type | Description |
---|---|---|
details | array(variable) |
Send the variable declared in step 2 |
// Initialize the send whatsapp message functions
wa.sendMessage(details, (error, data) => {
if (data.statusCode !== 200) {
console.log('Error: ' + data.statusMessage);
} else {
console.log('Success ' + data.statusMessage);
}
});