# Setting Slots within Form Action

**URL:** <https://forum.rasa.com/t/setting-slots-within-form-action/34179>\
**Category:** Rasa Open Source\
**Created:** [September 23, 2020, 4:31pm UTC](https://forum.rasa.com/t/setting-slots-within-form-action/34179 "2020-09-23T16:31:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adboio](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/adboio/32/11034_2.png) [@adboio](https://forum.rasa.com/u/adboio)\
**Post date:** [September 23, 2020, 4:31pm UTC](https://forum.rasa.com/t/setting-slots-within-form-action/34179/1 "2020-09-23T16:31:18Z")

</div>

Hi everyone! I’m trying to set slots via a Form Action but running into some trouble.

For a bit of background info, the bot’s purpose is to help users set appointments. An example conversation might look like this:

- Bot: Hi, this is Adam from X. Are you available to chat today regarding Y?
- User: Yes
- Bot: Great, when works best for you?
- User: Let’s talk tomorrow at 5pm
- Bot: Perfect. We’ll call you tomorrow at 5!

I’m using Duckling to extract the time from messages, but the problem is sometimes (unlike the example above) users will simply say they want to talk “tomorrow” rather than a specific time such as “tomorrow at 5pm.” In these cases, we need to save tomorrow’s date, then ask for a specific time as well.

So far, my solution to handle this has been:

Create 4 slots:

- **time** - _this is the one Duckling will extract parsed times to_
- **call\_date** - _the date a call will happen_
- **call\_hhmmss** - _the time a call will happen_
- **call\_time** - _the full timestamp for when a call should happen_

Use some custom logic in the `required_slots` function to determine if a date and/or time have been extracted, and save these values along the way. [(Click here to see the code for my required\_slots function)](https://gist.github.com/adboio/231081db41bf02bbd42231af280be6f6)

However, this logic requires me to set slots along the way, and I’m not actually sure if that’s possible within the `required_slots` function. In my code you can see quite a few `SlotSet(name, value)` calls, but looking through the debugging info it appears they don’t do anything.

Some research on the forums shows `SlotSet` (or a list of `SlotSet`s) is usually returned by a custom action, but I can’t return that here because the `required_slots` function needs to return a list of the required slots.

Is there any way I can actually set slot values on the client side from within this function? Or does anyone have any suggestions on how else I can achieve this? I believe I also saw a `tracker._set_slot()` function somewhere, but it looked like that only set the slots on the server-side.

Thanks everyone!

---

<div class="post-metadata">

**Author:** ![adboio](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/adboio/32/11034_2.png) [@adboio](https://forum.rasa.com/u/adboio)\
**Post date:** [September 23, 2020, 4:46pm UTC](https://forum.rasa.com/t/setting-slots-within-form-action/34179/2 "2020-09-23T16:46:03Z")

</div>

I looked around a bit more into how I could execute custom actions while a form is active, and found [this forum post](http://forum.rasa.com/t/using-custom-actions-instead-of-utter-ask-templates-in-forms/2667/8) in which it is suggested you override the `request_next_slot` function to accomplish things like this.

Is that considered good practice, or is there a better way?

---

<div class="post-metadata">

**Author:** ![adboio](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/adboio/32/11034_2.png) [@adboio](https://forum.rasa.com/u/adboio)\
**Post date:** [September 25, 2020, 4:54pm UTC](https://forum.rasa.com/t/setting-slots-within-form-action/34179/3 "2020-09-25T16:54:00Z")

</div>

For anyone else that might have this issue:

I was able to accomplish what I needed by overriding the `request_next_slot()` function, essentially using the same logic I was trying to use in `required_slots()`.

---

<div class="post-metadata">

**Author:** ![jyotiupd](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/jyotiupd/32/17178_2.png) [@jyotiupd](https://forum.rasa.com/u/jyotiupd)\
**Post date:** [September 20, 2021, 7:27am UTC](https://forum.rasa.com/t/setting-slots-within-form-action/34179/4 "2021-09-20T07:27:54Z")

</div>

@adboio could you please detail out the solution. I am working on similar kind of problem where SlotSet isn’t working in formActions.
