2024-07-27

Getting Started with Chatter.plus API: Sending Your First Message

Learn how to connect to the Chatter.plus API using Node.js and send your first WhatsApp message. This guide will walk you through the necessary steps and provide sample code to get you started quickly.

Welcome to our guide on using the Chatter.plus API to send WhatsApp messages. In this tutorial, we will show you how to establish a connection with the API and send your first message using Node.js and the Axios library.

Step 1: Create an Instance

First, you need to create an instance on our platform. Once you have created an instance, you will receive a QR code. Scan this QR code with your WhatsApp mobile app to link the instance to your WhatsApp account. After linking, you will obtain an instanceId which is crucial for making API calls.

Step 2: Install Axios

To interact with the Chatter.plus API, we will use Axios, a promise-based HTTP client for Node.js. Install Axios using npm:

npm install axios

Step 3: Send Your First Message

Here is a simple Node.js script to send a WhatsApp message using the Chatter.plus API:

const axios = require('axios');

const apiUrl = 'https://chatter.plus/api/instance/send';
const apiKey = 'YOUR_API_KEY';
const instanceId = 'YOUR_INSTANCE_ID';
const recipientJid = '[email protected]';

const message = 'Hello, this is a test message!';

axios.post(apiUrl, {
    instanceId: instanceId,
    remoteJid: recipientJid,
    message: message
}, {
    headers: {
        'Authorization': `Bearer ${apiKey}`
    }
}).then(response => {
    console.log('Message sent successfully:', response.data);
}).catch(error => {
    console.error('Error sending message:', error);
});

Understanding `remoteJid` Format

In our API, the remoteJid parameter specifies the recipient of the message. It is formatted as the recipient's phone number followed by @s.whatsapp.net(Persons) and @g.us(Groups). For example, if the phone number is +1234567890, the remoteJid would be [email protected]. For a group with ID 1234567890, use [email protected]

By following these steps, you should be able to send your first message using the Chatter.plus API. If you have any questions or need further assistance, feel free to reach out!