Send WhatsApp messages send using jQuery with the help of chat API; We will send WhatsApp messages using chat API in jQuery but before that, we need to generate the install number and token no from the chat API. For that, you need to create an account in the chat API, after which they will provide the token no and instance number for sending a message to WhatsApp.
Using chat API we will send WhatsApp messages, for that, we will create an account, click on the given link and create an account Create Account
See below the given image, from there you will find your credentials.
Integrate In jQuery
Once you generate your token and instance number from there, paste in the given variable $token & $instanceId, then after adding your mobile number to the data array define the template name as well as the namespace and language also.
Now run your jQuery script and you will receive a message from the register number in the account.
// URL FOR REQUEST POST /MESSAGE
const token = '83763g87x';
const instanceId = '777';
const url = `https://api.chat-api.com/instance${instanceId}/sendTemplate?token=${token}`;
let data = {
phone: '91XXXXXXXXXX', // RECEIVERS PHONE
template: "template_name",
namespace : "namespace_of_template",
language: {
code: "en",
policy: "deterministic"
}
};
// SEND A REQUEST
$.ajax(url, {
data : JSON.stringify(data),
contentType : 'application/json',
type : 'POST'
});
We always thanks to you for reading our blogs.
Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us
Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- AngularJS Login Logout with Laravel 6
- How to install vue js project ?
- Vuejs form input binding with select box option
- jQuery load more data on scroll
- Axios API Response Status Code Best way To Handle In Vue
- MultiSelect Vue Js Npm Example
- Vuejs form input binding with radio checkbox
- jQuery Lazy Load
- Jquery - notification popup box using toastr JS Plugin
- Matching text highlight on search using html and js