Custom hook to parse user message and process multiple statements

Hi Friends,

I have a use case where a long sentence is being entered by the user, e.g. “My name is John, and I would like to know travel options from Los Angeles to Quebec. I am also interested in hotels availability, charges and amenities.

This single message by the user is required to be parsed into 3-4 smaller atomic statements and then I require to know the matching intents for all these 3-4 sentences.
I know that message can be parsed and processed by creating a custom hook of type “Before Incoming Middleware” but the challenge is how to process all these 3-4 statements in loop.

I also think that this might not be the best approach to achieve this use case hence seeking support.

Thanks

Hello @saurabh,

It’s a really good question. Sometimes I find myself stuck with really long sentences to parse :sweat_smile:.Recently I discovered the conversation chat design for chatbot. One of the propositions is to parse one sentences at a time. In the example:

My name is John, and I would like to know travel options from Los Angeles to Quebec. I am also interested in hotels availability, charges and amenities. ”*

This sentence could be parsed into 3 smaller sentence

What’s Your name

My name is John

Where do you want to travel

I would like to know travel options from Los Angeles to Quebec

Extra options (with a button)

Depend on the choice button

hotels availability, charges, and amenities.

Sometimes a form input (Normal webpage) is a better idea than using a conversation form. For example, if the user made an error at the beginning of the flow; How to correct that error? But in the example, it’s fairly small

Hook

The hook is a good idea. Probably if the intent is misunderstood by botpress. You could split the sentences by Punctuation marks

!
.
and
or
?
;
:

With the sentences split you can loop over the smaller sentences and find the appropriate intents. This method will only word for one specific language :thinking: (I’m not sure)?

What do you think about those approaches?