Can't get Open AI input and output to work the way I want

So I’m running an AI chatbot from my website to a webhook that goes to an OpenAI message a model. First off, I have {{$json[“message”]}} inside the OpenAI node to ask the model the question from the chatbot, which doesnt seem to work.

Second, no matter how hard I try (Code Node, Set Node, Filter Node) I cannot seem to extract ONLY the text response from OpenAI’s response. Either I get all the raw code, or it comes out as undefined or empty. Here are some screenshots showing the workflow working, but not as intended. Here is the code I used for the Code Node and here is the Open AI output:

output
0 id:msg_0cc9551e5829c33e006902b9966f7081909d327d17b7d4e07f

and here is the code I was using for java: let assistantText = “”;

// Return the assistant text as JSON
return [
{
json: {
responseText: assistantText
}
}
]

Where am I going wrong?

did you try with AI Agent? then choose openAI as the ai model for that agent. usually it works, but also check the output of the webhook, make sure its not empty.