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

Action Buttons #14

Open
assafweinberg opened this issue May 8, 2016 · 5 comments
Open

Action Buttons #14

assafweinberg opened this issue May 8, 2016 · 5 comments

Comments

@assafweinberg
Copy link

More of a question than an issue. When you create an action button like

%[Button Text](postback:button action)

How do you specify the handler for the postback. What does "button action" map to? Can you show an example?

@Pol-Lanski
Copy link

Yeah, I'm having the same issue! I'd love it if someone could clarify.

@btutal
Copy link

btutal commented May 10, 2016

i guess currently it looks for postbacks labels and uses them as a command. %Label for this one it will answer like user says "Label" not sure but at least smooch supports said that.

@alavers
Copy link
Contributor

alavers commented May 13, 2016

Hey folks, I've updated the readme with some clarity around how postback buttons work:

https://github.com/esthercrawford/EstherBot/blob/master/README.md

@assafweinberg
Copy link
Author

assafweinberg commented May 16, 2016

@alavers - Thanks for the update. I still don't have it working though. It seems like the app.post('/webhook', function(req, res, next) { code fires only when the user types something, but not when they press an action button. It could be that I have something else wrong in my setup, but I'm not sure what.

Also, I'm surprised that the callback function that gets called depends on the user visible text, rather than the callback value. (e..g %[user text](postback:postbackValue) would trigger a state of "user text".

@kazekagekorosu
Copy link

kazekagekorosu commented May 16, 2016

there's also an issue with postback as well, the the text has to match the postback value...
so in your jscript file...it works like this...

The problem seems to be because of the way EstherBot was (oddly) coded. It's actually the button label that it sent as a reply. If you were to use this postback button:

%[Sure!](postback:multi_word)
This would be fine usually; having multiple words isn't related to your issue and that would work under regular circumstances. When the user clicks on the postback, the bot is actually listening to Sure! instead. Which didn't have any entry in your script.json.

To fix your issue, you can add an entry for SURE!

%[SURE!](postback:multi_word)
"SURE!":"...
or rename the label to MULTI WORD.

%[MULTI WORD](postback:multi_word)
"MULTI WORD":"...

this is from Danny Tran from stackoverflow...so thanks to him for finding this!

I think it's obvious but I'll state it again...
you write
KEYWORD: "phrase here %[buttonlabel](postback:buttonlabel)",
BUTTONLABEL: "text from when buttons pushed",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants