OpenAI not receicving JSON data from previous node

Describe the problem/error/question

Im currently using the openAI node to send a text message to the system. I am sending the previous nodes JSON data, but the openai response says that im only sending {{ $json }} instead of the actual output. im trying to do some basic data summary with the previous jsons output which does not seem to be sending out to the chat node. I tried making another workflow as well, and deleted and put the node in place.

What is the error message (if any)?

i added a 5 second wait period, as i saw that on another post with a similar problem but it didnt fix it. still says:

"It appears the JSON data you've shared is represented as `[object Object]`, which means I can't directly see the rankings and details. ```
It looks like there was an error or malfunction with the provided weather data. The input reads as "[object Object]," which suggests that a non-textual data structure, likely an object, was passed through when textual weather data was expected.

Please provide the specific weather details or a clearer text input, and I'd be happy to help you review and summarize the weather information.

Its not a direct error message, but the message response says its not getting the information.

Please share your workflow

Share the output returned by the last node

[
  {
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "It looks like there was an error or malfunction with the provided weather data. The input reads as \"[object Object],\" which suggests that a non-textual data structure, likely an object, was passed through when textual weather data was expected.\n\nPlease provide the specific weather details or a clearer text input, and I'd be happy to help you review and summarize the weather information.",
      "refusal": null
    },
    "logprobs": null,
    "finish_reason": "stop"
  }
]

Information on your n8n setup

  • n8n version: 1.55.3
  • Database (default: SQLite): SQlite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own,main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system:

Hi Everyone,

I do want to admit i am not a pro at all at coding. I did some googling, and i saw the javascript code to make a JSON into a string. i tested it out, and if i make the JSON into a string, it is able to send the information to the openai model.

{{ JSON.stringify($json.weather_report) }}

Maybe this can help provide some more info as to why the json data is not being sent to openai raw?

1 Like

Hi @YellowRiverCar, glad you managed to find a solution!

n8n displays [object, object] in certain scenarios, like in this case when you’re trying to insert an object or an array where a string is expected (OpenAI expects a string as a message). So best is to use {{ JSON.stringify($json.items) }} :slight_smile:

1 Like

Ok that makes sense. I’m not sure if this is in the documentation, but might be best to put it somewhere for other users to know as well. I saw it come up a few times on the forums with no solid answers. Thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.