# Usert enter random message and continue with predifined utter

**URL:** <https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937>\
**Category:** Rasa Open Source\
**Created:** [December 1, 2019, 7:43pm UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937 "2019-12-01T19:43:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![alebeta90](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/alebeta90/32/4832_2.png) [@alebeta90](https://forum.rasa.com/u/alebeta90)\
**Post date:** [December 1, 2019, 7:43pm UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/1 "2019-12-01T19:43:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alebeta90](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/alebeta90/32/4832_2.png) [@alebeta90](https://forum.rasa.com/u/alebeta90)\
**Post date:** [December 1, 2019, 10:24pm UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/2 "2019-12-01T22:24:31Z")

</div>

I did this FormAction

```auto
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?

---

<div class="post-metadata">

**Author:** ![Bhanu](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@Bhanu](https://forum.rasa.com/u/Bhanu)\
**Post date:** [December 2, 2019, 6:41am UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/3 "2019-12-02T06:41:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alebeta90](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/alebeta90/32/4832_2.png) [@alebeta90](https://forum.rasa.com/u/alebeta90)\
**Post date:** [December 2, 2019, 8:26am UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/4 "2019-12-02T08:26:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bhanu](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@Bhanu](https://forum.rasa.com/u/Bhanu)\
**Post date:** [December 2, 2019, 9:16am UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/5 "2019-12-02T09:16:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alebeta90](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/alebeta90/32/4832_2.png) [@alebeta90](https://forum.rasa.com/u/alebeta90)\
**Post date:** [December 2, 2019, 9:27am UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/6 "2019-12-02T09:27:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lgrinberg](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/lgrinberg/32/1659_2.png) [@lgrinberg](https://forum.rasa.com/u/lgrinberg)\
**Post date:** [December 5, 2019, 10:39am UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/7 "2019-12-05T10:39:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alebeta90](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/alebeta90/32/4832_2.png) [@alebeta90](https://forum.rasa.com/u/alebeta90)\
**Post date:** [December 12, 2019, 3:03pm UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/8 "2019-12-12T15:03:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fuih](https://avatars.discourse-cdn.com/v4/letter/f/d78d45/32.png) [@fuih](https://forum.rasa.com/u/fuih)\
**Post date:** [December 13, 2019, 1:52am UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/9 "2019-12-13T01:52:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alebeta90](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/alebeta90/32/4832_2.png) [@alebeta90](https://forum.rasa.com/u/alebeta90)\
**Post date:** [December 14, 2019, 12:44pm UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/10 "2019-12-14T12:44:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fuih](https://avatars.discourse-cdn.com/v4/letter/f/d78d45/32.png) [@fuih](https://forum.rasa.com/u/fuih)\
**Post date:** [December 14, 2019, 5:38pm UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/11 "2019-12-14T17:38:11Z")

</div>

@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 😄 . It might not be your problem in this case though, since you didn’t find indentical messages in the log.

---

<div class="post-metadata">

**Author:** ![alebeta90](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/alebeta90/32/4832_2.png) [@alebeta90](https://forum.rasa.com/u/alebeta90)\
**Post date:** [December 16, 2019, 11:28am UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/12 "2019-12-16T11:28:35Z")

</div>

Hi @fuih,

I double checked today 😃 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

```auto
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

---

<div class="post-metadata">

**Author:** ![alebeta90](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/alebeta90/32/4832_2.png) [@alebeta90](https://forum.rasa.com/u/alebeta90)\
**Post date:** [December 16, 2019, 12:33pm UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/13 "2019-12-16T12:33:19Z")

</div>

I created this issue

> <https://github.com/RasaHQ/rasa/issues/4979>
>
> \<!-- THIS INFORMATION IS MANDATORY - YOUR ISSUE WILL BE CLOSED IF IT IS MISSING.… If you don't know your Rasa version, use \`rasa --version\`. 
> Please format any code or console output with three ticks \`\`\` above and below.
> If you are asking a usage question (e.g. "How do I do xyz") please post your question on https://forum.rasa.com instead --\>
> 
> \*\*Rasa version\*\*:
> Rasa 1.5.3
> 
> \*\*Rasa SDK version\*\*
> rasa-sdk:1.5.1
> 
> \*\*Rasa X version\*\*
> rasa-x:0.23.4
> 
> \*\*Python version\*\*:
> Python 3.6.9 (Running Rasa official Docker Image)
> 
> \*\*Operating system\*\* (windows, osx, ...):
> CentOS 7 nodes for Docker Swarm Cluster
> 
> \*\*Issue\*\*:
> 
> In some point of our conversation(Slack Channel) after a ScheduleReminder action, our bot is asking two questions to the user, after the user reply this questions, the bot ask again(using FormAction) and the bot is not waiting for user's answer, instead it is getting last user reply and set the slot for that action. We used action to reset slots and it is not working neither. The bot keep asking the FormActions and setting the same slot/answer till it reach a question where it should have an user answer(not FormAction). This problem only happens when using Slack channel, if we use interactive learning in Rasa X it is working properly and the same with the Rasa X option to share the bot, it is possible to talk with the bot and everything is fine.
> 
> I had been asking in the forum, but no luck yet
> 
> Forum link: https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937
> 
> 
> 
> \*\*Error (including full traceback)\*\*:
> \`\`\`
> 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
> \`\`\`
> 
> \*\*Command or request that led to error\*\*:
> \`\`\`
> {"sender\_id": "UMAAQ4QTB", "event": "user", "timestamp": 1576494212.3010159, "text":
> "ja", "parse\_data": {"intent": {"name": "utter\_positive\_answer", "confidence": 0.8873927593231201}, "entities": \[\], "intent\_ranking": \[
> {"name": "utter\_positive\_answer", "confidence": 0.8873927593231201}, {"name": "test\_s3", "confidence": 0.008611131459474564}, {"name": "
> utter\_no\_difference", "confidence": 0.008563085459172726}, {"name": "utter\_im\_thankful\_for", "confidence": 0.008091296069324017}, {"name
> ": "utter\_email", "confidence": 0.006594611797481775}, {"name": "utter\_cant\_be\_glad", "confidence": 0.0063270037062466145}, {"name": "ut
> ter\_what\_we\_can\_change", "confidence": 0.005936738569289446}, {"name": "test\_s4", "confidence": 0.005273961462080479}, {"name": "utter\_i
> m\_happy\_if", "confidence": 0.005174669902771711}, {"name": "utter\_nothing\_positiv\_self", "confidence": 0.005160031374543905}\], "text": "
> ja"}, "input\_channel": "slack", "message\_id": "8cbb2c45cc1a4bbc81eb38a1d87d068e", "metadata": {}}
> 
> \`\`\`
> 
> This is the last user message, that is being used by as slot(though it is not an slot) later on by the bot.
> 
> \*\*Content of configuration file (config.yml)\*\* (if relevant):
> \`\`\`yml
> language: de
> pipeline: supervised\_embeddings
> policies:
> \- name: AugmentedMemoizationPolicy
> \- name: MappingPolicy
> \- name: FormPolicy
> \`\`\`

---

<div class="post-metadata">

**Author:** ![stephens](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/stephens/32/1632_2.png) [@stephens](https://forum.rasa.com/u/stephens)\
**Post date:** [December 18, 2019, 3:49am UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/14 "2019-12-18T03:49:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alebeta90](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/alebeta90/32/4832_2.png) [@alebeta90](https://forum.rasa.com/u/alebeta90)\
**Post date:** [December 26, 2019, 5:40pm UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/15 "2019-12-26T17:40:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![stephens](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/stephens/32/1632_2.png) [@stephens](https://forum.rasa.com/u/stephens)\
**Post date:** [December 28, 2019, 3:24am UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/16 "2019-12-28T03:24:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alebeta90](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/alebeta90/32/4832_2.png) [@alebeta90](https://forum.rasa.com/u/alebeta90)\
**Post date:** [January 14, 2020, 5:49pm UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/17 "2020-01-14T17:49:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![stephens](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/stephens/32/1632_2.png) [@stephens](https://forum.rasa.com/u/stephens)\
**Post date:** [January 15, 2020, 1:33pm UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/18 "2020-01-15T13:33:14Z")

</div>

You could use filebin.ca or pastebin

---

<div class="post-metadata">

**Author:** ![alebeta90](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/alebeta90/32/4832_2.png) [@alebeta90](https://forum.rasa.com/u/alebeta90)\
**Post date:** [January 15, 2020, 1:35pm UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/19 "2020-01-15T13:35:20Z")

</div>

Hi @stephens

here is the pastebin [2020-01-14 17:16:50 DEBUG rasa.core.policies.mapping\_policy - There - Pastebin.com](https://pastebin.com/U9hCxLqT)

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

Thanks and all the best

---

<div class="post-metadata">

**Author:** ![stephens](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/stephens/32/1632_2.png) [@stephens](https://forum.rasa.com/u/stephens)\
**Post date:** [January 15, 2020, 1:58pm UTC](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937/20 "2020-01-15T13:58:14Z")

</div>

Can you paste the story here and also the random\_answer intent.

[Next page](https://forum.rasa.com/t/usert-enter-random-message-and-continue-with-predifined-utter/21937.md?page=2)
