I’ve set up a webhook (and chat trigger) that connects to a Question and Answer Chain. I’ve not included them here, because i’m not sure what people can see regarding credentials etc.
When I test the flow using the ‘Chat’ function (next to the test button), responses I receive are normal text:
“Hi”
“Hello, how are you” (Ai)
However, when I set up the webhook or chat to the AI through the public chat website, the JSON of the response will be returned:
Webhook
“hi”
{“text”: “Hello, how are you” }
Chat
hi
{“response”: {“text”: “Hello, how are you” }}
I’ve tried to set an item as just the output of {{$json.response.text}} from the AI, and then returning the item in the webhook, but that either fails as ‘wrong json format’ (if responding with JSON option in Return Webhook) or the webhook won’t reply at all (if responding with text option in Return Webhook).
Any thoughts? What should I be converting the JSON to before parsing it to the webhook, and what should I be changing about the data in the public chat trigger website?
Thanks for posting here and welcome to the community!
The good news is, you can share your workflow here without having to worry about your credentials. They will automatically be excluded when downloading your workflow from you workspace. Simply paste the JSON here in between two block quotes (```). Then we can take a look
I’m happy to post my first message ( not the real one but I’ve create a new pro account ) to help with this issue that I was also stuck on.
I used a code.node on js and used this type of code:
return items.map(item => {
// Access the `text` property in the `response` object
const text = item.json.response.text;
// Return a new object that contains only the text
return {json: {text}};
});
(coded by chatGPT haha)
With the Respond mode set to “When the last node finishes,” it will only keep the result of the code.
I’ve included a screenshot of my public chat hosted by n8n.