# TypeError: 'SlotSet' object is not subscriptable

**URL:** <https://forum.rasa.com/t/typeerror-slotset-object-is-not-subscriptable/3010>\
**Category:** Rasa Open Source\
**Created:** [November 27, 2018, 12:30pm UTC](https://forum.rasa.com/t/typeerror-slotset-object-is-not-subscriptable/3010 "2018-11-27T12:30:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajt](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@ajt](https://forum.rasa.com/u/ajt)\
**Post date:** [November 27, 2018, 12:30pm UTC](https://forum.rasa.com/t/typeerror-slotset-object-is-not-subscriptable/3010/1 "2018-11-27T12:30:16Z")

</div>

Dear Team,

I am getting error as **TypeError: ‘SlotSet’ object is not subscriptable** when running rasa core interpreter with curstom action.

**Error log:**

ERROR:flask.app:Exception on /webhook [POST] Traceback (most recent call last): File “/home/ajontanu/jon/my\_work/chatbot3/chatbot3/lib/python3.6/site-packages/flask/app.py”, line 2292, in wsgi\_app response = self.full\_dispatch\_request() File “/home/ajontanu/jon/my\_work/chatbot3/chatbot3/lib/python3.6/site-packages/flask/app.py”, line 1815, in full\_dispatch\_request rv = self.handle\_user\_exception(e) File “/home/ajontanu/jon/my\_work/chatbot3/chatbot3/lib/python3.6/site-packages/flask\_cors/extension.py”, line 161, in wrapped\_function return cors\_after\_request(app.make\_response(f(\*args, \*\*kwargs))) File “/home/ajontanu/jon/my\_work/chatbot3/chatbot3/lib/python3.6/site-packages/flask/app.py”, line 1718, in handle\_user\_exception reraise(exc\_type, exc\_value, tb) File “/home/ajontanu/jon/my\_work/chatbot3/chatbot3/lib/python3.6/site-packages/flask/\_compat.py”, line 35, in reraise raise value File “/home/ajontanu/jon/my\_work/chatbot3/chatbot3/lib/python3.6/site-packages/flask/app.py”, line 1813, in full\_dispatch\_request rv = self.dispatch\_request() File “/home/ajontanu/jon/my\_work/chatbot3/chatbot3/lib/python3.6/site-packages/flask/app.py”, line 1799, in dispatch\_request return self.view\_functionsrule.endpoint File “/home/ajontanu/jon/my\_work/chatbot3/chatbot3/lib/python3.6/site-packages/flask\_cors/decorator.py”, line 128, in wrapped\_function resp = make\_response(f(\*args, \*\*kwargs)) File “/home/ajontanu/jon/my\_work/chatbot3/chatbot3/lib/python3.6/site-packages/rasa\_core\_sdk/endpoint.py”, line 83, in webhook response = executor.run(action\_call) File “/home/ajontanu/jon/my\_work/chatbot3/chatbot3/lib/python3.6/site-packages/rasa\_core\_sdk/executor.py”, line 177, in run events = action(dispatcher, tracker, domain) File “/home/ajontanu/jon/my\_work/chatbot3/chatbot3/lib/python3.6/site-packages/rasa\_core\_sdk/forms.py”, line 388, in run if e[‘event’] == ‘slot’: TypeError: ‘SlotSet’ object is not subscriptable

**Custom Action file:**

```
    def validate(self, dispatcher:CollectingDispatcher, tracker: Tracker,
             domain: Dict[Text, Any]) -> List[Dict]:

    "Validate extracted requested slot else raise an error"

    # extract slots that are not requested but set by corresponding entity
    slot_values = self.extract_other_slots(dispatcher, tracker, domain)

    #extract requested slot
    slot_to_fill = tracker.get_slot(REQUESTED_SLOT)

    if slot_to_fill:
        slot_values.update(self.extract_requested_slot(dispatcher, tracker, domain))

        if not slot_values:
            raise ActionExecutionRejection(self.name(),
                                           "Failed to validate slot {0}"
                                           "with action {1}"
                                           "".format(slot_to_fill, self.name))

    for slot, value in slot_values.items():
        print(slot)
        print(value)
        if slot_values[slot] == 'gender':
            if value.lower() not in self.gender_db():
                dispatcher.utter_template('utter_wrong_gender', tracker)

                slot_values[slot] = None

    return [SlotSet(slot, value) for slot, value in slot_values.items()]
```

---

<div class="post-metadata">

**Author:** ![MetcalfeTom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/metcalfetom/32/1422_2.png) [@MetcalfeTom](https://forum.rasa.com/u/MetcalfeTom)\
**Post date:** [December 2, 2018, 8:26pm UTC](https://forum.rasa.com/t/typeerror-slotset-object-is-not-subscriptable/3010/2 "2018-12-02T20:26:47Z")

</div>

Hi @ajt,

First of all, I’m not sure what this form is doing, but is the line

```auto
if slot_values[slot] == 'gender':

```

supposed to be

```auto
if slot == 'gender':

```

?

As for the `TypeError`, can you show me your imports please? Is this the only custom code you have written?

---

<div class="post-metadata">

**Author:** ![Tobias\_Wochinger](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tobias_wochinger/32/4580_2.png) [@Tobias\_Wochinger](https://forum.rasa.com/u/Tobias_Wochinger)\
**Post date:** [December 3, 2018, 9:06am UTC](https://forum.rasa.com/t/typeerror-slotset-object-is-not-subscriptable/3010/3 "2018-12-03T09:06:38Z")

</div>

This question was also asked here. So if you find the solution, give some updates in the issue [TypeError: ‘SlotSet’ object is not subscriptable · Issue #1407 · RasaHQ/rasa\_core · GitHub](https://github.com/RasaHQ/rasa_core/issues/1407)

---

<div class="post-metadata">

**Author:** ![Ghostvv](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ghostvv/32/211_2.png) [@Ghostvv](https://forum.rasa.com/u/Ghostvv)\
**Post date:** [December 12, 2018, 1:21pm UTC](https://forum.rasa.com/t/typeerror-slotset-object-is-not-subscriptable/3010/4 "2018-12-12T13:21:54Z")

</div>

which import for `SlotSet` do you use?
