Dear Community,
I would like to teach my devices (Photon, Electron) to act on a commands received from my Telegram bot.
I have URL which sends me data: https://api.telegram.org/bot/getUpdates
then message typed in Bot this URL returns following data:
“message”:“message_id”:422,“from”:“id”:222222222,“is_bot”:false,“first_name”:“Anton”,“username”:“UserAnton”,“language_code”:“ru”},“chat”:“id”:222222222,“first_name”:“Anton”,“username”:“UserAnton”,“type”:“private”},“date”:1674067942,“text”:“my test message”}}]}
NEED: it to pass values from “id” and “text” to my Device - so device would act on it
After reading many guides and manuals I’ve created following:
Webhook in Console:
event name = WHTG_get
request type = Get
query parameters - Custom:
id > {TG_USER_ID}
text > {TG_USER_TEXT}
and Code
bool sendMessage = false;
String TG_USER_ID;
String TG_USER_TEXT;
How do you trigger the webhook?
A webhook subscribes to a Particle event - but who publishes that event?
Do you see any indication in console.particle.io/integrations/yourWebhook that the webhook ever fires?
Also IIRC, a hook-response is typically directed at the originator of the triggering event, not broadcast to all your other devices.
If you want your bot to actively tell all your devices something you’d not need to go via a webhook but can directly publish an event.
BTW, the MY_DEVICES parameter has been deprecated and if you don’t do anything in loop() you should also not use delay() in it.
you are right - URL itself doesn't trigger event ... and so there are no events fired in Integrations
Is there any chance that I can setup long polling in Particle Integrations/webhook so it would "listen" this URL?
got it - now trying to learn how i can parse data from response ..
The Particle cloud infrastructure will not automatically poll data from any URL.
Your bot would need to actively publish the data via the respective Cloud API.
How to incorporate that in your Python bot code you’d need to investigate yourself - I’m not a Python guy
im not a Python guy as well ))
will try maybe some other options - e.g. there good library for NodeMCU for Telegram Bot
is it possible that Particle will port and add it to Library in WebIDE ?