RasaHQ / rasa

πŸ’¬ Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants
https://rasa.com/docs/rasa/
Apache License 2.0
18.89k stars 4.63k forks source link

ConversationError when retrieving end-to-end story #8114

Closed nbeuchat closed 3 years ago

nbeuchat commented 3 years ago

Rasa version: 2.3.4

Python version: 3.7.9

Operating system (windows, osx, ...): Ubuntu

Issue: When trying to retrieve the end-to-end story through the API, I get a ConversationError for several users (but not all). I can get the tracker as JSON without any issue though.

Error (including full traceback):

{
    "version": "2.3.4",
    "status": "failure",
    "message": "An unexpected error occurred. Error: 'start'",
    "reason": "ConversationError",
    "details": {},
    "help": null,
    "code": 500
}

Command or request that led to error:

GET {{protocole}}://{{url}}/conversations/{{sender_id}}/story?token={{token}}
sara-tagger commented 3 years ago

Thanks for raising this issue, @koernerfelicia will get back to you about it soon✨

Please also check out the docs and the forum in case your issue was raised there too πŸ€—
wochinge commented 3 years ago

Is there anything else in the log messages @nbeuchat ?

nbeuchat commented 3 years ago

Hi @wochinge ! Ah yes, for some reason I couldn't find them in the log last time. Anyway, here you go:

sender_id=2368913086550157 Traceback (most recent call last):
  File "/opt/venv/lib/python3.8/site-packages/rasa/server.py", line 811, in retrieve_story
    stories = get_test_stories(
  File "/opt/venv/lib/python3.8/site-packages/rasa/server.py", line 311, in get_test_stories
    return YAMLStoryWriter().dumps(story_steps, is_test_story=True)
  File "/opt/venv/lib/python3.8/site-packages/rasa/shared/core/training_data/story_writer/yaml_story_writer.py", line 73, in dumps
    self.dump(stream, story_steps, is_appendable, is_test_story)
  File "/opt/venv/lib/python3.8/site-packages/rasa/shared/core/training_data/story_writer/yaml_story_writer.py", line 94, in dump
    result = self.stories_to_yaml(story_steps, is_test_story)
  File "/opt/venv/lib/python3.8/site-packages/rasa/shared/core/training_data/story_writer/yaml_story_writer.py", line 119, in stories_to_yaml
    stories.append(self.process_story_step(story_step))
  File "/opt/venv/lib/python3.8/site-packages/rasa/shared/core/training_data/story_writer/yaml_story_writer.py", line 149, in process_story_step
    processed = self.process_event(event)
  File "/opt/venv/lib/python3.8/site-packages/rasa/shared/core/training_data/story_writer/yaml_story_writer.py", line 163, in process_event
    return self.process_user_utterance(event, self._is_test_story)
  File "/opt/venv/lib/python3.8/site-packages/rasa/shared/core/training_data/story_writer/yaml_story_writer.py", line 220, in process_user_utterance
    rasa.shared.core.events.format_message(
  File "/opt/venv/lib/python3.8/site-packages/rasa/shared/core/events.py", line 98, in format_message
    return TrainingDataWriter.generate_message(
  File "/opt/venv/lib/python3.8/site-packages/rasa/shared/nlu/training_data/formats/readerwriter.py", line 93, in generate_message
    entities = sorted(message.get("entities", []), key=lambda k: k["start"])
  File "/opt/venv/lib/python3.8/site-packages/rasa/shared/nlu/training_data/formats/readerwriter.py", line 93, in <lambda>
    entities = sorted(message.get("entities", []), key=lambda k: k["start"])
KeyError: 'start'
wochinge commented 3 years ago

Mhm, how does your NLU pipeline look like? Might be a duplicate of https://github.com/RasaHQ/rasa/issues/5263

nbeuchat commented 3 years ago

We have a few custom pipeline components but as far as I can see, all of them sets the start/end of entities.

However, I looked at the json I get from the tracker endpoint and it seems the only entities that come without a start are from the trigger_intent endpoint (which makes sense because there is no text for these so start/end don't make much sense):

        {
            "event": "user",
            "timestamp": 1614975110.5258033,
            "metadata": {
                "is_external": true
            },
            "text": "EXTERNAL: receive_notify_new_apartments",
            "parse_data": {
                "intent": {
                    "name": "receive_notify_new_apartments"
                },
                "entities": [
                    {
                        "entity": "slug",
                        "value": "ABCDE"
                    }
                ],
                "text": "EXTERNAL: receive_notify_new_apartment",
                "message_id": null,
                "metadata": {
                    "is_external": true
                }
            },
            "input_channel": "facebook",
            "message_id": null
        },

which is expected because I'm sending the following as a trigger_intent:

{
    "name": "receive_notify_new_apartment",
    "entities": {"slug": "ABCDE"}
}
nbeuchat commented 3 years ago

@wochinge do you know if there is any workaround for this? I basically can't retrieve stories for users for which we used the trigger_intent at the moment

oytuntez commented 3 years ago

We have the same situation – can't view stories when trigger_intent is used.

wochinge commented 3 years ago

The workaround would be to define some values for start and end in the trigger_intent request for now 😬 Would you mind submitting a bugfix PR?

nbeuchat commented 3 years ago

The workaround would be to define some values for start and end in the trigger_intent request for now

Doesn't really work for existing conversations, unfortunately πŸ˜‰ But also, not sure what format we are supposed to send the trigger_intent as in that case? Given that the API expects:


{
  "name": "greet",
  "entities": {
    "temperature": "high"
  }
}

I can try a PR, not sure if I'll have much time for it right now.

wochinge commented 3 years ago

@joejuzl Will work on it this week. Good pointer regarding the API spec πŸ™ŒπŸ»

nbeuchat commented 3 years ago

That's awesome :tada:!

nbeuchat commented 3 years ago

@wochinge @joejuzl I wanted to see if you knew when a fix for this will be released? We have so many external intents now that it basically makes this endpoint unusable for 95% of our conversations :disappointed: Thank you!! :pray:

joejuzl commented 3 years ago

@nbeuchat it will be released in 2.4.3 which should be this week

nbeuchat commented 3 years ago

Fantastic! Thanks a lot for the feedback @joejuzl :smiley:

oytuntez commented 3 years ago

We are starting to use external intents, too, but mostly for telling the user something (we call this intent EXTERNAL_forward_custom_message). I am curious about Nicholas’s use case that needs so many external intents, would you mind giving some insights, Nicholas?

On Thu, Mar 25, 2021 at 7:40 PM Nicolas Beuchat @.***> wrote:

Fantastic! Thanks a lot for the feedback @joejuzl https://github.com/joejuzl πŸ˜ƒ

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RasaHQ/rasa/issues/8114#issuecomment-807067594, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFAJ6ZGMBK646ZIJ7M7RYTTFNRPBANCNFSM4YTNG7CQ .

--


Oytun Tez

O Y T U N . C O - What do you want to see? Copy+. M O T A W O R D - The World's Fastest Human Translation Platform. G U Z E L I S L E R D E R N E G I - Multidisciplinary workshops in Bergama.

nbeuchat commented 3 years ago

I'd be happy to @oytuntez! Our chatbot is on Facebook Messenger and we extensively use what they call "webviews" (if you're interested, I had a lighting talk at the Rasa Summit, it's on YouTube here). As part of the interaction is from an "app" within the chatbot, we send information of what the user did within their session through an external intent so that the bot can take it from there and suggest what to do next. We also use external intents to send updates on specific listings that a user had added to their favorites for example.

Feel free to reach out to me if you want more details :smiley:

oytuntez commented 3 years ago

Great, thanks for the details!

And our cases for external intents are 1) notifications, 2) feedback loop with our decision/workflow management engines.

On Thu, Mar 25, 2021 at 8:47 PM Nicolas Beuchat @.***> wrote:

I'd be happy to @oytuntez https://github.com/oytuntez! Our chatbot is on Facebook Messenger and we extensively use what they call "webviews" (if you're interested, I had a lighting talk at the Rasa Summit, it's on YouTube here https://www.youtube.com/watch?v=HzXFXxLqtGk&list=PL75e0qA87dlGu_SnqloQXTf-4GGiUsBwJ&index=19). As part of the interaction is from an "app" within the chatbot, we send information of what the user did within their session through an external intent so that the bot can take it from there and suggest what to do next. We also use external intents to send updates on specific listings that a user had added to their favorites for example.

Feel free to reach out to me if you want more details πŸ˜ƒ

β€” You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/RasaHQ/rasa/issues/8114#issuecomment-807173725, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFAJ6ZURSCTHSHRFDDE7RDTFNZMDANCNFSM4YTNG7CQ .

--


Oytun Tez

O Y T U N . C O - What do you want to see? Copy+. M O T A W O R D - The World's Fastest Human Translation Platform. G U Z E L I S L E R D E R N E G I - Multidisciplinary workshops in Bergama.

joejuzl commented 3 years ago

fixed in: https://github.com/RasaHQ/rasa/releases/tag/2.4.3