# How to load Open API response to a variable which is then displayed

**URL:** https://community.weweb.io/t/how-to-load-open-api-response-to-a-variable-which-is-then-displayed/5209
**Category:** How do I?
**Created:** [November 4, 2023, 6:52pm UTC](https://community.weweb.io/t/how-to-load-open-api-response-to-a-variable-which-is-then-displayed/5209 "2023-11-04T18:52:26Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Dervish99](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@Dervish99](https://community.weweb.io/u/Dervish99)
#### Post date: [November 4, 2023, 6:52pm UTC](https://community.weweb.io/t/how-to-load-open-api-response-to-a-variable-which-is-then-displayed/5209/1 "2023-11-04T18:52:26Z")

</div>

I followed the “OpenAI plugin in Weweb- Live Demo” to make a simple question and answer app to learn how this works.

I have successfully retrieved the response:  
'‘Call openAI.result.choices[0].message.content’

How do I capture this response into a variable, and then display it in text field?

The video shows that the next steps in the workflow are:

1. Return value
2. Change value variable

But doesnt go into the detail, i’ve been trying for hours to figure out which forumla to use and where with no success!

---

<div class="post-metadata">

### Author: ![luka](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/luka/32/1571_2.png) [@luka](https://community.weweb.io/u/luka)
#### Post date: [November 5, 2023, 1:40pm UTC](https://community.weweb.io/t/how-to-load-open-api-response-to-a-variable-which-is-then-displayed/5209/2 "2023-11-05T13:40:38Z")

</div>

If you have received the response from OpenAI you can use return value or change variable value actions and as the value you can bind to the result of a previous action

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/1/1cbb0e8160432d1bab0a7ab62798f672e9196417.png)

---

<div class="post-metadata">

### Author: ![Dervish99](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@Dervish99](https://community.weweb.io/u/Dervish99)
#### Post date: [November 5, 2023, 6:51pm UTC](https://community.weweb.io/t/how-to-load-open-api-response-to-a-variable-which-is-then-displayed/5209/3 "2023-11-05T18:51:55Z")

</div>

I have the result.

How do I bind the value from the message I received to a variable?

I did a drill down like what shows on your screen shot and the following shows the result:

Call openAI.result.choices[0].message.content

How do bind that to a variable.

I tried the following in the function box:

My variable = Call openAI.result.choices[0].message.content

But I must be missing something.

---

<div class="post-metadata">

### Author: ![raydeck](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raydeck/32/384_2.png) [@raydeck](https://community.weweb.io/u/raydeck)
#### Post date: [November 5, 2023, 10:01pm UTC](https://community.weweb.io/t/how-to-load-open-api-response-to-a-variable-which-is-then-displayed/5209/4 "2023-11-05T22:01:35Z")

</div>

Have you tried the “change variable value” action step after you complete your chat request? Here’s a quick screenshot of how that would look:

 ![Screenshot 2023-11-05 at 5.00.54 PM](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/7/7a35d160592d0f2385a36d1fe47d34fba184c055.png)

---

<div class="post-metadata">

### Author: ![Dervish99](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@Dervish99](https://community.weweb.io/u/Dervish99)
#### Post date: [November 6, 2023, 7:28pm UTC](https://community.weweb.io/t/how-to-load-open-api-response-to-a-variable-which-is-then-displayed/5209/5 "2023-11-06T19:28:08Z")

</div>

Hi Ray,

Yes. It’s that formula inside that second action that I’m stuck with.

How do I retrieve the message and populate in the second action?

---

<div class="post-metadata">

### Author: ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)
#### Post date: [November 7, 2023, 11:08pm UTC](https://community.weweb.io/t/how-to-load-open-api-response-to-a-variable-which-is-then-displayed/5209/6 "2023-11-07T23:08:44Z")

</div>

Hi @Dervish99 👋

Before you can use the result from action 1 in action 2, you will need to test action 1 to get a result. Then, you will be able to access that result and use it in action 2.

Here’s an example of a [file upload workflow](https://docs.weweb.io/workflows/actions/upload-file.html#file-upload-workflow) that uses similar logic.

---

<div class="post-metadata">

### Author: ![Dervish99](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@Dervish99](https://community.weweb.io/u/Dervish99)
#### Post date: [November 11, 2023, 3:45pm UTC](https://community.weweb.io/t/how-to-load-open-api-response-to-a-variable-which-is-then-displayed/5209/7 "2023-11-11T15:45:10Z")

</div>

Thank you Joyce, after following your link, i go to the solution via a similar doc.

For other users benefit, the solution was to:

1. Capture the OPENAI response from the workflow, by selecting the path in the ‘context’ next to the foruma, the path can be seen in the formula box,
2. and then assigning this to the ‘Change Value Variable’ . The examples online had "return a value’ step instead. which i’m not show how is used, anyway using the below it worked. Hope it helps:

**Overview of workflow:**

 ![Workflow](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/2/2515b885abca0aaaae704ff6f1c0bc93f74cb887.png)

**Details of the third action:**

 ![workflow step details](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/2/289b416c9e3c6307e4a422523d96a7fb7a14d66b.png)

---

<div class="post-metadata">

### Author: ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)
#### Post date: [November 18, 2023, 11:11am UTC](https://community.weweb.io/t/how-to-load-open-api-response-to-a-variable-which-is-then-displayed/5209/8 "2023-11-18T11:11:53Z")

</div>

Awesome! Thanks a lot for taking the time to share the solution for this use case as well, I’m sure it will help future readers 😊

---

<div class="post-metadata">

### Author: ![rayanenocode](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/rayanenocode/32/13166_2.png) [@rayanenocode](https://community.weweb.io/u/rayanenocode)
#### Post date: [November 19, 2023, 1:32pm UTC](https://community.weweb.io/t/how-to-load-open-api-response-to-a-variable-which-is-then-displayed/5209/9 "2023-11-19T13:32:32Z")

</div>

“change a variable” then select your result from open ai api call, then bind your text on your page with the variable.
