Skip to main content

Automate your bank – Monzo API with Microsoft Flow

In this guide we will create an HTTP endpoint using flow , which Monzo will call every time a new transaction occurs in our account. I will also provide a few examples as to what you can do with the data provided to us from Monzo but the possibilities are pretty much endless with Flow. Although this is aimed at Monzo account users, this same principles can be applied to any other service that allows you to create webhooks!

Microsoft Flow is a cloud based service that allows you to create and automate workflows across multiple applications without the need to write any code. You can get access to flow for free with just a Hotmail/Outlook email address. The free plan allows up to 750 workflow executions per month. Thank you Microsoft!!

Firstly head over to https://developers.monzo.com to get your Monzo dev account setup.Open up flow and create a new blank workflow

Add a “When a HTTP request is received” step. Copy and paste in the below JSON code into the request body JSON Schema, it’s a long one! This is basically a definition of the transaction message sent by Monzo described here.

{
    "type": "object",
    "properties": {
        "type": {
            "type": "string"
        },
        "data": {
            "type": "object",
            "properties": {
                "account_id": {
                    "type": "string"
                },
                "amount": {
                    "type": "number"
                },
                "created": {
                    "type": "string"
                },
                "currency": {
                    "type": "string"
                },
                "description": {
                    "type": "string"
                },
                "id": {
                    "type": "string"
                },
                "category": {
                    "type": "string"
                },
                "is_load": {
                    "type": "boolean"
                },
                "settled": {
                    "type": "string"
                },
                "merchant": {
                    "type": "object",
                    "properties": {
                        "address": {
                            "type": "object",
                            "properties": {
                                "address": {
                                    "type": "string"
                                },
                                "city": {
                                    "type": "string"
                                },
                                "country": {
                                    "type": "string"
                                },
                                "latitude": {
                                    "type": "number"
                                },
                                "longitude": {
                                    "type": "number"
                                },
                                "postcode": {
                                    "type": "string"
                                },
                                "region": {
                                    "type": "string"
                                },
                                "short_formatted": {
                                    "type": "string"
                                },
                                "formatted": {
                                    "type": "string"
                                },
                                "zoom_level": {
                                    "type": "number"
                                },
                                "approximate": {
                                    "type": "boolean"
                                }
                            }
                        },
                        "created": {
                            "type": "string"
                        },
                        "group_id": {
                            "type": "string"
                        },
                        "id": {
                            "type": "string"
                        },
                        "logo": {
                            "type": "string"
                        },
                        "emoji": {
                            "type": "string"
                        },
                        "name": {
                            "type": "string"
                        },
                        "category": {
                            "type": "string"
                        },
                        "online": {
                            "type": "boolean"
                        },
                        "atm": {
                            "type": "boolean"
                        },
                        "updated": {
                            "type": "string"
                        },
                        "metadata": {
                            "type": "object",
                            "properties": {
                                "created_for_transaction": {
                                    "type": "string"
                                },
                                "enriched_from_settlement": {
                                    "type": "string"
                                },
                                "google_places_icon": {
                                    "type": "string"
                                },
                                "google_places_id": {
                                    "type": "string"
                                },
                                "google_places_name": {
                                    "type": "string"
                                },
                                "suggested_name": {
                                    "type": "string"
                                }
                            }
                        },
                        "disable_feedback": {
                            "type": "boolean"
                        }
                    }
                },
                "notes": {
                    "type": "string"
                },
                "metadata": {
                    "type": "object",
                    "properties": {}
                },
                "account_balance": {
                    "type": "number"
                },
                "attachments": {},
                "local_amount": {
                    "type": "number"
                },
                "local_currency": {
                    "type": "string"
                },
                "updated": {
                    "type": "string"
                },
                "counterparty": {
                    "type": "object",
                    "properties": {}
                },
                "scheme": {
                    "type": "string"
                },
                "dedupe_id": {
                    "type": "string"
                },
                "originator": {
                    "type": "boolean"
                },
                "include_in_spending": {
                    "type": "boolean"
                }
            }
        }
    }
}

Your HTTP flow step should look like the below .screenshot.

We also need to send a response back to Monzo saying, everything is good and that we have received the message.  Add a new action , search for response and add the action named Request ,response.Set the  status code to 200. Now save your flow, a HTTP POST URL will be generated in the When a HTTP request is received action which we`ll need later.

Go to your Monzo play ground you may have to log in again.

This is a very important step, select the list accounts endpoint and hit send. Search for your latest current account in the results below,if you used to have  a prepaid card you will most likely see two accounts. Find your current account, closed should be false, the account number and sort code should match. Note down the id of your account.

Switch to the register webhook endpoint. in the request body, replace $account_id with the account id copied earlier and url  to your generated flow HTTP post url, make sure to keep the surrounding quotation marks and hit send.

{
“account_id”: “Your account id”,
“url”: “Flow HTTP post URL”
}

Your webhook is now fully setup. Any new transactions in Monzo will now execute the flow. You can browse through the dozens of connectors available in flow, some examples are .  You can send the data to Power BI for analysis,  create a twitter post for every transaction ( not recommended but possible ) or even backup your transactions and insert a row into a database, Google Docs or Dropbox. You can send an email notification or thank you message if a specific person sends you money, which i`ll demo below quickly .

Add a new condition step below your flow, set to Description is equal to “Name of person”. If your current transaction is from another Monzo account holder their name will be in the description field of the message . In the yes section add a Gmail send email step, enter your contact’s email address and add something into the email body for example the amount and currency show below.  You could repeat this for multiple different people, or even add in conditions for specific merchants using the name field.

Thanks for reading, if you have some amazing Monzo Flow ideas, please let me know in the comments below.

 

Charles Osei

Dynamics 365 Consultant @ RSM MCSE Business Applications Computer Science – University of Lincoln 2017 Nottingham D365/CRM user group Chapter Leader TDG – Community leader Twitter @charliedevxyz LinedIn https://www.linkedin.com/in/charlesosei/

Leave a Reply

%d bloggers like this: