Okay, so when I started to move all my automations into Microsoft Flow, one part I was missing was a super easy way to trigger a Flow manually. I have used the Chrome extension Zapier Push to great success before, but that only triggers Zaps. I need something more flexible.

This post describes how to trigger a Flow from one click in your browser.

Simple trigger

First, I’m creating a trigger that starts a Flow, but does not pass any data with it.

Flow configuration

Select the built in Request-trigger When a HTTP request is received

Flow trigger

Next, create the rest of the Flow and save it. Copy the HTTP POST URL, you’re going to need that soon.

Simple request trigger

The bookmark

Create a new bookmark in your browser, and put this Javascript as the URL of the bookmark.

javascript:(
    function(){
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function() {
            if (this.readyState == 4) {
                if (this.status > 299) {
                    alert("Something failed.\nHTTP Status Code: " + this.status);
                } else {
                    alert("Success");
                }
            }
        };
        xhr.open("POST","Put your HTTP POST URL here", true);
        xhr.send();
    }
)();

Make sure to change the URL to the actual URL you copied from the Request-trigger in Flow. The bookmark should look something like this:

The bookmark

The result

Now, whenever you click the bookmark, the Flow should trigger.

Result of successfully ran Flow

Get the referer

If you go through the Headers in the received request, you might find a very interesting header. I’m thinking of course of the Referer-header, which has the value of your browser window’s url when you clicked the bookmark. You can access this field in a later step with dynamic content:

triggerOutputs()['headers']['Referer']
Initialize variable with dynamic content

Trigger with data

In some cases, it would be nice to pass in some other data when you click the bookmark. This is also pretty simple to fix.

First, we need to edit the schema for our trigger in Flow. I am setting up the schema to receive one property with the name key and with the type string:

{
    "type": "object",
    "properties": {
        "key": {
            "type": "string"
        }
    }
}

My trigger is now ready to receive aditional data:

Trigger with schema

Next, I change my bookmark to start with a prompt, and I am sending the result of the prompt with the request.

javascript:(
    function(){
        var data = prompt("Enter the value:", "Default value");
        if (data == null || data == "") {
            alert("Input cancelled");
            return;
        }
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function() {
            if (this.readyState == 4) {
                if (this.status > 299) {
                    alert("Something failed.\nHTTP Status Code: " + this.status);
                } else {
                    alert("Success");
                }
            }
        };
        xhr.open("POST","Put your HTTP POST URL here", true);
        xhr.setRequestHeader("Content-Type", "application/json");
        xhr.send(JSON.stringify({key: data}));
    }
)();

When I click the bookmark now, I have to type in the value:

Browser prompt

And when the Flow now is triggered, the additional data is included:

Flow trigger with data

That data can be accessed in a later step with dynamic content

triggerBody()['key']