How to combine slash commands, buttons and dialogs for a menu? - slack

My Slack app is started with a slash command, which then posts an ephemeral menu message to the user. That menu has some information and three message buttons.
Example:
First button allows the user to close the menu
Second button allows the user to start an action
Third button allows the user to open a dialog for changing
options.
After the user submits the dialog I want to update the menu message to reflect the changes made in the dialog.
However, after the user submits the dialog I can no longer to update the message menu by responding to a Slack response as before.
How can I update the menu message with the changes?

In order to keep the connection with the initial slash command one needs to store the response_url of the last interactive action before opening the dialog.
In this example it will be in the interactive action request initiated after pressing the "Options" button. That response_url allows one to seamlessly continue the conversation that was started with the initial slash command.
The easiest approach for storing the response_url is to put it into the state property of the dialog, which will automatically be echoed back to the app with the dialog submission request.
One needs to be careful not to confuse the response_url from the interactive action with the response_url from the dialog.
Also, the dialog cancel case is automatically handled, since in that case the user can continue working with the initial menu message.

Related

How to detect whether a FormClosing event is from a user [X] button clicking?

In the FormClosing event handler of a Windows Form, I want to detect if the event is from a programmatically Form.Close() method call or through a user action in the user interface (for example, by clicking the Close button [X] on the form window).
I must show a dialog to confirm with the user whether he/she really wants to exit the application only if the FormClosing event is through a user clicking [X] button.
Is it possible? If yes, how to do?
Thanks you all in advance.

How to hide a Submit button on Oracle Workflow Notification after clicking it?

In an Oracle workflow process, I have a notification with a custom response of type "Submit". I want to hide this button after the user clicks it so he can't send the notification more than one time.
All I can find is #HIDE_REASSIGN Attribute to hide the Reassign button and #HIDE_MOREINFO Attribute to hide the Request Information button. But I want to hide a custom button based on a condition (clicking one time)

Slack respond to dialog submission with another dialog

Is there any way in the Slack API to have the submission button of a dialog open a new dialog or edit the current one?
Not directly. You can use the response_url attached to the dialog submission sent to your server to then post a follow up ephemeral message to the user, containing a button to continue to the next dialog. Once clicked, you'll receive another trigger_id which you can send to dialog.open and start another dialog.
More information on triggers and where to find them can be found here.

Open slack dialog by external app

The slack docs state that dialog's can be invoked using slash commands and buttons.
Is there however a way to not use either ? I would want my app to prompt user with a dialog. One option I found possible is to send a button via incoming web hooks or postMessage attachment than user clicks the button and opens a dialog but this seems like a needless step.
Another was to invoke the dialog via slash command but i cant find a way to invoke a slash comma d ia web api.
No. At least at the moment it is only possible in two ways:
With a slash commmand
With an interactive message
Both generate a trigger ID for the user, which is required to start your dialog and only valid for 3 seconds.
Source

Xamarin Forms - Navigation stack disrupted when send email

My cross-platform Xamarin Forms app (iOS and Android) needs to send an email (upon request from the user). Right now, when the user presses the appropriate button I'm calling
Page.Navigation.PushAsync(new SendEmailPage)
And then in the SendEmailPage constructor I'm using the DependencyService to send an email:
IMail mail = DependencyService.Get<IMail> ();
mail.SendMessage ("Contents");
I've implemented IMail in both Android and iOS, but looking just at the Android version:
void IMail.SendMessage (string contents)
{
Intent emailIntent = new Intent(Intent.ActionSend);
emailIntent.SetType ("message/rfc822");
emailIntent.PutExtra (Intent.ExtraEmail, new string [] { "me#notreal.com" });
emailIntent.PutExtra (Intent.ExtraSubject, "Subject");
emailIntent.PutExtra (Intent.ExtraText, contents);
Forms.Context.StartActivity (Intent.CreateChooser (emailIntent, "Send email"));
}
When I run this code, and click the appropriate button, it pops up an email "Compose" window with all the appropriate information filled in, and I can click the "send" button to send the mail. Cool!
Side Question: Am I correct in assuming there's no way to send an email "quietly" (without requiring additional user intervention)? This would not be something done maliciously, our app would only do this when the user asked to, and would certainly request the appropriate privileges if this is possible.
Main Question #1: When the "Compose" window comes up, if I click the back button in the title bar, it takes me back to my email Inbox, not back to my application. How do I invoke the email intent/activity in such a way that its back button brings the user back to my app?
Main Question #2: Instead, when the "Compose" window comes up, if I click the back button in the bottom of the screen, it does come back to my app, but tells me "Message saved as draft" which isn't what I want. I would rather have the message deleted, and then re-create it if the user hits the appropriate button again.
For Main Question #1, I believe that starting the activity with
Forms.Context.StartActivityForResult (Intent.CreateChooser (emailIntent, "Send email"));
instead of:
Forms.Context.StartActivity (Intent.CreateChooser (emailIntent, "Send email"));
should work to get you back to your Forms activity. At least in a non-forms app that should work, and I suspect it should in a Form app as well, but not 100% certain.
I can not answer your side question, though I suspect that this is intentional. I am sure you are not intending to do anything malicious and that the user requests the email, but if the OS allowed sending the email without user interaction, developers who are not as ethical as you might abuse the feature. But don't quote me, there may very well be a way to do it, I just don't know how if so.
As for Main Question #2, without changing the behavior of the email client app, I don't see how you could do as you wish as it is the mail client itself that is saving the email as a draft.

Resources