There is a script that sends a message to whatsapp
<script>
$(document).ready(function() {
// URL for the POST /message request
var url = 'https://eu43.chat-api.com/instance**********/message?token=**********';
var data = {
phone: '***********', // Recipient's phone number
body: 'There should be a message here', // Message
};
// Send a request when the button is clicked
$(".button").click(function() {
$.ajax(url, {
data: JSON.stringify(data),
contentType: 'application/json',
type: 'POST'
});
});
});
</script>
And there are inputs that are filled in by the client to send information about the order to connected partners (cafes, restaurants) by phone number in whatsapp for order formation and delivery
<input name="name" class="t-input">
<input name="phone" class="t-input">
<input name="address" class="t-input">
<input type="hidden" name="recipient" value="78888888888"> //Phone number of the recipient of order information in whatsapp
Now the task is to send information about the order to whatsapp, which is contained in the input values (name, phone,address) to the recipient's number (recipient) and put names before each input value (except recipient), i.e. Name:, phone Number:, Address: from a new line. The recipient value must be inserted in phone, and the other input values (name,phone,address) must be inserted in data.
Example of a received message:
- Name: Alex
- Phone: +79999999999
- Address: Kazan, Baumana street, the house 20, apartment 19
- Order: Pizza " Margarita"