guidone/node-red-contrib-chatbot

Chatbot broken with node-red 2.2.0?

flamingm0e opened this issue ยท 22 comments

Updated to Node-Red 2.2.0 today and my chat bot stopped working. It can't find the Transport and bot configurations in the Conversation node. The dropdowns are blank.

[error] [chatbot-telegram-node:8819b2a2.272e2] TypeError: RED.settings.functionGlobalContext.get is not a function

Reverting back to 2.1.6 and it works with no other changes

Same here. Got it back to work by modifying file lib/sender-factory.js:

Changed line 36 from
var platformConfigs = RED.settings.functionGlobalContext.get(platform) || {};
to
var platformConfigs = {};

But some other things seem to be broken, too. Can't edit a Rule e.g., only shows an empty settings area...

Same here.
Reverted NR to 2.1.6 and patently waiting for a fix :)

Same here.

I also experience that issue, here the log output:

TypeError: RED.settings.functionGlobalContext.keys is not a function
    at /data/node_modules/node-red-contrib-chatbot/nodes/chatbot-context-store.js:39:53
    at Layer.handle [as handle_request] (/usr/src/node-red/node_modules/express/lib/router/layer.js:95:5)
    at next (/usr/src/node-red/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/usr/src/node-red/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/usr/src/node-red/node_modules/express/lib/router/layer.js:95:5)
    at /usr/src/node-red/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/usr/src/node-red/node_modules/express/lib/router/index.js:341:12)
    at next (/usr/src/node-red/node_modules/express/lib/router/index.js:275:10)
    at expressInit (/usr/src/node-red/node_modules/express/lib/middleware/init.js:40:5)
    at Layer.handle [as handle_request] (/usr/src/node-red/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/src/node-red/node_modules/express/lib/router/index.js:323:13)
    at /usr/src/node-red/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/node-red/node_modules/express/lib/router/index.js:341:12)
    at next (/usr/src/node-red/node_modules/express/lib/router/index.js:275:10)
    at query (/usr/src/node-red/node_modules/express/lib/middleware/query.js:45:5)
    at Layer.handle [as handle_request] (/usr/src/node-red/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/src/node-red/node_modules/express/lib/router/index.js:323:13)
    at /usr/src/node-red/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/node-red/node_modules/express/lib/router/index.js:341:12)
    at next (/usr/src/node-red/node_modules/express/lib/router/index.js:275:10)
    at Function.handle (/usr/src/node-red/node_modules/express/lib/router/index.js:174:3)
    at Function.handle (/usr/src/node-red/node_modules/express/lib/application.js:174:10)
    at mounted_app (/usr/src/node-red/node_modules/express/lib/application.js:230:10)
    at Layer.handle [as handle_request] (/usr/src/node-red/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/src/node-red/node_modules/express/lib/router/index.js:323:13)
    at /usr/src/node-red/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/node-red/node_modules/express/lib/router/index.js:341:12)
    at next (/usr/src/node-red/node_modules/express/lib/router/index.js:275:10)

According to a developer of NodeRed:

We made some internal changes in Node-RED with how global context is managed - and this error is a side-effect of that.

Using RED.settings.functionGlobalContext as way to access global context was never documented as a suitable way of doing it. The fact these nodes are broken because they took that approach, isn't ideal, but nor have we changed a published API.

We need to think about what to do here - should we revert our change to keep things working, or encourage these nodes to use proper APIs.

Reference: Problem with node-red-contrib-actionflows since upgrade to 2.2.0

Can anyone test if the error still occurs with this fix: #522

Instructions to test this fix are in the PR.

At least it works for my usage with Telegram in pulling mode.

Just tested it and the result seems to be the same:

"Unable to find a valid chat context instance for the selected context provider"

I guess we're not supposed to change any existing configuration, right? Rolling back to the previous version now.

Thanks for looking into it though!

EDIT: Forgot to mention, the drop down menus are working again though. :)

What did you test? May I can reproduce the error on may setup too?

Sorry for the late reply and I have some unfortunate news.

I migrated all my notifications away from telegram towards matrix. It was not related to this error or your addon, I was happily using it for over a year now. So by now I have removed all chatbot instances in nodered and replaced them with matrix nodes.

The test I did was really simple. I upgraded nodered to 2.2.0, applied the fix you provided and tried to send a message with one existing chatbot flow that was working until the update. Really simple flow, just an inject node, and then the usal: conversation node, text node and telegram sender. Nothing too fancy I suppose.

Sorry I couldn't dig deeper, maybe one of the other participants can shed some light on the problem.

@flamingm0e @aschubert @crnah2o @JanickGers85 could you have a look and see if the fix @OidaTiftla provided, works for you?

Okay that's the same thing I tested. Maybe someone else can reproduce it.

For me it seems to work. I can send telegram notification.

@OidaTiftla It's OK for me: I use my bot just to send notifications and it works like a charm, good job!
Tested:

  • message with text
  • message with pic
  • message with video

Any update on this issue? I'm on NR v2.2.0 and having the same problem. I have snapshots sent to my telegram bot when motion is detected on any of my cameras or if someone enters the front door and it stopped working since Feb 2. I'm assuming that's when I updated NR but I didn't realize it until sometime last week.

Any update on this issue? I'm on NR v2.2.0 and having the same problem. I have snapshots sent to my telegram bot when motion is detected on any of my cameras or if someone enters the front door and it stopped working since Feb 2. I'm assuming that's when I updated NR but I didn't realize it until sometime last week.

Exact same issue for me. I'm going to try another telegram node and see if that works.

I've tried installing the fix, but didn't manage to. I'm using HassOS, or however it's calles now (Home Assistant OS) on an Intel NUC. I've tried adding it in different forms to the Node Red addon config (under "npm_packages:") but have not managed to get it to nistall. If anyone has any idea how it could be done, please help. @OidaTiftla, maybe you know how to?

You can try installing the fix with npm. Run the following command in the directory where Node-Red is installed (I'm not sure where the location is in Home Assistant OS):

npm i guidone/node-red-contrib-chatbot#pull/522/head

You can try installing the fix with npm. Run the following command in the directory where Node-Red is installed (I'm not sure where the location is in Home Assistant OS):

npm i guidone/node-red-contrib-chatbot#pull/522/head

Thanks! The "npm i ...." isn't an option in Home Assistant Node Red addon (at least as far as I know), but tried adding it to npm packages in config. It doesn't seem to work, getting errors:
TypeError: RED.settings.functionGlobalContext.get is not a function
and
Missing configuration in Telegram Receiver
for every chatbot node deployed. Will try setting up the config again, see if I messed up somewhere.... It doesn't look like the dev is interested in (t)his project any more, so either I get it working or find another telegram bot node package.

Thanks! The "npm i ...." isn't an option in Home Assistant Node Red addon (at least as far as I know), but tried adding it to npm packages in config. It doesn't seem to work, getting errors: TypeError: RED.settings.functionGlobalContext.get is not a function and Missing configuration in Telegram Receiver for every chatbot node deployed. Will try setting up the config again, see if I messed up somewhere.... It doesn't look like the dev is interested in (t)his project any more, so either I get it working or find another telegram bot node package.

Okay, did you check the logs and is the installation confirmed in the logs? It seems as it is not installed yet.

I currently have two options in mind you can try:

Option 1

As far as I understand Home Assistant OS, it is a Home Assistant Supervised installation and adding the Node-Red Add-On will create a docker container. Can you SSH into the Intel NUC and execute the npm i ... command inside the container?

  • Grab the name of the node-red container with docker ps
  • Then execute the npm-install-command with docker exec [name-of-container] npm i guidone/node-red-contrib-chatbot#pull/522/head and replace [name-of-container] with the name found with the docker ps command

Option 2

I found a configuration parameter init_commands. You may try adding the install command like this:

...
npm_packages:
  - ...
init_commands:
  - npm i guidone/node-red-contrib-chatbot#pull/522/head
...

Hope I could help you. Let me know if it worked.

Hi guys, confirmed the bug also on my side. Reviewing the PR, thanks for it

Thanks! The "npm i ...." isn't an option in Home Assistant Node Red addon (at least as far as I know), but tried adding it to npm packages in config. It doesn't seem to work, getting errors: TypeError: RED.settings.functionGlobalContext.get is not a function and Missing configuration in Telegram Receiver for every chatbot node deployed. Will try setting up the config again, see if I messed up somewhere.... It doesn't look like the dev is interested in (t)his project any more, so either I get it working or find another telegram bot node package.

Okay, did you check the logs and is the installation confirmed in the logs? It seems as it is not installed yet.

I currently have two options in mind you can try:

Option 1

As far as I understand Home Assistant OS, it is a Home Assistant Supervised installation and adding the Node-Red Add-On will create a docker container. Can you SSH into the Intel NUC and execute the npm i ... command inside the container?

* Grab the name of the node-red container with `docker ps`

* Then execute the npm-install-command with `docker exec [name-of-container] npm i guidone/node-red-contrib-chatbot#pull/522/head` and replace `[name-of-container]` with the name found with the `docker ps` command

Option 2

I found a configuration parameter init_commands. You may try adding the install command like this:

...
npm_packages:
  - ...
init_commands:
  - npm i guidone/node-red-contrib-chatbot#pull/522/head
...

Hope I could help you. Let me know if it worked.

Thank you very much for your time and good will.
I've tried the second option; in fact, it was the only option that occurred to me to try and got the errors I mentioned in my previous post. It hadn't occurred to me at all that it could be possible to connect to the add-on as a docker and try npm command directly. I'll try it as soon as I return home tomorrow and get back to you. Thanks once again!

Hi guys, confirmed the bug also on my side. Reviewing the PR, thanks for it

Has the issue been resolved yet? I still am not getting any Telegram notifications and I'm afraid to update NR until it's been fixed.

It's fixed in 0.19.13

It's fixed in 0.19.13

I didn't realize there was an update. It's working like a charm now, thank you!