Preprocess user input

Hello everybody, I am new to Rasa and I have a question how to best structure my application. Before Rasa should check the message for intents, I want to check if there are spelling errors in the users input. If there are errors -> send the possible corrections to user. I am going to use LanguageTool for spellchecks. For communication between client and server I use websockets, which are already working.

My questions now are:

  • how can I achieve the LanguageTool part? Do I need to setup a custom component? Or an extra server/service between client and rasa-server?
  • if I want to add more events, how can I do that? By default only “user_uttered” and “bot_uttered” are available, right? I would like to have an event which is triggered when there’s spelling errors.

Thank you very much for your help!

I see 2 situations why you would want to offer spelling suggestions:

  1. The spelling error is preventing Rasa NLU from detecting the intent correctly
    In this case, you can classify it as an unknown intent and handle it in a custom action later on.
  2. The intent is classified correctly
    Even here, you can use a custom action to set a slot like misspelt to True and handle it inside a custom action again.

Is there any reason this doesn’t work for you?

Thanks for your quick answer Amogh. The reason why I am offering spelling suggestion is that I am implementing a bot to learn English with. So it is essential to know when there are mistakes in the sentence.

I now managed to solve the problem by checking the sentence for language errors in the input channel specifically in the method async def handle_message(sid, data) . Here I can call the languagetool endpoint.

The second part of my question I also managed to solve. Again I customized the InputChannel. Socket events can be added here in the __init__ function and by defining a method that is registered as a socket event.