botman / web-widget

MIT License
37 stars 68 forks source link

When using Question (backend), the answer of the user is not displayed #19

Open joaquin03 opened 5 years ago

joaquin03 commented 5 years ago

Hi and thank you for the library!

I don't now if im doing something wrong.

This is what is happening:

screen shot 2018-10-17 at 11 42 23 am screen shot 2018-10-17 at 11 42 29 am

I think it will be nicer if the replay of the user is visible in the chat.

Thanks!

Edd-G commented 5 years ago

Hi! Confirm.

jjsquady commented 5 years ago

+1

christoph007 commented 5 years ago

This is indeed a problem. When the user writes a message, this message appears is the message area as a user message. But when the user clicks on a button, all the buttons disappear, and there is no user message generated at all. It would be nice to add the label of the button pressed as a user message.

LiamRoels commented 5 years ago

No updates on this yet?

maqnouch commented 4 years ago

No updates?

bobkosse commented 3 years ago

@joaquin03 @Edd-G @jjsquady @christoph007 @LiamRoels @aqnouch

I made a little fix in 2 files:

chat\messages\action.tsx: Added those 2 lines to the performAction method:

var event = new CustomEvent('buttonSelection', {'detail': { message: action.text}});
window.dispatchEvent(event);

chat\chat.tsx Add an eventLIstener tot the componentDidMount method like this:

// Add event listener for button clicks
window.addEventListener("buttonSelection", (e) => {
            try {
                // @ts-ignore
                this.onlySay(e.detail.message);
            } catch (e) {
                //
            }
        });

Because I didn't want the backend called for this message I added a new onlySay method that does only the frontend work:

onlySay(text: string, showMessage = true) {
        const message: IMessage = {
            text,
            type: "text",
            from: "visitor"
        };

        if (showMessage) {
            this.writeToMessages(message);
        }
    }

I think there should be options that work better but in my case this was working very well.

Schermafbeelding 2021-03-30 om 15 29 07 Schermafbeelding 2021-03-30 om 15 30 17
jjsquady commented 3 years ago

Thanks @bobkosse I ll try this fix. 😉

bobkosse commented 3 years ago

Thanks @bobkosse I ll try this fix. 😉

Let me know if it works for you!

dbo90 commented 3 years ago

+1 no updates on this?

Novelz commented 2 years ago

Thank you @bobkosse Your solution kinda work in my setup, but now I have the clicked answer written 2 times, one as user (and that's ok) and one as bot. I can't wrap my head around it. Do you have any suggestion?

EranGrin commented 2 months ago

I created a new package that solves this and several other issues https://www.npmjs.com/package/botman-extended-web-widget