# KeyError: "text"

**URL:** <https://forum.rasa.com/t/keyerror-text/13591>\
**Category:** Rasa Open Source\
**Created:** [July 26, 2019, 10:38am UTC](https://forum.rasa.com/t/keyerror-text/13591 "2019-07-26T10:38:39Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jainkrunal](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/jainkrunal/32/3719_2.png) [@jainkrunal](https://forum.rasa.com/u/jainkrunal)\
**Post date:** [July 26, 2019, 10:38am UTC](https://forum.rasa.com/t/keyerror-text/13591/1 "2019-07-26T10:38:39Z")

</div>

Hello Guys,

I am facing this error after the latest update, If anyone could find out what it is?

ERROR  
**rasa.core.nlg.template - Failed to fill utterance template** ‘{‘custom’: {‘messages’: [{‘suggestions’: [{‘payload’: ‘/business\_function{“business\_function\_name”: “sales”}’, ‘title’: ‘sales’}, {‘payload’: ‘/business\_function{“business\_function\_name”: “finance”}’, ‘title’: ‘finance’}], ‘type’: ‘suggestion\_chips’}]}}’. **Tried to replace ‘text’ but could not find a value for it. There is no slot with this name nor did you pass the value explicitly when calling the template. Return template without filling the template.**   
Traceback (most recent call last):  
File “/home/krunal/.local/lib/python3.6/site-packages/rasa/core/nlg/template.py”, line 114, in \_fill\_template\_text  
text = re.sub(r"{([^\n]+?)}", r"{0[\1]}", template[“text”])  
**KeyError: 'text’**

Thanks,  
Krunal

---

<div class="post-metadata">

**Author:** ![fuih](https://avatars.discourse-cdn.com/v4/letter/f/d78d45/32.png) [@fuih](https://forum.rasa.com/u/fuih)\
**Post date:** [July 26, 2019, 10:49am UTC](https://forum.rasa.com/t/keyerror-text/13591/2 "2019-07-26T10:49:42Z")

</div>

Hello, jainkrunal

Do you have any utterance template with variable {text} in it ? Such as:

```
utter_something:
- text: I need to fix this {text}

```

It seems to me that you didn’t pass any value or there wasn’t any slot with the same name, so the variable {text} never get filled.

---

<div class="post-metadata">

**Author:** ![jainkrunal](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/jainkrunal/32/3719_2.png) [@jainkrunal](https://forum.rasa.com/u/jainkrunal)\
**Post date:** [July 26, 2019, 10:58am UTC](https://forum.rasa.com/t/keyerror-text/13591/3 "2019-07-26T10:58:46Z")

</div>

Hey @fuih,\ Thank you for getting back to me…

> [@fuih](#):
>
> Do you have any utterance template with variable {text} in it ? Such as:

It’s not the case. I think the problem is with the slot that I am firing. But, I am not sure how to get solved it…

> [@jainkrunal](#):
>
> '/business\_function{“business\_function\_name”: “sales”}’

---

<div class="post-metadata">

**Author:** ![fuih](https://avatars.discourse-cdn.com/v4/letter/f/d78d45/32.png) [@fuih](https://forum.rasa.com/u/fuih)\
**Post date:** [July 26, 2019, 12:35pm UTC](https://forum.rasa.com/t/keyerror-text/13591/4 "2019-07-26T12:35:26Z")

</div>

The way you set slots with payloads seems fine to me. And even if the slots didn’t get set, shouldn’t they still have None (or null) value ? I tried utter empty slot before and it still worked fine (it printed out None value but the program didn’t crash)

---

<div class="post-metadata">

**Author:** ![erohmensing](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/erohmensing/32/1789_2.png) [@erohmensing](https://forum.rasa.com/u/erohmensing)\
**Post date:** [July 29, 2019, 11:16am UTC](https://forum.rasa.com/t/keyerror-text/13591/5 "2019-07-29T11:16:57Z")

</div>

Hey there @jainkrunal, can you post how this custom template is defined, i.e. do you define it in your action server or in the domain? If in the action server, which dispatcher method are you using to utter it?

---

<div class="post-metadata">

**Author:** ![jainkrunal](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/jainkrunal/32/3719_2.png) [@jainkrunal](https://forum.rasa.com/u/jainkrunal)\
**Post date:** [July 29, 2019, 11:55am UTC](https://forum.rasa.com/t/keyerror-text/13591/6 "2019-07-29T11:55:34Z")

</div>

Here it is!!  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/d/dacf92a1fbd06a71741e0bd01bb69714be431d13.png)

Here ‘sample\_intent’ is same as mentioned!! Also this error occurred after the update…

Thanks,  
Krunal

---

<div class="post-metadata">

**Author:** ![erohmensing](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/erohmensing/32/1789_2.png) [@erohmensing](https://forum.rasa.com/u/erohmensing)\
**Post date:** [July 29, 2019, 6:37pm UTC](https://forum.rasa.com/t/keyerror-text/13591/7 "2019-07-29T18:37:38Z")

</div>

Hmmm this is a good point. This would happen after the most recent update because we allowed interpolation of slots into everything including everything in custom. This is actually exactly what I had reservations about with this 😅 can you create a github issue please?

---

<div class="post-metadata">

**Author:** ![jainkrunal](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/jainkrunal/32/3719_2.png) [@jainkrunal](https://forum.rasa.com/u/jainkrunal)\
**Post date:** [July 30, 2019, 5:03am UTC](https://forum.rasa.com/t/keyerror-text/13591/8 "2019-07-30T05:03:26Z")

</div>

Hey @erohmensing,\

I had setup the new Virtual Environment to test and Now, it’s gone! I don’t know why but there is no error in Console.

But, had faced a warning about the library numpy **deprecating** the usage. It is appearing after installing **pandas** which, I think updated **numpy**. Snapshot for the same:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/7/7c6651aa27f4281bb353b1a45be5234bd7f89847.png)

Same warning is thrown while running: rasa train, run, test, also for command while running action server.

Thanks,  
Krunal

---

<div class="post-metadata">

**Author:** ![erohmensing](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/erohmensing/32/1789_2.png) [@erohmensing](https://forum.rasa.com/u/erohmensing)\
**Post date:** [July 30, 2019, 8:54am UTC](https://forum.rasa.com/t/keyerror-text/13591/9 "2019-07-30T08:54:17Z")

</div>

That’s strange that it’s disappeared 🤔

The tensorflow issues should be okay, its just deprecated usage by some libraries that we use that need to update their usage. We would surpress the warnings but unfortunately they use print instead of log. Let me know if that creates some unexpected behavior though.

---

<div class="post-metadata">

**Author:** ![jainkrunal](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/jainkrunal/32/3719_2.png) [@jainkrunal](https://forum.rasa.com/u/jainkrunal)\
**Post date:** [July 30, 2019, 9:48am UTC](https://forum.rasa.com/t/keyerror-text/13591/10 "2019-07-30T09:48:58Z")

</div>

Yeah, It’s good for me that it disappeared 🙂

> [@erohmensing](#):
>
> Let me know if that creates some unexpected behavior though

No, It’s not and thanks for your kind help!!

Thanks,  
Krunal

---

<div class="post-metadata">

**Author:** ![n2718281](https://avatars.discourse-cdn.com/v4/letter/n/4bbf92/32.png) [@n2718281](https://forum.rasa.com/u/n2718281)\
**Post date:** [May 18, 2020, 2:59pm UTC](https://forum.rasa.com/t/keyerror-text/13591/11 "2020-05-18T14:59:48Z")

</div>

I permit myself to reopen that.

I used that:

```
  - text: "Foo"
    custom:
      data:
        attachment:
          type: template
          payload:
            template_type: generic
            elements:
            - title: "Bar"
              subtitle: ""
              image_url: 'img/myimage.jpg'
              default_action: 
                type: 'postback'
                payload: '/inform{"myentity": "bla"}'
              buttons:
              - title: "foo"
                type: postback
                payload: '/inform{"myentity": "bla"}'

```

And I got the error:

```
ERROR rasa.core.nlg.interpolator - Failed to fill utterance template '/inform{"myentity": "bla"}'. Tried to replace '"myentity": "bla"' but could not find a value for it. There is no slot with this name nor did you pass the value explicitly when calling the template. Return template without filling the template. 
Traceback (most recent call last):
  File "rasa/rasaenv02/lib/python3.7/site-packages/rasa/core/nlg/interpolator.py", line 18, in interpolate_text
    text = text.format(values)
KeyError: '"myentity": "bla"'
```

---

<div class="post-metadata">

**Author:** ![n2718281](https://avatars.discourse-cdn.com/v4/letter/n/4bbf92/32.png) [@n2718281](https://forum.rasa.com/u/n2718281)\
**Post date:** [May 18, 2020, 4:59pm UTC](https://forum.rasa.com/t/keyerror-text/13591/12 "2020-05-18T16:59:50Z")

</div>

~~Using a syntax like “{{ }}” could be an idea for slot values replacement? (But I guess that would need a lot of changes)~~

---

<div class="post-metadata">

**Author:** ![n2718281](https://avatars.discourse-cdn.com/v4/letter/n/4bbf92/32.png) [@n2718281](https://forum.rasa.com/u/n2718281)\
**Post date:** [May 19, 2020, 8:47am UTC](https://forum.rasa.com/t/keyerror-text/13591/13 "2020-05-19T08:47:07Z")

</div>

Oh but actually {{ }} prevents interpolation, does it? At least it fixed my issue.

I don’t know if it’s a feature or using a bug but that works, so I use:

```auto
payload: '/inform{{"myentity": "bla"}}'

```

---

<div class="post-metadata">

**Author:** ![Johan1us](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/johan1us/32/14245_2.png) [@Johan1us](https://forum.rasa.com/u/Johan1us)\
**Post date:** [October 18, 2020, 3:16pm UTC](https://forum.rasa.com/t/keyerror-text/13591/14 "2020-10-18T15:16:56Z")

</div>

@n2718281 With rasa 2.0 I had the same problem. But the double curly brackets solved the problem for me. 👍
