messengers is a messaging service used by people all over the world. With Chat API you can programmatically receive and send messengers messages using simple HTTP requests.
Integrate messengers with any marketing or business platform i.e. Woocommerce, Shopify, Autoresponder, CRM, ERP, etc.
Let's walk through how to use JavaScript to send a message over messengers.
Before you begin, make sure that Node.js and npm installed (do this first if you haven't already)
You will need an account in our service. Create your account in Chat-Api. It's free!
After that, you will be redirected to the admin panel, where your personal instance will be generated and created for you.
Go to your personal account and get a QR code there. Next, open messengers on your mobile phone, go to Settings -> messengers Web -> Scan a QR code.
Sending a messengers message with Node.js
var request = require('request'); //bash: npm install request
// URL for request POST /message
var token = '83763g87x';
var instanceId = '777';
var url = `https://api.chat-api.com/instance${instanceId}/message?token=${token}`;
var data = {
phone: '15034365851', // Receivers phone
body: 'Hello, world!', // Message
};
// Send a request
request({
url: url,
method: "POST",
json: data
});
Just copy and use it!
Don't use brackets, hyphens and any other formatting symbols in the phone. Use only digits.
You will only need to substitute your token from your personal account into the $token variable and instance number (or ApiURL)
Get API key, try it today!
What if I want to do this with another language?
You just successfully sent your first messengers message using JavaScript, but what if you want to do this in PHP? We have other blog posts you can check out for that: How to send messenger message with PHP or How to send a messengers message with Python
Feel free to reach out and share your experiences or ask any questions.