# \[SOLVED\] Is it possible to set slot value from within stories file?

**URL:** <https://forum.rasa.com/t/solved-is-it-possible-to-set-slot-value-from-within-stories-file/1257>\
**Category:** Rasa Open Source\
**Created:** [September 19, 2018, 6:58pm UTC](https://forum.rasa.com/t/solved-is-it-possible-to-set-slot-value-from-within-stories-file/1257 "2018-09-19T18:58:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fade2black](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/fade2black/32/1922_2.png) [@fade2black](https://forum.rasa.com/u/fade2black)\
**Post date:** [September 19, 2018, 6:58pm UTC](https://forum.rasa.com/t/solved-is-it-possible-to-set-slot-value-from-within-stories-file/1257/1 "2018-09-19T18:58:45Z")

</div>

Suppose I have the following story inside my `stories.md` fil:

```auto
## say hello
* greet
  - utter_greet
  - utter_ask_name
* inform{"name":"John"}
  - set_user_name
  - utter_propose_help

```

Q1: I can write a custom action `set_user_name` where I programmatically can fill the slot `name` with user’s name. Isn’t it possible to do directly from `stories.md`?

Q2: Suppose I decided to fill slots from my code. The user my enter different text such as: `My name is John`, `John`, `John Lennon`, `My friends call me John`, etc. How do we extract the name `John` from the input. Do we have to extract, say, using spaCy, or is there any other RASA-way to perform this task? Assume I don’t use Python to process and my custom action is on another server.

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [September 20, 2018, 8:54am UTC](https://forum.rasa.com/t/solved-is-it-possible-to-set-slot-value-from-within-stories-file/1257/2 "2018-09-20T08:54:21Z")

</div>

So if both your entity and your slot have the same name, then the slot should get filled automatically. So yeah you’d use an entity extractor, you can use both `ner_spacy` or `ner_crf` for that.

---

<div class="post-metadata">

**Author:** ![fade2black](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/fade2black/32/1922_2.png) [@fade2black](https://forum.rasa.com/u/fade2black)\
**Post date:** [September 20, 2018, 11:13am UTC](https://forum.rasa.com/t/solved-is-it-possible-to-set-slot-value-from-within-stories-file/1257/3 "2018-09-20T11:13:25Z")

</div>

It does not work. The following are my files:

**domain.yml**

```auto
entity:
  - name

slots:
  name:
    type: text

intents:
  - greet
  - goodbye
  - propose_help
  - inform

templates:
  utter_greet:
    - "hello"
  utter_goodbye:
    - "Goodbye"
  utter_ask_name:
    - "What is your name?"
  utter_propose_help:
    - "{name}, how can I help you?"

actions:
  - utter_greet
  - utter_goodbye
  - utter_ask_name
  - set_user_name
  - utter_propose_help

```

**srories.md**

```auto
## say hello
* greet
  - utter_greet
  - utter_ask_name
* inform{"name":"John"}
  - utter_propose_help

## say goodbye
* goodbye
  - utter_goodbye

```

**nlu\_config.md**

```auto
language: "en"

pipeline:
- name: "nlp_spacy"
- name: "tokenizer_spacy"
- name: "intent_entity_featurizer_regex"
- name: "intent_featurizer_spacy"
- name: "ner_crf"
- name: "ner_synonyms"
- name: "intent_classifier_sklearn"

```

This is how I train NLU

```auto
from rasa_nlu.training_data import load_data
from rasa_nlu import config
from rasa_nlu.model import Trainer
from rasa_nlu.config import RasaNLUModelConfig

def train():
    trainer = Trainer(config.load('./nlu_config.md'))
    interpreter = trainer.train(load_data('./data/nlu.md'))
    model_directory = trainer.persist('./models/nlu/', fixed_model_name = 'simplebot')

if __name__ == ' __main__':
    train()

```

It does not set the slot `name`. But when I add a custom action like this

```auto
* greet
  - utter_greet
  - utter_ask_name
* inform{"name":"Bayram"}
  - set_user_name
  - utter_propose_help

```

and set the `name` in the JSON response it works.

---

<div class="post-metadata">

**Author:** ![fade2black](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/fade2black/32/1922_2.png) [@fade2black](https://forum.rasa.com/u/fade2black)\
**Post date:** [September 20, 2018, 12:31pm UTC](https://forum.rasa.com/t/solved-is-it-possible-to-set-slot-value-from-within-stories-file/1257/4 "2018-09-20T12:31:39Z")

</div>

Then I added the following lines into my `nlu.md` file

```auto
## intent:inform
- My name is [John](name)
- My name is [Paul](name)

```

It fills the slot ‘name’ only when I enter `My name is John` and `My name is Paul`. What about other names? Or what if user simply enters `John`? Or what about other patters: `Call me John`? I guess I need provide more example to train it, almost every possible scenario?

**I needed MORE!!! data, in particular more examples for `nlu.md`.**

---

<div class="post-metadata">

**Author:** ![fade2black](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/fade2black/32/1922_2.png) [@fade2black](https://forum.rasa.com/u/fade2black)\
**Post date:** [September 20, 2018, 8:39pm UTC](https://forum.rasa.com/t/solved-is-it-possible-to-set-slot-value-from-within-stories-file/1257/6 "2018-09-20T20:39:52Z")

</div>

I was simply doing experiments trying to figure out how to use/fill slots. It turned out I need at least 10 NLU examples before the bot started to understand.

As for the chatito, an interesting project. I’ll have a look. Thank you for sharing.  
🙂

---

<div class="post-metadata">

**Author:** ![Abir](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/abir/32/771_2.png) [@Abir](https://forum.rasa.com/u/Abir)\
**Post date:** [September 21, 2018, 6:41am UTC](https://forum.rasa.com/t/solved-is-it-possible-to-set-slot-value-from-within-stories-file/1257/7 "2018-09-21T06:41:17Z")

</div>

You should first look into your NLU data . Your NLU\_MODEL isn’t strong enough to capture intent/entities of every string , i would suggest you exec you nlu model separately and try to add data so that it’s smart enough to classify intents and extract entities. After doing this move on to using it in your stories , that way you will have a systematic debugging
