Hey everyone! I’m new to programming but eager to learn. I’m working on a project with Node-RED for IoT stuff. I’m trying to set up communication between Node-RED and a Telegram bot.
Here’s what I’ve done so far:
- Installed TelegramBot and Redbot (chatbot) modules in Node-RED
- Created a Telegram bot and got the API key
- Found my Chat ID (that was tricky!)
- Set up a basic flow in Node-RED following some online guides
The problem is when I send a message from my Telegram bot, Node-RED seems to pick it up, but I get this error in the Debug tab:
msg : string [44]Unable to find context().global in Node-RED
When I click the error, it takes me back to my Telegram setup in Node-RED.
I feel like I’m missing something simple, but I can’t figure out what. Any ideas on what might be causing this error or how to fix it? Thanks for any help!
I ran into a similar issue when I first started with Node-RED and Telegram. The error you’re seeing is likely due to how you’re trying to access the global context. In newer versions of Node-RED, you can’t use context().global directly anymore.
Try updating your nodes to use global.get() and global.set() instead. For example, if you’re trying to store the bot token, use global.set(‘botToken’, ‘your_token_here’) in a function node. Then, in your Telegram nodes, you can retrieve it with global.get(‘botToken’).
Also, double-check that your Telegram nodes are up to date. I once spent hours debugging only to realize I was using an outdated version that wasn’t compatible with my Node-RED installation.
If you’re still stuck, posting a screenshot of your flow might help us spot the issue. Good luck with your project!
hey, i had a similar problem. try using global.get() and global.set() instead of context().global. that fixed it for me. also, make sure ur telegram nodes are updated. if ur still stuck, maybe share a screenshot of ur flow? good luck with ur project!
That error usually pops up when you’re trying to access global context the old way. Node-RED changed how it handles global variables a while back. Instead of using context().global, you need to use global.get() and global.set() now.
For example, if you’re storing your bot token, you’d do something like global.set(‘botToken’, ‘your_token_here’) in a function node. Then in your Telegram nodes, you can grab it with global.get(‘botToken’).
Also, make sure your Telegram nodes are up to date. Outdated nodes can cause all sorts of weird issues.
If you’re still stuck after trying that, maybe post a screenshot of your flow? Sometimes a fresh pair of eyes can spot something you’ve missed. Hope this helps!