Using same entity/slot for different intents - works only the first time - Getting Started with Rasa / Tutorials, Resources & Videos - Rasa Community Forum

👋 Introducing the Rasa Playground

Using same entity/slot for different intents - works only the first time


post by vvasani on Jan 21, 2020

Hi, I am working on a FAQ type of a bot. I have 3 applications for my domain and there are more than 15 FAQs where the questions are same across the three applications, but the answers(utterances only) will be different per application. So, I defined Entity:“app”, Slot:“app”, type :text. I have written a custom action as below for each Q:

class Actionnewconsumer(Action):

def name(self):
    return "action_newconsumer_byapp"

def run(self, dispatcher, tracker, domain):
    appl = tracker.get_slot('appl')

if appl == 'A':
        dispatcher.utter_template('utter_newconsumer_A', tracker)
    elif appl == 'B':
        dispatcher.utter_template('utter_newconsumer_B', tracker)
    else:
        dispatcher.utter_template('utter_cantunderstand', tracker)

return []

Also, defined a custom action to reset slot. class ActionResetSlotapp(Action):

def name(self):
    return "action_reset_slot"

def run(self, dispatcher, tracker, domain):
    return [SlotSet("appl", None)]

My stories are as below:(this is just for one Q(new consumer). There are stories like this for all 15 Qs for the same A and B applications)

NewConsumer story1

NewConsumer story2

So, basically, if a user specifies the appl in the Q itself, it should directly give the answer- which works perfect. Now, if the user doesnt specify the application, it asks the application- which is also as expected. But after the appl is specified, for the first time it answers correctly, the second time, it takes the correct entity value(A or B), but identifies intent as "enter_data" and hence replies for any of the 15 Qs where this slot is being used.

My config is as below:

language: en_core_web_sm pipeline: supervised_embeddings policies:

I also tried increasing the augmentation factor upto 250 and changing to Memoization policy as well, but this part fails to work correctly. Sorry for the super-long Q.

Thanks!


post by vvasani on Jan 30, 2020

Any idea @JiteshGaikwad @akelad @chatbot_Ra?


post by JiteshGaikwad on Jan 30, 2020

hey @vvasani, In your Actionnewconsumer(Action) can you replace

appl = tracker.get_slot(‘appl’)

with

appl = next(tracker.get_latest_entity_values(“appl”), None)

What I am trying to say here is if user specifies the appl in the question itself it will be captured in the entities by NLU and then you extract the user specified entity in the action using the above code. So here it will only capture the appl only if the user has specified and if user has not specified we don’t need to use the slot.

Let me know if this helps


post by vvasani on Jan 31, 2020

@JiteshGaikwad Thank you so much for your time. But I will always need to appl to be specified. So, what am trying to do is, if the user specifies the appl, utterance is for that appl directly, else, the bot will ask for that appl, which is captured by the “enter_data” intent. The issue is that the slot(appl) is being captured correctly always, the intent is not correct,since it picks up the intent as “enter_data” which is being used in multiple stories, it randomly picks any intent after that. I have specified the max_history as 5, but still it picks up incorrect intents, since the last intent it picks up is “enter_data”.

So, say I have two actual intents: 1)New consumer 2)Email id

I have two actions as specified above, for each for these and they both use “appl” entity and slot. My stories are as specified above.


post by preetham1 on Aug 26, 2020

Hello Guyz i am having similar issue i am using same entity for different intends . its actually not recognizing that particular intend please help


post by mohan on Sep 17, 2021

Have you guys found any solution to this problem?