Write Function Node Code with ChatGPT

We've been working on a way to get ChatGPT to write Node-RED function code, directly within the Node-RED interface. You can describe the code you need and in that magic-like way LLMs work, it writes the code you need (most of the time). We've open-sourced the project and wanted to share where we are with the community. Chat GPT in Node-RED Function Nodes • FlowForge


For info, the node is called @flowforge/node-red-function-gpt :smiley:

Thanks to the entire team for developing this, and sharing it with the community!

I am a fan of chatgpt (at least for some areas that it know a lot about) so looking forward to start using this in Node-RED. BTW The demo looks very nice!!

I "think" I have setup my API key correctly, and entered all my info into the config screen. But I keep getting this error:


Do you have any tips I could try?

Two other remarks:

  • A "test connection" button in the config screen might be useful.
  • Is it the intention to keep this in the future as a separate node, or will it be integrated later on into the standard function node? In case it will stay a separate node, my feature request from some time ago might be useful. Because if the function node backend part could be reused, that would simplify maintaince for all of us.


Not a good start @robmarcer :astonished:

After installing the node via 'Manage Palette', I see this this in the debug panel...


Trying to use the node, I see this...

Same result after restarting Node-RED.

OS - Canonical-Ubuntu-22.04-aarch64-2023.02.15-0
Oracle cloud VM server
Node-RED v3.0.2
node v18.15.0

Yes, I can't wait to sit in an A350 and ask it to fly me to the Moon :stuck_out_tongue_winking_eye:

I'd settle for asking it how I can make enough money to afford an A350! :grin:

1 Like

Well I know from personal experience that chatgpt is quite good in writing Python, so I assume it is also good in writing Javascript since there is a lot of material around from which 'it' can learn. Therefore I am quite sure it will (now or perhaps in the near future) be a great help for writing function nodes. Of course manual tweaking might be necessary, but for people with very basic Javascript skills this node might be very welcome...

And I also learned that the quality of its answers are directly proportional to the quality of your questions :wink:


It can write pretty good JS, I've used it a number of times already. Though it certainly does not always produce the "best" or optimal code. Nor does it always get it right either. But it seems to get close enough to give you enough clues at least. But then, I'm not generally asking it for simple things since I probably already know those answers or can easily look it up in MDN. I'm asking about things I've not found an easy answer to.

1 Like

Well, Douglas Adams knew that all along :stuck_out_tongue_winking_eye:


@robmarcer Any update on getting this node working?

I can make it work under windows but not on a raspberry pi. Have left comments on Github.

Hi Paul, it looks as if there is an ongoing discussion on Github about this issue which is worth monitoring - common.notification.error · Issue #16 · flowforge/node-red-function-gpt · GitHub

Thanks @robmarcer, I've added to the Github issue.

Updated the latest version of the node, and the previous errors have cleared OK, but I'm now getting this instead...


This is in response to my very first question :astonished:

I'm using Chat GPT model gpt-3.5-turbo, is that correct?

That is a good sign the nodes issues have been resolved Paul as you are seeing chatgpt response.

Does this help: Error Code 429 - You exceeded your current quota, please check your plan and billing details. | OpenAI Help Center

Thanks Steve

Strange that my free trial expired 1st April when I only signed up for the api on the 3rd May :flushed:

But it looks as though there isn't a free tier, and I'd need to sign up to a plan to actually use it.

Doesn't surprise me that OpenAI want to tighten the screws on monetisation That is until most governments legislate it into extinction...


Not going to happen. Too many are already using it! Pandora's box is well and truly open. And by the time any government has organised itself to even think about it beyond vague, generic statements, it will be far too late to shut down it and its myriad similar services.

I've been reminding various people in the NHS recently about what is and isn't appropriate use for a public AI tool that learns from its inputs. There is no doubt that it is a fantastic tool - but only if you think carefully about what you share with it and how you treat its answers.

1 Like