Limit Postback Button for Facebook Bot To One TIme Use - facebook-messenger

I have made a postback button that appears when a user messages the Facebook page a specific phrase, with 3 options to choose from as a trivia competition:
Option 1
Option 2
Option 3
Users can click an option, they will receive a follow-up message if it's right or wrong. If user clicks the right one, another postback button with question appears to continue, however if user clicks wrong one, just text gets sent that they have lost.
However, they still have the previous postback message that if they lose, they can choose the correct option to continue.
Is there a way to implement that the postback button be overwritten with new postback button, or if already selected an option not able to choose a different one.

You can use Floating Buttons ( Quick Reply ) for this purpose. When any user press floating buttons, the buttons disappear.
You can attach quick reply with your generic template card too.
See more about Quick Replies here: https://developers.facebook.com/docs/messenger-platform/send-messages/quick-replies/

Related

Issue checked in radio button

I'm developing about questions with step by step and I got bug on radio button with param "checked" in reactjs
Problem: the user can next question and back old question, the problem when I stored data on state that user checked radio button, I mean the question has 4 options and user choose option 2 and click next question but user want to back old question then I need to checked option that user choose on step 1, but when I want to choose another option then the old checked don't disappear, can you read my code below?
My code handled like this
Anyone had saw this problem before?
The example on below
when I choose 1 options and next
when I clicked previous button and choose another radio

Detect press of "cancel" on a Codename One lightweight date picker

On a Codename One lightweight date pickers, the user has four buttons in the top, like in the following screenshot.
I suppose the tapping of the second, third and fourth buttons are detected by the .addActionListener() (please correct me if I'm wrong)... but I need to detected also the tapping of the "Cancel" button. How can I run some code when the user taps "Cancel"?
We don't provide a way to detect cancel since we can't consistently detect it on native. As a workaround you can listen to the click on the picker button and unless you get a selection it would mean that the action was canceled.
Alternatively we can add a feature like this for the lightweight picker only. If you need that you can file an RFE on that.
I overcame this by comparing the newly selected picker value to the previously stored value. If it’s the same, I consider it a cancel.

How to allow/stop an event based on a condition like YES or NO?

I need to allow or stop an event from happening, based on a given condition such as a pop up box with options YES, NO and CANCEL.
I need to notify the user saying that there are unsaved data and if the user wishes to SAVE it, IGNORE it or CANCEL his current action(event such as Selection-change or Click).
I tried to use createInterceptor() function. But could not achieve the functionality.
Can anybody give me some suggestions with example? Basically I want to know how to stop an event.
Thanks..
Edited
I like the idea of using beforeXXX events. But I am still facing problems. As I mentioned, I need to ask the user if he wishes to save the unsaved data, which is a popup message box (With options YES, NO and CANCEL) that runs asynchronously. So by the time I get a reply, the event will have happened.
For ex. lets imagine a situation where, there is a page that displays a list of records in a grid with a pagination toolbar attached to it on the bottom(with a page size of 10 and total number pages is 10. So totally 100 records) on the left hand side. If you select a record in the list, the details are shown in a detail view on the right hand side.
Now,
I select third record in the list and make some changes to it in the detail view(form).
Without saving the record, I click on next page button on the Pagination toolbar.
It will show a confirm box from the beforeXXX event of Pagination toolbar, but the event will have happened anyway.
Here if the user clicks on CANCEL, I will have to restore the previous state which is already gone. Somehow I will have to go back and select the third record in the list of previous page.
So in order to resolve this problem, if I return false from my beforeXXX event, the next XXX event will be not be triggered.
But if the user clicks on YES or NO options I will have to trigger the event XXX manually which I am unable to do it for a selection-change event as of now.
Like this there can be many operations like list-filtering, searching, Ordering(A-Z/ Z-A), logout etc. For each of this operation I will have to write customised code which totally spoils the readability of the code.
So I was thinking if there is way to, somehow manually trigger the event XXX by holding the event object in beforeXXX...or is there any other way to restore the previous state.
Please give me suggestions....Thanks...
Many events have their "before-" counterpart, for example "beforeactivate". If you return false from this kind of the processing stops.
If not, or if your event does not have it's before- part, then you can use event object passed to all event handlers and call:
ev.stopEvent();
ev.stopPropagation();
return false;
at the end of your handler.

Dialog box closes slowly after clicking send button

In my webapp, I have a send dialogue box which sends the data to a selected email address. The issue is that the dialog box disappears after few seconds of clicking send button which makes the user click send button multiple times as a result of which same mail is sent multiple times.
What I think is that this can be a function of the speed of the DB (and probably the size of the data).
If it takes several second to receive confirmation then you must reflect that in the UI, by putting up a "wait" cursor, disabling the "Send" button, possibly dimming the dialog box etc. There's nothing wrong with taking a few seconds as long as you make sure the user is aware and cannot click Send a second time
Even if you expect the operation to be nearly instantaneous in most cases, you STILL must reflect the possibility of a delay in the UI. That's just a fundamental UI design principle.

WP7 - Determine where the app will go when the "back" button is pressed

I'm working on a WP7 appliation with Silverlight. When a user clicks the back button, I want to determine where they will go to. Is there a way to determine where a user will go without managing my own nav stack?
thanks!
To respond to the question that has actually been asked "Is there a way to determine where a user will go without managing my own nav stack?"
You could use the OnNavigatingFrom override the eventargs of which carries the Uri of the page being navigated to. I suspect this is only useful when the navigation is back to page within your app.
You cannot override what the back button does - the rule Derek mentioned is enforced by the system and the previous page/app will always be called.
You can, however, add an action to be executed on back key press:
this.BackKeyPress += new EventHandler<System.ComponentModel.CancelEventArgs>(MainPage_BackKeyPress);
Then just use the handler:
void MainPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
{
// Your activity goes here
}
The application will go back to the previous page when the user presses the Back button. If the user is at the last page in the application, then the application will exit and the user will be navigated to the previous application. To perform anything else would be inconsistent, confusing to the user, and almost certainly would fail certification.
In general you'll want to build your app composed of pages (similar to a website). For example a HyperlinkButton might be used like this:
<HyperlinkButton NavigateUri="/Page2.xaml" Content="Click here to enter page 2"/>
After clicking that then pressing the back button will automatically return to the previous page. There's no extra programming involved to make this happen... it just works.
But there are some circumstances where you'll want to override the back button. The one I ran into was the dialog box. If your app creates a dialog box, then the back button should close it instead of returning to the previous page. I wrote a brief article about how to accomplish this.
And here's a complete list of rules from Microsoft's certification requirements concerning the back button:
To maintain a consistent user
experience, the Back button must only
be used for backwards navigation in
the application.
a. Pressing the Back button from the
first screen of an application must
exit the application.
b. Pressing the Back button must
return the application to the previous
page.
c. If the current page displays a
context menu or a dialog, the pressing
of the Back button must close the menu
or dialog and cancel the backward
navigation to the previous page.
d. For games, when the Back button is
pressed during gameplay, the game can
choose to present a pause context menu
or dialog or navigate the user to the
prior menu screen. Pressing the Back
button again while in a paused context
menu or dialog closes the menu or
dialog.
As I found out, if you don't follow those rules they won't approve your app.

Resources