scalableminds / chatroom

React-based Chatroom Component for Rasa Stack
https://npm-scalableminds.s3.eu-central-1.amazonaws.com/@scalableminds/chatroom@master/demo.html
GNU Affero General Public License v3.0
307 stars 208 forks source link

How to avoid showing button payload text in UI? #109

Open alex-movila opened 5 years ago

alex-movila commented 5 years ago

Hi, After pressing button to reply the payload text is shown in the chat window. This happens in Chrome. Can I avoid this?

I use window.chatroom = new window.Chatroom

hotzenklotz commented 5 years ago

I think this is the intended behavior. Currently, there is no way to disable the button response. Note, the only the button title should be displayed not the payload.

Feel free to submit a PR if you like to make this configurable.

alex-movila commented 5 years ago

I get the payload not the title: /roger image

utter_ask_ok_quit:

hotzenklotz commented 5 years ago

Indeed, you are right. Looks like the payload is being send: https://github.com/scalableminds/chatroom/blob/master/src/ConnectedChatroom.js#L179

alex-movila commented 5 years ago

It is normal to be sent but not normal to be rendered since for user is gibberish.

rgstephens commented 5 years ago

I'm seeing this behavior but also one other issue shown i @alex-movila example above. The text "Choose" should show up before the two buttons.

rgstephens commented 5 years ago

Just realized the text issue is addressed in 0.10.1, PR 112

hotzenklotz commented 5 years ago

@rgstephens Just to clarify, the issue is fixed in version 0.10.1? If so, please close the issue. Thanks.

rgstephens commented 5 years ago

I've updated now to 0.11.0 and the issue with the text not showing is fixed. However, the original problem reported by @alex-movila where the payload is displayed is still a problem in 0.11.0. As his example shows, the /roger payload is displayed after the user selects the button.

fallik commented 4 years ago

Hi there, I might have a little workaround for you. I solved this by checking each message for a regex pattern in the Message.js (switch case "text"). Like this:

var dispMsg = message.text;
if (pattern.exec(message.text)) {
            dispMsg = replacement;
}

My pattern looks like this: /\/roger/g. The replacement string can be anything you want it to be... In the Markdown below just replace source={message.text} with source={dispMsg}.