Problem statement
You have made an IOT project e.g.: home automation and wanted to send whatsapp messages to your self or some registered number for all the alerts. Here is a simple way to send messages in whatsapp using Whatabot api. Whatabot API is a service that allows you to send yourself messages in real time. You only have to register your phone and take note of your api key.
To send a message is necessary to execute a http GET from your microcontroller / app. It’s easy to use and you can receive real time alerts in all your projects
Steps to Follow
- Create the Whatabot contact in your smartphone.
The phone number is: +54 9 1123998026. You can also use the following link <link> - Send: “I allow whatabot to send me messages”
- Copy the link that Whatabot sent you and change the “text” tag of the URL for whatever you want.
- Use the link received in your IOT project to send messages to whatsapp number.
Screesshots
Note:
If you forgot your api key, send “I allow whatabot to send me messages” again and Whatabot will send you the key you had
To change your api key, send “I want to update my apikey” and Whatabot will send you a new one. Then update the key in all your apps
To delete your Whatsapp Whatabot accout, sent “I want to delete my account”
Sample examples
Below is the example on using whatsapp messages from your IOT projects made by using ESP8266.
#include <WiFiUdp.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#define WIFI_SSID "xxxxxxxxxx" //Your wifi ssid
#define WIFI_PASSWORD "YOUR_WIFI_PASS" //Your wifipassword
const String YOUR_PHONE = "9999999999"; //Without +
const String YOUR_WP_APIKEY = "12345678"; //Your API KEY
const String URL_WP = "http://api.whatabot.net/whatsapp/sendMessage?text=";
const String YOUR_CHATID = "000000000"; //Without +
WiFiUDP ntpUDP;
void setup() {
wifiConnect();
//Use the URL encoded blackspace (%20)
sendWhatsapp("Hello%20from%Digitalab.org");
}
void sendWhatsapp(String text) {
WiFiClient client;
HTTPClient https;
String url = URL_WP + text + "&apikey=" + YOUR_WP_APIKEY + "&phone=" + YOUR_PHONE;
https.begin(client, url);
int httpCode = https.GET();
https.end();
}
void loop() {
}
void wifiConnect() {
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD); // Connect to the network
Serial.print("Connecting to ");
Serial.print(WIFI_SSID);
Serial.println(" ...");
byte teller = 0;
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
delay(1000);
Serial.print(++teller);
Serial.print(' ');
if (teller % 40 == 0) {
teller = 0;
Serial.println();
}
}
Serial.println('\n');
Serial.println("Connection established");
Serial.print("IP address: \t");
Serial.println(WiFi.localIP());
}