Rasa X - Buttons

Hi! I’m using Rasa X version 0.21.0 and the buttons right below redirects me to another similar page instead of the payload/intent inside the buttons. 37%20PM It redirects me here:

I’m using a custom action for two stage fallback policy. Here’s the code:

class ActionDefaultAskAffirmation(Action):
"""Asks for an affirmation of the intent if NLU threshold is not met."""
def name(self) -> Text:
    return "action_default_ask_affirmation"

def __init__(self) -> None:
    import pandas as pd

    self.intent_mappings = pd.read_csv("data/" "intent_description_mapping.csv", encoding="utf-8")
    self.intent_mappings.fillna("", inplace=True)
    self.intent_mappings.entities = self.intent_mappings.entities.map(
        lambda entities: {e.strip() for e in entities.split(",")}
    )

def run(
    self,
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: Dict[Text, Any],
) -> List["Event"]:

    intent_ranking = tracker.latest_message.get("intent_ranking", [])
    if len(intent_ranking) > 1:
        diff_intent_confidence = intent_ranking[0].get(
            "confidence"
        ) - intent_ranking[1].get("confidence")
        if diff_intent_confidence < 0.2:
            intent_ranking = intent_ranking[:2]
        else:
            intent_ranking = intent_ranking[:1]
    first_intent_names = [
        intent.get("name", "")
        for intent in intent_ranking
        if intent.get("name", "") != "out_of_scope"
    ]

    message_title = (
        "Sorry, I'm not sure I've understood " "you correctly 🤔 Do you mean...".encode("utf-8")
    )

    entities = tracker.latest_message.get("entities", [])
    entities = {e["entity"]: e["value"] for e in entities}

    entities_json = json.dumps(entities)

    buttons = []
    for intent in first_intent_names:
        logger.debug(intent)
        logger.debug(entities)
        buttons.append(
            {
                "title": self.get_button_title(intent, entities),
                "payload": "/{}{}".format(intent, entities_json),
            }
        )

    buttons.append({"title": "Something else", "payload": "/out_of_scope"})

    dispatcher.utter_button_message(message_title, buttons=buttons)

    return []

def get_button_title(self, intent: Text, entities: Dict[Text, Text]) -> Text:
    default_utterance_query = self.intent_mappings.intent == intent
    utterance_query = (
        self.intent_mappings.entities == entities.keys() & default_utterance_query
    )

    utterances = self.intent_mappings[utterance_query].button.tolist()

    if len(utterances) > 0:
        button_title = utterances[0]
    else:
        utterances = self.intent_mappings[default_utterance_query].button.tolist()
        button_title = utterances[0] if len(utterances) > 0 else intent

    return button_title.format(**entities)

Hey there @Star, thanks for the bug report! It has nothing to do with your code. We just ran into this one and are aware of it, should be fixed in an upcoming patch :+1:

1 Like

@erohmensing I don’t see this issue in Github, and the issue has persisted through 0.21.1 and 0.21.2. To me this is a blocker / highest priority issue as it makes our bot, which uses buttons heavily, absolutely unusable within Rasa X (still works on Messenger, fortunately). Should I create this issue in Github?

2 Likes

Sure thing, we are aware of it already, but feel free to make a github issue for more exposure.

Hi @erohmensing Any updates or workarounds on the issue? I have switched to rasa 1.3.x an having trouble getting rasa-x working because of this bug. Is there a way to force rasa 1.3.x with an older version of rasa-x? whenever i try to pip install rasa-x < 0.21.0, rasa automatically downgrades.

@erohmensing Any news on the problem? Can the buttons be simulated as text input? Example: /intent{“slot_name”: “text_value”

@Andre1 I just tried on the latest version and the buttons seem to work fine. So i would try upgrading. You can indeed simulate the buttons as text as you’ve said, though it should be noted that that format is for entity names, not slot names (if you ahve a slot of the same name as an entity, the default is to autofill that slot, though)

@erohmensing you’re absolutely right. But now the buttons are all pressed into one line. Is it possible to split the buttons into several lines?

Good point, we’re working on a fix for this (somehow a regression got introduced): Buttons rasa x 0.22

do they also appear in one line in Talk to your bot?

@erohmensing Thanks for your work. Yes, unfortunately that’s the way it is.Screenshot_2019-11-13%20Rasa%20X

Ok thank you for the report!

upgrade rasa x to 0.23, its working i.e, now buttons are in several lines