# Using custom slot mappings with forms

**URL:** <https://forum.rasa.com/t/using-custom-slot-mappings-with-forms/23041>\
**Category:** Getting Started with Rasa\
**Created:** [January 4, 2020, 12:23am UTC](https://forum.rasa.com/t/using-custom-slot-mappings-with-forms/23041 "2020-01-04T00:23:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jmg007](https://avatars.discourse-cdn.com/v4/letter/j/dbc845/32.png) [@Jmg007](https://forum.rasa.com/u/Jmg007)\
**Post date:** [January 4, 2020, 12:23am UTC](https://forum.rasa.com/t/using-custom-slot-mappings-with-forms/23041/1 "2020-01-04T00:23:23Z")

</div>

Hi,

The paragraph below is taken from the Forms docs. I didn’t quite get the sentence, _ **"slots will be only filled by entities with the same name as the slot that are picked up from the user input."** _

Could I get some clarification and maybe an example on how slots will be only filled by entitites with the same name…

Thanks.

## [Custom slot mappings](https://rasa.com/docs/rasa/core/forms/#id4)

If you do not define slot mappings, slots will be only filled by entities with the same name as the slot that are picked up from the user input. Some slots, like `cuisine` , can be picked up using a single entity, but a `FormAction` can also support yes/no questions and free-text input. The `slot_mappings` method defines how to extract slot values from user responses.

---

<div class="post-metadata">

**Author:** ![JulianGerhard](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/juliangerhard/32/3781_2.png) [@JulianGerhard](https://forum.rasa.com/u/JulianGerhard)\
**Post date:** [January 4, 2020, 12:29pm UTC](https://forum.rasa.com/t/using-custom-slot-mappings-with-forms/23041/2 "2020-01-04T12:29:59Z")

</div>

Hi @Jmg007,

regarding your other post I assume you already have seen the `slot_mappings` methods of your `actions.py`. Imagine the following mapping:

```
"new_agreement": [
                self.from_intent(intent="confirm", value="yes"),
                self.from_intent(intent="deny", value="no"),
                self.from_entity(entity="slot_shift"),
            ], 

```

Here we have two ways of filling the slot `new_agreement`: by **intent** (confirm/deny) or by **entity** (slot\_shift).

In order to let Rasa fill this slot with the entitiy **slot\_shift** , there have to be an entity called **slot\_shift** in your `domain.yml` and an Extractor for this entitiy - in this case you want to use the **CRFEntityExtractor**.

That means: If your `domain.yml` defines an entity which actually can be extracted, then you can fill a slot with it, as long as the likewise `slot_mapping` exists, demonstrated in my sample.

Kind regards  
Julian

---

<div class="post-metadata">

**Author:** ![Jmg007](https://avatars.discourse-cdn.com/v4/letter/j/dbc845/32.png) [@Jmg007](https://forum.rasa.com/u/Jmg007)\
**Post date:** [January 4, 2020, 9:47pm UTC](https://forum.rasa.com/t/using-custom-slot-mappings-with-forms/23041/3 "2020-01-04T21:47:23Z")

</div>

Thanks Julian. Got it all working now. The only thing I still don’t quite get is the difference between entities and slots. In the end aren’t they both performing the same task - essentially a placeholder for user information that can be extracted?

Thanks again.

---

<div class="post-metadata">

**Author:** ![JulianGerhard](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/juliangerhard/32/3781_2.png) [@JulianGerhard](https://forum.rasa.com/u/JulianGerhard)\
**Post date:** [January 5, 2020, 3:09pm UTC](https://forum.rasa.com/t/using-custom-slot-mappings-with-forms/23041/4 "2020-01-05T15:09:36Z")

</div>

Hi @Jmg007,

> The only thing I still don’t quite get is the difference between entities and slots.

You have to imagine those two terms separated from each other. An **entity** can be seen as an object with semantic relevance, e.g. for the task [Named Entity Recognition](https://en.wikipedia.org/wiki/Named-entity_recognition). Popular entities are e.g. PERSON, LOCATION, NUMBER - objects that we often want to extract out of text.

A **slot** is something our bot should fill - primarily it doesn’t matter with which kind of information. Let’s say you are for the first time at a local dentist - usually you have to fill out a form with personal information about yourself. Consider everything to fill out as a slot similar to the one we are talking about - with the difference that **our** slot should be filled automatically.

Now Rasa simply offers the possibility to fill a **slot** with the value of any recognized **entity**. Imagine this example:

_Our bot has only one single task: He should fill a slot called **fullname**._

Now the setup is simple: We create a Form, define one slot and the following mapping:

```
"fullname": self.from_text()

```

If the bot asks **“Please give me your fullname”** you have many possibilities to respond. A few samples:

- Peter Parker
- Gandalf the Grey
- Julian
- Shitstorm
- Blink182

Out of this perspective, the slot would even be filled with the value “Shitstorm” because noone determines how to properly validate the value, e.g. to not being a proper name. Thank god, Rasa provided some additional methods for this one: **Why don’t we use a mechanism that already exists for this task?** leading to:

`"fullname": self.from_entity(entity="PERSON")`

This would tell the Bot to fill the slot **exclusively** with a value that corresponds to the entity PERSON, e.g. “Peter Parker” - assumed that our _NLU-Core extracted the entity PERSON properly_.

Of course this mechanisms are error-prone such that it is always a good idea to use the validator-methods to inject some additional validation but I think you got it now.

Did this help?

Regards  
Julian

---

<div class="post-metadata">

**Author:** ![Jmg007](https://avatars.discourse-cdn.com/v4/letter/j/dbc845/32.png) [@Jmg007](https://forum.rasa.com/u/Jmg007)\
**Post date:** [January 6, 2020, 1:34am UTC](https://forum.rasa.com/t/using-custom-slot-mappings-with-forms/23041/5 "2020-01-06T01:34:07Z")

</div>

Thanks Julian!
