Star
(Estela Mariz Oganiza)
September 26, 2019, 5:33am
1
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.
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)
erohmensing
(Ella Rohm-Ensing)
September 26, 2019, 12:10pm
2
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 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
erohmensing
(Ella Rohm-Ensing)
October 3, 2019, 5:12pm
4
Sure thing, we are aware of it already, but feel free to make a github issue for more exposure.
thusithaC
(Thusitha)
October 14, 2019, 12:33am
5
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.
Andre1
(André Weber)
November 12, 2019, 12:44pm
6
@erohmensing Any news on the problem? Can the buttons be simulated as text input?
Example: /intent{“slot_name”: “text_value”
erohmensing
(Ella Rohm-Ensing)
November 12, 2019, 4:30pm
7
@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)
Andre1
(André Weber)
November 12, 2019, 8:28pm
8
@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?
erohmensing
(Ella Rohm-Ensing)
November 13, 2019, 9:14am
9
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?
Andre1
(André Weber)
November 13, 2019, 11:50am
10
@erohmensing Thanks for your work. Yes, unfortunately that’s the way it is.
erohmensing
(Ella Rohm-Ensing)
November 13, 2019, 4:31pm
11
Ok thank you for the report!
ravikrcs
(Ravi Kumar)
November 27, 2019, 7:47am
12
upgrade rasa x to 0.23, its working i.e, now buttons are in several lines
touqeer
(Touqeer Nasir)
July 9, 2020, 11:29am
13
Is there any way to add next line between buttons?
@touqeer in Rasa X there is not. In any other channels, it depends on your channel.
touqeer
(Touqeer Nasir)
July 9, 2020, 3:08pm
15
What you mean by channel?
my User case is follow:
text: | Welcome message
buttons:
- title: Register a Complaint
payload: >/complaint_registration
type: postback
index: 1
<I want to add next line here>
- title: Check Complaint Status
payload: >-
/complaint_registration
type: postback
index: 2
- title: Default
payload: /greet
type: postback
index: -1
The channel is where the user talks to the bot. Examples include shell (your console), facebook, telegram, slack, share your bot in rasa x, etc.
erohmensing
(Ella Rohm-Ensing)
July 21, 2020, 3:26pm
18
You would have to check the WhatsApp API for a parameter like that. On first look, I can’t even find how buttons are sent, though.