Buenas, estoy usando la librería CBOT.H para realizar la comunicación con TELEGRAM con el siguiente código;
#include "CTBot.h"
CTBot myBot;
String ssid = "kapotik"; // REPLACE mySSID WITH YOUR WIFI SSID
String pass = "Florencia36";
// REPLACE myPassword YOUR WIFI PASSWORD, IF ANY
String token = "940672949:AAF5pljdZUJV16mpLum3mOugD1FHgQlWzjE"; // REPLACE myToken WITH YOUR TELEGRAM BOT TOKEN
uint8_t led = D4; // the onboard ESP8266 LED.
// If you have a NodeMCU you can use the BUILTIN_LED pin
// (replace 2 with BUILTIN_LED)
void setup() {
// initialize the Serial
Serial.begin(115200);
Serial.println("Starting TelegramBot...");
// connect the ESP8266 to the desired access point
myBot.wifiConnect(ssid, pass);
// set the telegram bot token
myBot.setTelegramToken(token);
// check if all things are ok
if (myBot.testConnection())
Serial.println("\ntestConnection OK");
else
Serial.println("\ntestConnection NOK");
// set the pin connected to the LED to act as output pin
pinMode(led, OUTPUT);
digitalWrite(led, HIGH); // turn off the led (inverted logic!)
}
void loop() {
// a variable to store telegram message data
TBMessage msg;
// if there is an incoming message...
if (myBot.getNewMessage(msg)) {
// generate the message for the sender
String reply;
reply = (String)"Carlos " + msg.sender.username + (String)". llamame";
myBot.sendMessage(msg.sender.id, reply); // and send it
}
// wait 500 milliseconds
delay(500);
}
donde solo contesta si se escribe algo desde el teléfono en el bot, ya que como dice en el código "si hay mensaje nuevo envié tal cosa"
Bien, mi pregunta es como hago para enviar un mensaje al bot cuando yo quiera, sin que tenga que escribir algo en el teléfono?.
espero se entienda, gracias
saludos