Share feedback, ideas and get community help

Updated last year

Json response from GPT to Variables

At a glance

The community member has configured an OpenAI block to create a chat completion, which generates a JSON response with "name" and "email" fields. They need to know how to save this response into variables. A community member suggests using JSON.parse({{response}}).name and JSON.parse({{response}}).email to access the name and email values. Another community member confirms that this approach works. The discussion also includes a comment suggesting that using GPT may be a better solution than writing JavaScript code to achieve the same result.

Useful resources
I config OpenAI block to create a chat completion, this will generate a json response like this :

{
"name": "name here",
"email": "email here"
}

I need know how and if is possible save this into to variables.


Here is the flow

https://app.typebot.io/typebots/clrj82g020029rlwrmh7pqx60/edit
Attachment
image.png
V
m
5 comments
JSON.parse({{response}}).name
JSON.parse({{response}}).email
Attachment
image.png
Thanks, I will try...
Works like a charm, thanks @Vilela™
Attachment
image.png
I think soon will be better use GPT than make some JS code to make the same thing...
Add a reply
Sign up and join the conversation on Discord