(Reproducable) Installed node-red-contrib-chatbot which disable/messed up projects

OS: macOS 10.14.6
Node-red: v1.0.3
Node.js: v12.13.0
Running projects.

So I was trying to look into an issue for a user. Somewhere in the process of installing start/stopping NR and removing the node, it lost the connection to projects.

Now everytime I start NR I see in the log:

19 Jan 16:13:48 - [warn] No active project : using default flows file
19 Jan 16:13:48 - [info] Flows file     : /Users/Paul/.node-red/flows_Pauls-mini-4.local.json
19 Jan 16:13:48 - [info] Creating new flow file

and in NR I'm greeted with

How do I fix it so it will use my existing projects?

Has it changed the setting in settings.js? That would be a bit odd.

Click 'open existing project' in the bottom and see where that gets you.

@Colin - No it did not change settings.js - the last mod date on it is Dec 28, 2019
@knolleary, If I open an existing project make a change stop/start NR, the log shows no active project and I get the 'Hello we have intrduced projects...' again

I went and looked at .config.json - at the end of the file I see:

 "projects": {
  "projects": {}
 }

so I went into Timemachine (on my mac) and grabbed a copy from yesterday and at the end I see:

"projects": {
  "projects": {
   "RFID-reader": {
    "credentialSecret": false
   },
   "The-Project": {
    "credentialSecret": false
   },
   "test-area": {
    "credentialSecret": false
   },
   "Davids-CHAT": {
    "credentialSecret": false
   },
   "test_upgrade": {
    "credentialSecret": false
   },
   "Fire-Training": {
    "credentialSecret": false
   },
   "Music_box": {
    "credentialSecret": false
   },
   "GreenHouse": {
    "credentialSecret": false
   },
   "stupidhead": {
    "credentialSecret": false
   },
   "UI_testing": {
    "credentialSecret": false
   },
   "Abel": {
    "credentialSecret": false
   },
   "linechart": {
    "credentialSecret": false
   },
   "WemosBackupRestore": {
    "credentialSecret": false
   },
   "david-Weather": {
    "credentialSecret": false
   },
   "DavePlaytime": {
    "credentialSecret": false
   },
   "musicbox": {
    "credentialSecret": false
   },
   "DavidDeepSleep": {
    "credentialSecret": false
   },
   "debug_mqtt": {
    "credentialSecret": false
   },
   "coffee": {
    "credentialSecret": false
   },
   "a-fix-mqtt": {
    "credentialSecret": false
   },
   "deleteeme": {
    "credentialSecret": false
   },
   "PMB_Scrapr": {
    "credentialSecret": false
   },
   "plane2": {
    "credentialSecret": false
   },
   "SVG_testing": {
    "credentialSecret": false
   },
   "Outdoor_Survival": {
    "credentialSecret": false
   },
   "David_musicbox": {
    "credentialSecret": false
   },
   "Dave_musicbox2": {
    "credentialSecret": false
   },
   "AA_testing": {
    "credentialSecret": false
   },
   "FCATV-Telegram": {
    "credentialSecret": false
   },
   "MySQL_test": {
    "credentialSecret": false
   },
   "A_flow_module_finder": {
    "credentialSecret": false
   },
   "aTelegram_group": {
    "credentialSecret": false
   },
   "a-a-fs-test": {
    "credentialSecret": false
   },
   "M4": {
    "credentialSecret": false
   },
   "aaxterm": {
    "credentialSecret": false
   },
   "Find_templates": {
    "credentialSecret": false
   }
  },
  "activeProject": "AA_testing"
 },

(yes I have a lot of projects)

I'm going replace the .config.json and see what happens.

Well that got me out of that mess. Now to try installing the node again and see if it happens again.

Is there a deficiency in the system, if you loose config.json you lose the projects?

Not lost.... just misplaced :-)...(the file are still present - just the index was lost for some reason) - and yes - may be a bug if we can find out how it happened and can reproduce it.

.config.json contains all your runtime configuration. So yes, if it is lost, then you lose configuration. You don't lose any projects or data.

There is an item on the backlog to split some of runtime configuration into their own files to minimise any issue if one file gets corrupted.

I realised it wouldn't have removed the files, but how do you re-index them?

Well I have been able to reproduce it but need to build a step by step. I'll do it later since I'm going to go for a family swim with the grandkids!

Reproducable - here is how I can reproduce it

WARNING: before doing this, go to your .node-red directory and backup your .config.json

  1. stop NR
  2. npm remove node-red-contrib-chatbot
  3. start NR
  4. open project
  5. import test flow - get errors missing nodes
  6. in palette add node-red-contrib-chatbot
  • note screen grey, node moved out of the flow to top left - page not active
  1. refresh screen
  2. re-import flow
  3. deploy
  4. shutdown NR
  5. close browser window
  • note at this point the .config.json file is still good.
  1. start NR - .config.json file good - projects ok
  2. stop/start NR
    At this point the .config.json file updated and projects gone

Sadly, I can't say I'm surprised here. I've used redbot/node-red-contrib-chatbot in the past, but right now it's not in use in any of my flows no matter the benefits it would bring me. I've tried to understand how the code functions, but so far without much luck. It's incredibly powerful if/when it works, but for example the discord nodes (that have now been moved to their own package due to incompatibility with some platforms) will cause issues when a flow branches. (Note that the discord nodes won't show up in the flow library, the package published to NPM has a readme missing. I filled an issue and it has been added to the backlog on trello, will likely have to wait to a further version.)

And because of the complexity of the code it's hard to write PRs for it. Every redbot entry node puts a set of functions on the message object to handle the communication, as well as introduce its own messaging context. Depending on the communication type (slack/telegram/facebook messenger/discord/...) these functions are sync/async. Some can be cloned, others can't, thus cloneMessage running into trouble, especially on branching.

For each communication type a bot is defined, either development or production. The bot settings are stored in the functionGlobalContext in settings.js, which the node will edit. To later edit your bot settings you're instructed to go to your settings.js file to change them according to your needs. Figuring out what does what/what is located where is particularly hard as some core parts have been moved to their own package/repository. As a result it will be hard to figure out where this exact issue was caused, and whether it goes wrong on a Node-RED level or somewhere in the Redbot packages due to editing files. Iirc there's a number of injects taking place by the Redbot core on start/restart of Node-RED, so it could be there, but honestly I just tried to read through the code and I can't find where it even happens.

I fully agree. I tried to use it when it first came out but it had almost no documentation then. I've tried a few times since but it is just too complex without any real need. I got the feeling from the developer that it was part of a custom build of Node-RED that they used commercially & therefore there was little interest in fixing issues when used "normally".

I use the standard telegram node.

I have weird issue here too: Telegram error when sending message
Which node do you use right now?

@knolleary/@dceejay - bug in the node (in which case I'll open an issue) or issue with NR?

@kanke - see your thread for answer to your query.

Never really had any problems with it and it seems to do what I need it to.

I also use the Rivescript node for helping with conversational bot interfaces.

3 Likes

I agree with Julian - never had any problems with node-red-contrib-telegrambot
although I did have issues with chatbot and gave up trying to figure it out.

2 Likes

migrated over to this node, works fine. thank you

1 Like

node-red-contrib-telegrambot worked most of time, but do got error from time to time.

Screen Shot 2020-01-23 at 9.51.54 PM

from log:

23 Jan 21:49:53 - [warn] [telegram bot:ea007ac4.9f7f88] ETELEGRAM: 500 Internal server error: restart
23 Jan 21:49:53 - [warn] [telegram bot:ea007ac4.9f7f88] Unknown error. Trying again.
23 Jan 21:49:57 - [warn] [telegram bot:ea007ac4.9f7f88] ETELEGRAM: 502 Bad Gateway
23 Jan 21:49:57 - [warn] [telegram bot:ea007ac4.9f7f88] Unknown error. Trying again.