Member-only story
Adding features to the ChatGPT chatbot for WhatsApp, Messenger, and Telegram
This article is the second part of “Fast deploy a chatbot using ChatGPT and Node-RED for WhatsApp, Messenger, and Telegram”.
So, if you already managed to create your ChatGPT chatbot, then now you might want to make it a bit smarter, using the RedBot features and maybe some other things we will explore.

Most of these features you can find on the platform-specific article for chatbot, but here I’ll implement them with the API.
I’ve also added an OpenAI DALL-E 2 image generation example for the Telegram chatbot here. It’s quite nice.
At the bottom is a link from where you can get the flow and import it to Node-RED, as it’s quite time-consuming and would take a huge article to describe every small step 😵. You can import them to your Node-RED, then read the short description from this article bellow.
OpenAI chat API parameters
First, let’s expose the configurable parameters for the ChatGPT API.
We already got “temperature”, “top_p”, “presence_penalty”, “frequency_penalty”, and “max_tokens” inside the “Config chat model” template, and I would also add some more data inside the “messages”, like the “system” configuration and conversation history for the last few messages to get some contextual data when talking to the chatbot.


You can see the newly updated flow, so, let me explain how it works. It gets a message from the platforms as input, then append the API config to the payload passed to the “http request”.
You can personalize these configs from the “Change model config”.
After that, the history of the conversation is checked, to be exact, the file that contains the conversation, with the filename as “chatId”.json. This is by no means secure, encrypted, and exposes user data such as phone numbers, so I recommend you replace the classic file I/O with a database.
History is now added to the request. Take note that this will use more tokens, as your input will get…