How to receive WhatsApp messages into SQL database
This article is a detailed tutorial on how to receive WhatsApp messages into SQL database. The messages come from WhatsApp and they are sent to the Microsoft SQL server via the Ozeki SMS Gateway. With Ozeki SMS Gateway, you can effortlessly set up a connection between your database and WhatsApp, enabling you to receive messages directly into your SQL tables. We hope you find this article informative and let's get started!
What is WhatsApp messaging?
WhatsApp is a popular, free, and cross-platform messaging service for exchanging text, voice, and video messages, as well as documents and photos.
What is WhatsApp webhook?
WhatsApp webhook is a programming interface that allows third parties to automatically notify and reply to new messages on the WhatsApp platform.
Receiving WhatsApp messages into SQL database
The message sent from the WhatsApp user goes to the WhatsApp server which uses an API connection to send the message to the Ozeki SMS Gateway within 24 hours. Then the message arrives to the MS SQL Database server.
How to receive WhatsApp messages into SQL database (Simple steps)
To receive WhatsApp messages into SQL database:
- Launch the Ozeki SMS Gateway app
- Configure the WhatsApp webhook
- Check the message in the SQL database
How to receive WhatsApp messages into MS SQL (Video tutorial)
This video shows you how to receive messages from WhatsApp. How to connect your WhatsApp webhook to the Ozeki SMS Gateway. How to configure the webhook, what parameters to set. After successful connection, you can see the incoming messages in the log file and also in the database.
First log in to the Ozeki SMS Gateway, then select the SMS Gateway Desktop icon. In the Ozeki toolbar, select the existing WhatsApp client (Figure 2) link on the left side of the Connections panel.
Open WhatsApp configuration menu at the Meta for Developers page to configure the webhook (Figure 3). Click on Edit.
The webhook need to be set, because it allows the Ozeki SMS Gateway to send an alert message to Whatsapp when it receives a message from a mobile phone,
or when the status of a Whatsapp message sent to a mobile phone changes.
On the WhatsApp client page, we need the Configure tab. Scroll down to the Published callback URL section and copy it (Figure 4), it's a template. This will help you to just copy and paste.
Paste the template into the Callback URL field (Figure 5).
Copy the Connection name and the Verify token (Figure 7). The connection name specifies the name of the connection, the verifiy token is responsible for security.
Paste the Connection name at the end of the template. Replace the [public-ip]:[port] into your public IP with your forwarded port.
Paste the Verify token into the Verify token field on the Meta for Developers page. If you've filled everything in, click on Verify and save button.
Then press the Manage button (Figure 6).
You have to select the Webhook field, so you will need to select the messages on the page. Check this box and click Done (Figure 30). Selecting the message type in the WhatsApp webhook setting indicates that the webhook will respond to messages. It means that the webhook will work when messages are received and sent.
It should look like this (Figure 9), if we did everything right. And you can test the successful connection in the Ozeki SMS Gateway.
Let's go back to the Ozeki SMS Gateway. In the WhatsApp client, click on Events to see the log. Send a message in the WhatsApp application, the message needs to appear in the log (Figure 10).
On the left side in the control panel, under the Folders click on the Forwarded link, and choose the Forward accepted tab. Where you can see the messages (Figure 11).
Go back to the Main page and select your existing SQL Server link at the right side of the User and applications (Figure 12) panel to see the incoming message here too.
Let's query a message from the database. Go to the SQL tab of your connection. Select the SELECT * from the dropdown menu and you can see every received message (Figure 13).
Frequently Asked Questions (FAQs)
What is the purpose of the webhook in Ozeki SMS Gateway?
The Ozeki SMS Gateway webhook enables the system to send an alert message to WhatsApp. When it receives a message from a mobile phone, also, when there is a change in the status of a WhatsApp message sent to a mobile phone.
Can I use a WhatsApp webhook to send messages?
No, you cannot. The primary purpose of a WhatsApp webhook is to receive notifications and information, the webhook functionality is not designed for sending messages.
Why use a WhatsApp webhook?
A WhatsApp webhook helps developers automate responses, get notifications, and connect with other systems in real-time on the WhatsApp platform.
What is the purpose of the callback URL in a WhatsApp webhook?
The callback URL in a WhatsApp webhook is where WhatsApp sends messages to inform third-party apps about events, like new messages or changes in message status, through HTTP requests.
Is a WhatsApp webhook secure?
The security of a WhatsApp webhook relies on how it is set up by the developer. It is important to use secure connections (HTTPS) and proper authentication methods to keep the data safe and confidential. Within the Ozeki SMS Gateway it is secure.
What information can I receive through a WhatsApp webhook?
With a WhatsApp webhook, you can receive information about new messages, updates on message status (like delivered or read), and other important events on WhatsApp.
Summary
This article provides instructions on how to receive WhatsApp messages into an SQL database using Ozeki SMS Gateway. The article explains the components of WhatsApp messaging, the purpose of the webhook in Ozeki SMS Gateway, and the steps involved in configuring the webhook to receive messages from WhatsApp. Additionally, the article provides answers to frequently asked questions (FAQs) about WhatsApp webhooks.
By following the detailed instructions provided in the article, you can simply integrate WhatsApp messaging into your existing SQL database infrastructure, streamlining your communication processes and data management.
With the provided screenshots and instructions, you can easily follow the steps.
In addition, here are some more valuable tips for configuring your WhatsApp SMS connection:
- Verify that you have a valid WhatsApp Business account ID and a temporary access token.
- Ensure the phone number added to WhatsApp Business App matches the one used in Ozeki SMS Gateway.
- Validate the connection by sending a test message to a recipient’s phone number.
- Utilize a secure callback URL for your WhatsApp webhook.
If you have further questions, please email info@ozeki.com or register on our website: https://myozeki.com for help.