# NPC returns a variable value

**URL:** https://forum.convai.com/t/npc-returns-a-variable-value/2031
**Category:** Unity SDK
**Tags:** question, unity
**Created:** [October 29, 2024, 3:18pm UTC](https://forum.convai.com/t/npc-returns-a-variable-value/2031 "2024-10-29T15:18:29Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)
#### Post date: [October 29, 2024, 3:18pm UTC](https://forum.convai.com/t/npc-returns-a-variable-value/2031/1 "2024-10-29T15:18:29Z")

</div>

**Original Discord Post by mattiavitali | 2024-10-29 15:18:29**

Hi, I’m working on creating an application using Convai NPC. I noticed that I can activate functions through the start and end events in narrative design. However, I haven’t found anything about returning a value. Is it possible for the Convai NPC to return one or more values, allowing me to avoid a more hard-coded approach?

---

<div class="post-metadata">

### Author: ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)
#### Post date: [October 29, 2024, 4:32pm UTC](https://forum.convai.com/t/npc-returns-a-variable-value/2031/2 "2024-10-29T16:32:34Z")

</div>

**Reply by k3kalinix | 2024-10-29 16:32:34**

Hello \<@498630998481829898\> 👋🏻,

Could you please share an example?

---

<div class="post-metadata">

### Author: ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)
#### Post date: [October 29, 2024, 4:58pm UTC](https://forum.convai.com/t/npc-returns-a-variable-value/2031/3 "2024-10-29T16:58:12Z")

</div>

**Reply by mattiavitali | 2024-10-29 16:58:12**

hello \<@1023671043287699568\> sure there it is:

Example: I ask the NPC to recommend a place for holidays, and it suggests “LocationVariable”. Right after, I want to trigger a function in the narrative design section end event and use the “LocationVariable” that the NPC returned. I was wondering if there’s a way to determine a variable directly, or if I need to work around the issue by parsing the strings in the NPC’s response.

---

<div class="post-metadata">

### Author: ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)
#### Post date: [October 30, 2024, 9:39am UTC](https://forum.convai.com/t/npc-returns-a-variable-value/2031/4 "2024-10-30T09:39:02Z")

</div>

**Reply by mattiavitali | 2024-10-30 09:39:02**

\<@1023671043287699568\> Sorry if I’m being too pushy, but I need to know this to structure my next implementation at work. If you can, please respond ASAP.

---

<div class="post-metadata">

### Author: ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)
#### Post date: [October 31, 2024, 8:33am UTC](https://forum.convai.com/t/npc-returns-a-variable-value/2031/5 "2024-10-31T08:33:57Z")

</div>

**Replying to mattiavitali’s Message**

> **Reply by mattiavitali | 2024-10-29 16:58:12**  
> hello \<@1023671043287699568\> sure there it is:

Example: I ask the NPC to recommend a place for holidays, and it suggests “LocationVariable”. Right after, I want to trigger a function in the narrative design section end event and use the “LocationVariable” that the NPC returned. I was wondering if there’s a way to determine a variable directly, or if I need to work around the issue by parsing the strings in the NPC’s response.

**Reply by k3kalinix | 2024-10-31 08:33:57**

Unfortunately, you have to find it, but if you want to update the variable dynamically you can check our Narrative Design Keys,

> **[Narrative Design Keys | Documentation](https://docs.convai.com/api-docs/plugins-and-integrations/unity-plugin/adding-narrative-design-to-your-character/narrative-design-keys)**
>
> This guide shows how to dynamically pass variables to the Narrative Design section and triggers.

**Embedded Content:**  
**Narrative Design Keys | Documentation**  
This guide shows how to dynamically pass variables to the Narrative Design section and triggers.  
Link: [Narrative Design Keys | Documentation](https://docs.convai.com/api-docs/plugins-and-integrations/unity-plugin/adding-narrative-design-to-your-character/narrative-design-keys)

 ![Thumbnail](https://canada1.discourse-cdn.com/flex004/uploads/convai/original/2X/6/61b8a42cbd4829903ff9db6b4fc8facda57743f9.png)

---

<div class="post-metadata">

### Author: ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)
#### Post date: [November 25, 2024, 12:11pm UTC](https://forum.convai.com/t/npc-returns-a-variable-value/2031/6 "2024-11-25T12:11:20Z")

</div>

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