# How can I set a slot value in story itself

**URL:** <https://forum.rasa.com/t/how-can-i-set-a-slot-value-in-story-itself/2184>\
**Category:** Rasa Open Source\
**Created:** [October 25, 2018, 10:54am UTC](https://forum.rasa.com/t/how-can-i-set-a-slot-value-in-story-itself/2184 "2018-10-25T10:54:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![raghavendrav1210](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/raghavendrav1210/32/2235_2.png) [@raghavendrav1210](https://forum.rasa.com/u/raghavendrav1210)\
**Post date:** [October 25, 2018, 10:54am UTC](https://forum.rasa.com/t/how-can-i-set-a-slot-value-in-story-itself/2184/1 "2018-10-25T10:54:34Z")

</div>

Hi there,

Is it possible to set a slot value directly in story. I mean can we inject extra data which is not available from NLU but required in the custom action.

I am trying something like:

## apply\_leave\_vacation

- ApplyLeave{“leaveParam”: “vacation”}
  - slot(“execute”: True)
  - action\_apply\_leave
  - slot{“leaveParam”: “vacation”}

## apply\_leave\_illness

- ApplyLeave{“leaveParam”: “illness”}
  - slot(“execute”: True)
  - action\_apply\_leave
  - slot{“leaveParam”: “Illness”}

can anybody help me to solve this?

@akelad @souvikg10

Regards

---

<div class="post-metadata">

**Author:** ![enryh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/enryh/32/124_2.png) [@enryh](https://forum.rasa.com/u/enryh)\
**Post date:** [October 26, 2018, 3:25pm UTC](https://forum.rasa.com/t/how-can-i-set-a-slot-value-in-story-itself/2184/2 "2018-10-26T15:25:18Z")

</div>

Yes thats possible. Just return it with your customaction as a list

```python
class CustomAction(Action):
	"""
	Perform ...
	"""
	def name(self):
		return 'action_name'

	def run(self, dispatcher, tracker, domain):
                # whatever
		return [ SlotSet('no', str(1210)), 
		         SlotSet('name', 'raghavendrav')
			   ]

```

Cheers, Henry

---

<div class="post-metadata">

**Author:** ![PierrePaul](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/pierrepaul/32/82_2.png) [@PierrePaul](https://forum.rasa.com/u/PierrePaul)\
**Post date:** [October 26, 2018, 7:41pm UTC](https://forum.rasa.com/t/how-can-i-set-a-slot-value-in-story-itself/2184/3 "2018-10-26T19:41:29Z")

</div>

You can’t do it directly from the story, but you can create a custom action to set one or multiple slots at the same time. That custom action can be called from the story.

---

<div class="post-metadata">

**Author:** ![raghavendrav1210](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/raghavendrav1210/32/2235_2.png) [@raghavendrav1210](https://forum.rasa.com/u/raghavendrav1210)\
**Post date:** [October 30, 2018, 8:59am UTC](https://forum.rasa.com/t/how-can-i-set-a-slot-value-in-story-itself/2184/4 "2018-10-30T08:59:44Z")

</div>

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![raghavendrav1210](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/raghavendrav1210/32/2235_2.png) [@raghavendrav1210](https://forum.rasa.com/u/raghavendrav1210)\
**Post date:** [October 30, 2018, 8:59am UTC](https://forum.rasa.com/t/how-can-i-set-a-slot-value-in-story-itself/2184/5 "2018-10-30T08:59:58Z")

</div>

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![stalinsabu](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/stalinsabu/32/876_2.png) [@stalinsabu](https://forum.rasa.com/u/stalinsabu)\
**Post date:** [October 30, 2018, 9:57am UTC](https://forum.rasa.com/t/how-can-i-set-a-slot-value-in-story-itself/2184/6 "2018-10-30T09:57:01Z")

</div>

I dont think thats true

Just type `- slot{“execute”: True}` in the stories before you call your action and it will be set in stories itself.

Try debugging and you will see that the slot changes!

So if the user sends a message without an entity, you can set the default value for your slot

- my\_name\_is
  - slot{“name”: “human”}
  - utter\_hello

But its better to do it with a custom action so you can set your logic, like changing the conversation flow based on the slot. Eg in restaurant bot if there are no seats you can utter “Too many people” else perform action

```
#story_1
* book_for{"number": "20"}
  -slot{"number":20}
  - action_check_seats
  - slot{"available":"No"}
  - utter_sorry_no_seat

#story_2
* book_for{"number": "20"}
  -slot{"number":20}
  - action_check_seats
  - slot{"available":"Yes"}
  - action_book_seat
```

---

<div class="post-metadata">

**Author:** ![sibbsnb](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/sibbsnb/32/2285_2.png) [@sibbsnb](https://forum.rasa.com/u/sibbsnb)\
**Post date:** [October 4, 2020, 6:20pm UTC](https://forum.rasa.com/t/how-can-i-set-a-slot-value-in-story-itself/2184/7 "2020-10-04T18:20:05Z")

</div>

this doesnt work

---

<div class="post-metadata">

**Author:** ![chandimar](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@chandimar](https://forum.rasa.com/u/chandimar)\
**Post date:** [November 4, 2020, 9:47am UTC](https://forum.rasa.com/t/how-can-i-set-a-slot-value-in-story-itself/2184/8 "2020-11-04T09:47:02Z")

</div>

Is this working. Can I change a slot value in my story?
