# Outlook and Gmail (Using Azure Logic App)

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.

***

### Prerequisites

1. An Azure account with subscription (Create an Azure account [here](https://azure.microsoft.com/en-us/free)).
2. An Azure workflow Logic App of your choice (Create an Azure logic app [here](https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-overview)).

***

### Deploy Azure Logic App Flow

In Azure portal search for **Logic App** and choose the Logic App you want to use.

Under **Logic app designer** do the following:

#### Add workflow trigger fires "When a HTTP request is received"

Add the following Request Body JSON Schema and **save**.

```
{
    "type": "object",
    "properties": {
        "email": {
            "type": "string"
        },
        "cc": {
            "type": "string"
        },
        "subject": {
            "type": "string"
        },
        "body": {
            "type": "string"
        }
    }
}
```

As follow:

![](https://files.readme.io/7e93be2-image.png)

#### Send request events to Outlook API

1. Press on the + button to add an action and search for **Outlook**. **Under** the Gmail API choose **Send an email (V2)**, as follow:

![](https://files.readme.io/e6442b9-image.png)

2. In Send an email (V2) action, configure the **"When a HTTP request is received" trigger** values by standing on each value input and press on the lightning icon and choose the relevant value as follow and **save**:

![](https://files.readme.io/0ae4275-image.png)

![](https://files.readme.io/5e2699b-image.png)

![](https://files.readme.io/2e649e0-image.png)

***

#### Send request events to Gmail API

1. Press on the + button to add an action and search for **Gmail**. **Under** the Gmail API choose **Send email (V2)**, as follow:

![](https://files.readme.io/061a6b4-image.png)

2. In Send email (V2) action, configure the **"When a HTTP request is received" trigger** values by standing on each value input and press on the lightning icon and choose the relevant value as follow and **save**:

![](https://files.readme.io/8429765-image.png)

![](https://files.readme.io/4a03b40-image.png)

![](https://files.readme.io/f6f7b1a-image.png)

***

### Create the webhook

Follow these steps to configure a webhook:

1. On the [**Webhooks**](https://app.apono.io/webhooks) page, click **Add Webhook**. The **Add Webhook** page appears.
2. Click **Request Webhook**.
3. Enter a unique, alphanumeric, user-friendly **Request Webhook Name** for identifying this webhook.
4. Click the **Status** toggle to **Active**.
5. From the **Method** dropdown menu, select **POST**
6. In the **URL** field, enter the Workflow URL for the Logic App. This is located on the **Overview** page in your Azure Portal

{% hint style="warning" %}
The webhook URL **must adhere** to the following requirements:

* Uses the HTTPS protocol
* Does **not** specify any custom ports
  {% endhint %}

7. In the **Body Template** field, construct a JSON body for the webhook payload.

{% code overflow="wrap" %}

```json
{
   "email": "<OUTLOOK/GMAIL_MAILBOX_TO_SEND_THE_EVENTS>",
   "cc": "<LIST_OF_OUTLOOK/GMAIL_MAILBOXS_TO_SEND_THE_EVENTS_SEPARATED_BY_A_SEMICOLON_OR_A_COMMA>",
   "subject": "New {{event_type}} request event from Apono made by {{data.requester.name}}",
   "body": "<p>We are excited to inform you about a new event request that requires your attention</p><p>Event Type: {{event_type}}</p><p>Event Time: {{event_time}}</p><p>Integration: {{data.access_groups.[0].integration.name}}</p><p>Requester Name: {{data.requester.name}}</p><p>Requester Email: {{data.requester.email}}</p>"
}
```

{% endcode %}

{% hint style="success" %}
Click **View event's payload schema** to reveal the payload schema and available data fields. You can also refer to the [Webhook Payload Schema Reference](/docs/webhook-integrations/webhook-payload-references/webhook-payload-schema-reference.md) to read the descriptions of each data field.
{% endhint %}

8. From the **Triggers** dropdown menu, select one or more of the following event triggers, which correspond to Apono access request statuses:
   * **RequestCreated**
   * **RequestApproved**
   * **RequestExpired**
   * **RequestFailed**
   * **RequestGranted**
   * **RequestRejected**
9. Under **Filters**, define one or several filter from the listed dropdown menus.

{% hint style="info" %}
Filters empower admins to control the data transmitted via webhooks, minimizing the amount of data third-party tools receive and reducing unnecessary clutter.

**Examples**:

* Send only production requests to your admins' Slack channel.
* Trigger Okta workflows for events from specific integrations or resource types.
* Open a ticket in Jira or ServiceNow for manually approved requests.
  {% endhint %}

9. (Optional) In the **Timeout in seconds** field, enter the duration in seconds to wait before marking the request as failed.
10. (Optional) Define **Response Validators** to verify that the response from the webhook meets specified criteria:
    1. Click **+ Add**. A row of settings appears.
    2. Starting with *$.data.*, enter the **Json Path** of the JSON parameter.
    3. In the **Expected Values** field, enter a value and press the Enter key on your keyboard.
    4. Repeat step **c** to add several expected values.
    5. Repeat steps **a-d** to add multiple response validators.
11. Click **Test** to generate a test event to trigger your webhook. A **Test successful** or **Test failed** response status will appear at the bottom of the page. A successful test will send mock data to the target system.

{% hint style="success" %}
For more information about the test, click **View Invocation Data**. A panel opens revealing the request, response, and other relevant details.

Should your test fail, view these tips to [troubleshoot your webhook](/docs/webhook-integrations/troubleshoot-a-webhook.md).
{% endhint %}

12. Click **Save Webhook**.

The new webhook appears in the **Webhooks** table. Active webhooks are preceded by a green dot. Inactive webhooks are preceded by a white dot.

Apono access request logs will be sent to Outlook and Gmail based on the triggers you have selected.

***

## Results

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

![](https://files.readme.io/ba058b3-image.png)

![](https://files.readme.io/99455c9-image.png)

![](https://files.readme.io/f8a0674-image.png)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.apono.io/docs/webhook-integrations/request-webhook/communications-and-notifications/outlook-and-gmail-using-azure-logic-app.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
