Multiple intents handling

I am developing a bot for banking purpose and I have intents for fund transfer, transaction history, loan, balance, bill payments, etc. I have implemented intents for handling the functionalities one at a time. And now, I want to handle multiple intents at a time. For e.g if a user says,

"Show my latest transactions and then pay my bill after showing the balance."

How can I handle these kind of inputs where user asks for more than one or two functionalities in a single utterance?

I know, I can implement intents with multiple entities, but that seems to be not working for me as I have so many intents that I cannot afford to make intents with combination of 2 or 3 entities.

Is it even possible to implement using RASA or any other technology for building a chatbot?

Hi @vishal_a!

Are these (blog & doc) of any help to you?

Unfortunately, No

It’s a thing I faced few times before.

I tried with TensorFlow but not enough data in the training set to have good results. I don’t know if it’s the same now and if TensorFlow was updated.

So during my tests I used a fairly simple technique that worked well enough for simple examples: I created a NLU component that cuts sentences into pieces using connectors (and, because, but, etc.). Then I apply the intent classification for each extracted fragment of phrase. If the confidence in a piece of phrase is above a certain level then the intent can be considered part of the message. Then I created a label by concatenating the 2 or 3 intentions that I reused in the core for the actions.

It’s not very professional, but it works and handle 90% of the cases.

1 Like

I have tried with similar kind of approach. What I have done is whenever there is an amount mentioned in the user utterance, I am extracting it using regular expression. That works perfectly fine.

But when it comes to extracting text content it’s difficult. I liked your approach of dividing the sentence using prepositions. Can you share the code?

Code is the property of my company, so I’m not allowed to share it. I can only share ideas, experience or advice. Sorry :frowning:

Basically creating such component is not so difficult. Use RASA source code of your intent classifier and featurizer and adapt them is quite easy. The component need to use (or calculate if not available) text features for each of the fragment and then pass it to the intent classifier. Then you build a string with the label (only confidence above a threshold) that will be the result you will use in your stories.

Hope it helps by the way !

Thanks for the help @GuillaumeKoenigTncy. :slight_smile:

I’ll definitely give it a try.

Hi @GuillaumeKoenigTncy, I have tried the way you have suggested but, I am unable to figure it out. Please help me :expressionless:

Splitting a text into sentences or meaningful parts to be analyzed (e.g. by chat bot) is a typical NLP problem called sentence tokenisation. Solutions exist in NLTK etc. Please check this example.

Thanks @Pete I have checked that stackoverflow page. And I have even implemented it. But the limitation there is you have to have a punctuation mark to distinguish two sentences. But as @GuillaumeKoenigTncy has said I want to seperate the sentence based on the connectors/prepositions.

And also, I am not understanding where I have to to make changes in the intent classifier and featurizer.

To implement a simple sentence tokenizer or segmentation, try NTLK:

  • from nltk.tokenize import sent_tokenize
  • text = “God is Great! I won a lottery.”
  • print(sent_tokenize(text))
  • Output: [‘God is Great!’, 'I won a lottery ']

Other libraries actually use ML to break text into sentences. This is of course slower but more accurate. E.g. Spacy

To use such a component, you have to incorporate the sentencizer into the Rasa pipeline.

Thanks, @Pete, for your reply. I have already gone through the example you have provided. But in my case if I ask a bot Tell me about home loan and then show my balance, nltk cannot break it into two different sentences as there are no punctuation marks in the sentence. And in the real world I can’t even expect a user to use punctuation marks while talking to a bot.

Do you have any solution over this? I know I can handle two entities, even three entities in a intent. But, here I am looking for multiple intents like 5 to 6 different intents in a single utterance without relying on any punctuation mark.

This post has helped me: