Hello everyone,
I am working on an AI chatbot project for Telegram that acts as an investment and business development consultant. The goal is for the bot to gather specific information from a client by asking a series of 21 sequential questions. After all questions have been answered, the bot sends a final message stating that “the consultant team is reviewing your request.”
My Current Scenario
To achieve this, I have built a scenario with a memory function to keep track of the conversation. The scenario is split into two main paths based on whether a user is new or existing.
-
Trigger: Telegram Bot - Watch Updates.
-
Memory: Google Sheets, where I store the
ChatIDand aMessagesJSONcolumn to save the complete conversation log. -
Parsing: JSON - Parse JSON, to convert the
MessagesJSONstring from Google Sheets into a usable data structure. -
AI: I use ChatGPT to dynamically generate questions based on the conversation history.
-
Updating: Google Sheets - Update a Row, to update the
MessagesJSONcolumn with both the user’s responses and the bot’s replies.
The Current Problem: ‘Invalid array’ Error
I am encountering a recurring error in the Google Sheets - Update a Row module, which follows the ChatGPT module.
The error message is: DataError: Function 'add' finished with error! Invalid array.
The add function is supposed to append a new message to the conversation history array, but it seems to be receiving an invalid array. This happens even though I am correctly storing the conversation log in a variable named MessagesArray and passing it to the add function, as shown in the formula:
{{add(MessagesArray, {"role": "assistant", "content": ...})}}
I have checked and corrected several syntax errors, but the Invalid array error persists.
My Goal: I need help in resolving this final error to get the chatbot working properly so it can complete its dialogue with the client. Any advice on the cause of this error or suggestions for improving the scenario would be greatly appreciated.
Thank you all!