Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot Emulator PostBack #1140

Closed
tdurnford opened this issue Dec 4, 2018 · 3 comments
Closed

Bot Emulator PostBack #1140

tdurnford opened this issue Dec 4, 2018 · 3 comments
Assignees
Labels
Approved Approved by the Triage team Bug Your classic code defect

Comments

@tdurnford
Copy link

Version

Emulator: 4.1.0
SDK: NodeJs V4.1.5

Description

In response to this StackOverflow question, I created a simple bot with the NodeJs V4 SDK that responds to a user's message with a Hero Card. The card has two action buttons: a PostBack and an ImBack Action. The first time the user clicks the PostBack action in a new conversation the emulator sends the value of the action as a message from the user; however, all subsequent times the user selects the PostBack action, it does not send the value as a message. I also deployed this bot to the WebChat channel where everything worked as expected. Consequently, I suspect this is an issue with the emulator.

Code

onTurn Function

async onTurn(turnContext) {
        if (turnContext.activity.type === ActivityTypes.Message){
            await turnContext.sendActivity(`You said '${turnContext.activity.text}'`)
             await turnContext.sendActivity({ attachments: [this.createHeroCard()] });
        } else if (turnContext.activity.type === ActivityTypes.ConversationUpdate){
            for (const idx in turnContext.activity.membersAdded){
                if (turnContext.activity.membersAdded[idx].id === turnContext.activity.recipient.id){
                    await turnContext.sendActivity(`Welcome to PostBack Bot! Say something to begin.`);
                }
            }
        }
    }

Hero Card Helper Function

createHeroCard() {
        return CardFactory.heroCard(
            'BotFramework Hero Card',
            CardFactory.images(['https://sec.ch9.ms/ch9/7ff5/e07cfef0-aa3b-40bb-9baa-7c9ef8ff7ff5/buildreactionbotframework_960.jpg']),
            CardFactory.actions([
                {
                    type: ActionTypes.PostBack,
                    title: "PostBack",
                    value: 'PostBack'
                }, 
                {
                    type: ActionTypes.ImBack,
                    title: "ImBack",
                    value: 'ImBack'
                }
            ])
        );
    }

Expected behavior

PostBack Actions are not supposed to send a visible message from the user in the emulator channel; however, one is being sent the first time a PostBack action is invoked.

Screenshots

postback

@justinwilaby
Copy link
Contributor

This is related to, or a duplicate of #1134

@justinwilaby justinwilaby added the Bug Your classic code defect label Dec 4, 2018
@vishwacsena
Copy link
Contributor

@justinwilaby this does not appear to be a dupe of #1134. This is more of a behavioral issue with the PostBack card action. When emulator responds with postback, the actual message value should not be rendered on the canvas; however the message is rendered to the user the first time the button is clicked.

I have a repro set up here -

  1. Clone botbuilder-samples branch
  2. checkout vishwac/repro/em-1140 branch
  3. cd into samples/javascript_nodejs/06.using-cards/
  4. npm i & npm start
  5. connect to the bot using v4 emulator
  6. send 'hi' - bot responds back with a choice prompt
  7. choose '3' for hero card
  8. click on '[Post Back] hi'

Expected: Emulator does not show 'hi' as message sent from user
Actual: Emulator shows 'hi' as message sent from user.

Note that subsequent times you click on '[Post Back] hi' does the right thing and does not render user's message on the canvas.

@vishwacsena vishwacsena added Approved Approved by the Triage team 4.2 labels Dec 5, 2018
justinwilaby pushed a commit that referenced this issue Dec 6, 2018
fixes #1140 - postback messages showing up in webchat
@robert4os
Copy link

I am using v3.15.2.2 and I just noticed this problem. 3.15 was released 8 months ago! I wonder, how this problem went unnoticed for so long? Will there be a fix for v3 too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Approved by the Triage team Bug Your classic code defect
Projects
None yet
Development

No branches or pull requests

4 participants