Outlook and Gmail (Using Azure Logic App)

Create an outgoing webhook in Apono that will send emails to Outlook / Gmail based on Apono access requests using Azure Logic App

Intro

An Azure Logic App integration can seamlessly connect with Outlook or Gmail using their respective APIs to send Apono access requests events. By configuring triggers to initiate actions based on specified conditions, the Logic App can efficiently gather the necessary data and format it appropriately for transmission.

Utilizing Azure's secure connectivity and workflow automation capabilities, this integration ensures reliable and timely delivery of event notifications to users' Outlook or Gmail accounts, streamlining communication and enhancing productivity.

Step-by-step guide

Prerequisites

  1. An Azure account with subscription (Create an Azure account here).
  2. Deploy an Azure workflow Logic App of your choice.
  3. Create Azure API connection to Outlook / Gmail

Deploy Azure Logic App Flow

In Azure portal search for Logic App and choose the Logic App you want to use. Under Logic app code view copy the following code:

Outlook API

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Send_an_email_(V2)": {
                "inputs": {
                    "body": {
                        "Body": "<p>@{triggerBody()?['task']}</p>",
                        "Importance": "Normal",
                        "Subject": "@triggerBody()?['task']",
                        "To": "@triggerBody()?['email']"
                    },
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['outlook']['connectionId']"
                        }
                    },
                    "method": "post",
                    "path": "/v2/Mail"
                },
                "runAfter": {},
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "When_a_HTTP_request_is_received": {
                "inputs": {
                    "schema": {
                        "properties": {
                            "due": {
                                "type": "string"
                            },
                            "email": {
                                "type": "string"
                            },
                            "event_type": {
                                "type": "string"
                            },
                            "requester_email": {
                                "type": "string"
                            },
                            "requester_name": {
                                "type": "string"
                            },
                            "task": {
                                "type": "string"
                            }
                        },
                        "type": "object"
                    }
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "outlook": {
                    "connectionId": "<OUTLOOK_API_CONNECTION_RESOURCE_ID>",
                    "connectionName": "<OUTLOOK_API_CONNECTION_NAME>",
                    "id": "<OUTLOOK_API_CONNECTION_API_ID>"
                }
            }
        }
    }
}

Where

  • OUTLOOK_API_CONNECTION_RESOURCE_ID is your API connection resource id.
  • OUTLOOK_API_CONNECTION_NAME is your API connection name.
  • OUTLOOK_API_CONNECTION_API_ID is your API connection API Id.

Gmail API

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Send_email_(V2)": {
                "inputs": {
                    "body": {
                        "Body": "<p>@{triggerBody()?['task']}</p>",
                        "Subject": "@triggerBody()?['task']",
                        "To": "@triggerBody()?['email']"
                    },
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['gmail']['connectionId']"
                        }
                    },
                    "method": "post",
                    "path": "/v2/Mail"
                },
                "runAfter": {},
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "When_a_HTTP_request_is_received": {
                "inputs": {
                    "schema": {
                        "properties": {
                            "due": {
                                "type": "string"
                            },
                            "email": {
                                "type": "string"
                            },
                            "event_type": {
                                "type": "string"
                            },
                            "requester_email": {
                                "type": "string"
                            },
                            "requester_name": {
                                "type": "string"
                            },
                            "task": {
                                "type": "string"
                            }
                        },
                        "type": "object"
                    }
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "gmail": {
                    "connectionId": "<GMAIL_API_CONNECTION_RESOURCE_ID>",
                    "connectionName": "<GMAIL_API_CONNECTION_NAME>",
                    "id": "<GMAIL_API_CONNECTION_API_ID>"
                }
            }
        }
    }
}

Where

  • GMAIL_API_CONNECTION_RESOURCE_ID is your API connection resource id.
  • GMAIL_API_CONNECTION_NAME is your API connection name.
  • GMAIL_API_CONNECTION_API_ID is your API connection API Id.

📘

You can find your OUTLOOK_API_CONNECTION_RESOURCE_ID / GMAIL_API_CONNECTION_RESOURCE_ID and OUTLOOK_API_CONNECTION_API_ID / GMAIL_API_CONNECTION_API_ID in your Api Connection resource page, in the Overview upper right corner click on JSON View and you will see those values as follow:

Set up the Webhook

  1. In the Apono admin portal, click your avatar at the bottom left corner, click Settings and pick Webhooks
  1. Click Add Webhook

  2. Fill in the following fields:

  3. Method - POST

  4. URL

    YOUR_LOGIC_APP_WORKFLOW_URL
    

    you can find YOUR_LOGIC_APP_WORKFLOW_URL in your Logic App Overview page

  5. The webhook body:

{
    "task": "New {{event_type}} request event from Apono made by {{data.requester.name}}",
    "due": "{{event_time}}",
    "email": "<OUTLOOK/GMAIL_MAILBOX_TO_SEND_THE_EVENTS>",
    "event_type": "{{event_type}}",
    "requester_email": "{{data.requester.email}}",
    "requester_name": "{{data.requester.name}}"
}

This is an example body. You may use other fields according to your needs. See the schema to the right of the screen to learn more about available data fields.

  1. Triggers - you may pick one or more triggers. Triggers correspond to Apono access request statuses:
  • Created
  • Approved
  • Rejected
  • Granted
  • Expired
  • Failed
  1. Name - any name of your choosing. This will be displayed in the webhooks table.
  2. Status - if you save the webhook as active, it can be triggered immediately. If you prefer, you may also save it as inactive and activate it later.
  3. Optional: Test your webhook configuration. You should see ok as the response status.
    Please note: The Test will send a email using Azure Logic App to Outlook / Gmail with mock data.

Results

Your webhook should now start sending emails using Azure Logic App to Outlook / Gmail once triggered: