Usert enter random message and continue with predifined utter

Hi friends,

I have a conversation where i ask user “what you did during Christmas?” with utter utter_ask_question and next the user should enter an answer that should be always intent random_answer, does not matter what the content of the message is.

Story would look like this:

  • hi
  • utter_hi
  • utter_ask_question
  • random_answer
  • utter_thanks

The idea is that regarding the random text the user enter, it has to be recognized as random_answer and it should follow with utter_thanks

I did some tests with forms but not luck so far

yhanks

I did this FormAction

class FormRandom(FormAction):
      def name(self) -> Text:
         """Unique identifier of the form"""

         return "form_random01"
      
      @staticmethod
      def required_slots(tracker: Tracker) -> List[Text]:
         """A list of required slots that the form has to fill"""

         return ["random_answer"]
      
      def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:

         return {
              "random_answer": [self.from_entity(entity="random_answer"), self.from_text()],
         }

      def submit(
         self,
         dispatcher: CollectingDispatcher,
         tracker: Tracker,
         domain: Dict[Text, Any],
      ) -> List[Dict]:
         """Define what the form has to do
            after all required slots are filled"""
         return []

But for my use case, it would be a pain, create a action for everytime I have the need to specify random input.

There is a better way to address this need?

I didn’t got your question. Can you rephrase it in more elaborated form?

Hi Bhanu,

we have in the conversation different paths where we ask to our users an open question, let say we have around 20 cases where we ask such questions. There the user will answer any random text, and the idea is that after we receive the message we do not predict anything but we continue with the path as it is define in the story. When we make this open question, normally there is just one path, then we would like the conversation to flow to the next intent, instead to guess/predict the message in specific.

So far what I did is to create a FormAction for every single random answer in the story, but it does not look so good, though it is working.

I would like to know from our community if there is a better way to address this use case.

All the best

Hey @alebeta90,

According to rasa docs, if your NLU model picks up an entity, and your domain contains a slot with the same name, the slot will be set automatically. For example:

story_01

  • greet{“name”: “Ali”}
    • slot{“name”: “Ali”}
    • utter_greet

In this case, you don’t have to include the - slot{} part in the story, because it is automatically picked up.

To disable this behavior for a particular slot, you can set the auto_fill attribute to False in the domain file:

slots: name: type:text auto_fill: False

So in same manner you can mark all the text inside training data (for intent=random_answer) as entity (= random_answer). In this way all the text inside random_answer intent will also be detected as entity and can be used to update the slot.

But in my view using forms is better if you want to scale your bot by adding other intents and entities.

Hi Bhanu,

Thanks for the answer,

in this case, creating training data would be a quite challenging because the answer of the user can be anything, then it would be never enough training data to satisfied the requirement or the training data can get confuse with different kind of answer.

This is why so far, Form Actions are a good way to go, but in my own opinion seems to be a lot of work for that.

All the best

If you want to respond to anything the user says with an utter_thanks, then using forms is the way to go. But I think your problem is that you’re trying to fill the required_slot with self.from entities. In this case you can also do self.from_intent(intent=“random_answer”), but of course how can you get enough training data to match anything into random_answer? So the right way to go is to use self.from_text() to fill the required slot. That will match anything the user will say. You already do that. Then in the “submit” you do this: return [FollowupAction('utter_thanks")]

So your form will ask the user a question, get any answer and finish with “utter_thanks”.

I think that should work.

Saludos

2 Likes

Hi @lgrinberg,

thanks for your message,

Yes at the end we manage using self.from_text. and forms is working properly.

Now facing another issue related to form… In some part of our conversation, the bot in the Slack channel, start to reply it self after we reach the user using the ScheduleReminder.

When I see the conversation in Rasa X, I can see the it is setting the FormAction Slot automatically without waiting for user input, it is using last user answer to fill the slot… I checked and we had set properly the action to reset the slots.

And tested in Rasa X interactive learning and Rasa X shared bot platform and it works perfectly it seems to be just causing issues with slack.

any clue will be appreciated

thanks

Hello @alebeta90,

If I remember correctly from the time I integrated Rasa with Slack, there is a problem about Slack sending multiple messages to Rasa sometimes. Basically like if I enter message A once, Slack will send multiple message A to Rasa. Maybe that hasn’t been fixed and cause your problem ? You can try running Rasa command with --debug and observe the log to see if Rasa did receive multiple identical messages or not.

Hi @fuih,

I did activate the debug mode, and I could see the message is being send just one time. Afterwards it start to send the bot utters without showing and user reply.

when I check inside Rasa X in the conversations I can see it is using, last user (real) reply to fill the slots.

Do you know if there is a issue created in github for that problem you mentioned before?

Thanks

@alebeta90 I remember checking the logs and see Rasa receive multiple identical messages from Slack, i also got a Rasa staff confirmed that it’s an existing problem. But it was kinda a few months ago and i’m too lazy to search for the post, sorry :smile: . It might not be your problem in this case though, since you didn’t find indentical messages in the log.

Hi @fuih,

I double checked today :smiley: just in case hehe

And yes there are not other messages being sent, just the one before the FormAction starts and that one is being used to fill the slot(and it should not happen, it should wait for the users input)

But now I found to see another error regarding the Slack Channel

2019-12-16 11:03:37 ERROR    rasa.core.channels.slack  - Exception when trying to ha
ndle message.
2019-12-16 11:03:37 ERROR    rasa.core.channels.slack  - 
Traceback (most recent call last):
  File "/build/lib/python3.6/site-packages/rasa/core/channels/slack.py", line 307, i
n process_message
    await on_new_message(user_msg)
  File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 129, in throw
    return self.gen.throw(type, value, traceback)
  File "/build/lib/python3.6/site-packages/rasa/core/channels/channel.py", line 82, 
in handler
    await app.agent.handle_message(*args, **kwargs)
  File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 129, in throw
    return self.gen.throw(type, value, traceback)
  File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 485, in handle_
message
    async with self.lock_store.lock(message.sender_id):
  File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 129, in throw
    return self.gen.throw(type, value, traceback)
  File "/build/lib/python3.6/site-packages/async_generator/_util.py", line 34, in __
aenter__
    return await self._agen.asend(None)
  File "/build/lib/python3.6/site-packages/rasa/core/lock_store.py", line 115, in lo
ck
    conversation_id, ticket, wait_time_in_seconds
  File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 129, in throw
    return self.gen.throw(type, value, traceback)
  File "/build/lib/python3.6/site-packages/rasa/core/lock_store.py", line 143, in _a
cquire_lock
    await asyncio.sleep(wait_time_in_seconds)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 482, in sleep
    return (yield from future)
concurrent.futures._base.CancelledError

I will open an issue regarding this message and I think it is related to my problem, because I can see that is related to lock_store and maybe the lock store is not working properly with Slack channel

thanks

I created this issue

For slack users, it sounds like the user receives a message associated with completion of the form without ever being prompted to fill the slot.

With debug on, you should see all of the slot values when the intent is received. Look at that for the slack user utterance associated with the issue. Is the slot filled? If so, reset the conversation and watch the slots from the beginning. You should also be able to confirm the Slot Reset on the submit.

Hi @stephens

I checked the debug data and I always see how the action to reset slot is being called and running, but anyway the slot it is still set and the bot is answering without a real user input.

There is more information I could provide in order to advance and find a solution? you would like to see the debug logs?

all the best

In the debug logs you should see the slot filling occur as the user utterances are received.

Hi Stephen,

it is possible to send you the logs via email or a different way? the logs are quite big to post it here.

By the way we tried our bot using webchat and it is working properly.

All the best

You could use filebin.ca or pastebin

Hi @stephens

here is the pastebin 2020-01-14 17:16:50 DEBUG rasa.core.policies.mapping_policy - There - Pastebin.com

It is till the moment the bot answer without any user input.

Thanks and all the best

Can you paste the story here and also the random_answer intent.