How to send Particle commands from chats - Twitch, Telegram, YouTube, etc

I need to be able to receive and process commands that are sent to my Particle via chat apps. Twitch, ideally, or Telegram, or YouTube. I can find some examples on the web of chat-controlled devices that aren’t Particles, but nothing specifically for this system. (seems like it should be easier with a Particle anyways?)

I’ve been able to send text from my Particle to chat apps, I just need the reverse now. I want to have certain “commands” entered in a Twitch chat trigger things to happen on my device.

Are there any similar projects I should be looking at? I’d appreciate any guidance on how to approach starting this project.

Hi and welcome to the community!

I think from Telegram you could instruct a bot to send commands to your Particle.
If that is the case, this topic can get you halfway there:

Thanks! I followed the info in that link a few days ago and got sending messages to Telegram to work. The reverse seems more complicated to me. I’m very new to this so I appreciate the feedback. Here’s how I’m guessing this could work… I set a Telegram bot up with a webhook (Telegram Bot API) that sends all updates (messages, etc) it gets to the Particle Cloud API (using my specific device id and token somehow). The content of those updates from Telegram will look something like this:

{
“update_id”:987654321,
“message”: {
“message_id”:14,
“from”: {
“id”:123456789,
“is_bot”:false,
“first_name”:“Name”,
“username”:“Username”,
“language_code”:“en”
},
“chat”: {
“id”:123456789,
“first_name”:“Name”,
“username”:“Username”,
“type”:“private”},
“date”:1631453675,
“text”:“/hellobot”,
“entities”: [
{
“offset”:0,
“length”:9,
“type”:“bot_command”
}
]
}
}

And I’d need to have a function running on my particle to grab the data in the “text” field, and if it matches what I want, then the function does the thing I want?

Do I have the basic flow down, and just need to figure out the specifics of each step? Or am I way off? lol.

Hey, that sounds like the plan I would execute.
Best of luck and if you get stuck along the way, don’t hesitate to ask again in the community.

I thought I should close this topic out by posting my solution. While I was able to get it working eventually, I opted instead to use a program called Streamer.bot to do all of this for me, and it works extremely well. It grabs commands from Twitch’s chat and passes them to my particle devices using command line function calls.

Check it out in action at BokBok Station

3 Likes

Congrats! This is way too cool!
The way you used Twitch is MUCH MUCH better than using a Telegram bot, from our perspective (the viewer).

1 Like

That is SO COOL! Good job, I might follow your lead and try something similar in a project I’ve been thinking about.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.