# Microsoft Outlook

## Pre-requisite

A valid Microsoft 365 license assigned to the Azure Active Directory user. Refer: <https://learn.microsoft.com/en-us/answers/questions/761931/microsoft-graph-api-throws-the-mailbox-is-either-i>

## Create credential in Flowise

1. Add a new Microsoft Outlook OAuth2 credential
2. Enter a name for the credential.
3. Copy the OAuth Redirect URL.
4. Note that the following fields need to be filled in:
   * Authorization URL
   * Access Token URL
   * Client ID
   * Client Secret

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fjf49ExDH2z374uLPI573%2Fimage.png?alt=media&#x26;token=b83d89bc-4661-4825-ac30-2d2420e81fd3" alt="" width="437"><figcaption></figcaption></figure>

## Create an Azure application <a href="#h_8276f6aa94" id="h_8276f6aa94"></a>

1. Login to your existing [Azure](https://login.microsoftonline.com/) account or [sign up](https://signup.live.com/signup) if you haven't already signed up
2. Search for **App registrations**.
3. Next, register a new Azure application in [app registrations](https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/CreateApplicationBlade/quickStartType~/null/isMSAApp~/false).

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2F5f4FaB5ItIKSLwBBiVqj%2Fimage.png?alt=media&#x26;token=3dd33187-6a0f-49ae-abae-b2ce6731424c" alt="" width="304"><figcaption></figcaption></figure>

4. Under "Redirect URI (optional)", select "Web" and paste your "OAuth Redirect URL" you copied earlier.

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2FCKmO3SQiddLPvC4Bjq06%2Fimage.png?alt=media&#x26;token=90668ea3-f1fd-47a9-a3f5-c8d47e989246" alt=""><figcaption></figcaption></figure>

5. After created application, navigate to **Certificates & secrets** > **Client secrets** and click on the "**New client secret**" button to create a client secret. Copy the secret to use later.

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2F16HAcTULzzKK3G3X4Ido%2Fimage.png?alt=media&#x26;token=3adcd719-b339-4650-adb5-25169be39a5f" alt=""><figcaption></figcaption></figure>

6. Navigate to **Overview** and click "**Endpoints**". Copy the endpoints for "**OAuth 2.0 authorization endpoint (v2)**" and "**OAuth 2.0 token endpoint (v2)**".

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2FIueV9n4DwMCHKZ3egEtc%2Fimage.png?alt=media&#x26;token=e38cde6b-7e62-4d3f-9164-3f6250639d5d" alt=""><figcaption></figcaption></figure>

7. Close the Endpoints popup, copy the **Application (client) ID**:

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fs1z749Ao9jcuVQJC0zP2%2Fimage.png?alt=media&#x26;token=4da8fccb-87bb-40b1-9e81-8fe4f7fa1a8c" alt="" width="563"><figcaption></figcaption></figure>

## Finish setup in Flowise

1. Fill in all the values copied earlier. Then click "**Authenticate**":

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2FJQp4Pdw6lJCdsLVVvPpO%2Fimage.png?alt=media&#x26;token=5f339442-8f9d-4b35-a3cd-1a2c28206d4f" alt="" width="440"><figcaption></figcaption></figure>

2. A Microsoft window will pop up, select the account.

{% hint style="warning" %}
The account user must have a valid Microsoft 365 licensed
{% endhint %}

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fh8n7hQsQae20eTpb0BGg%2Fimage.png?alt=media&#x26;token=a42c8143-03c3-4253-8678-90cbcdfa3840" alt="" width="459"><figcaption></figcaption></figure>

3. Grant the required permissions:

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2FER0JNlyFcxcz9OlvlbJn%2Fimage.png?alt=media&#x26;token=f5715423-f347-4b51-a564-646539d82a8c" alt="" width="454"><figcaption></figcaption></figure>

4. The pop up will automatically close, and credential will be saved afterwards.

## Use as Agent Tool

Multiple actions can be selected to let the Agent intelligently choose the appropriate one.\
Parameters can be left empty to allow the Agent to determine the values on its own. However, if the user provides values, those will override the Agent's choices.

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2FV4KmGGJzr3GSSZstgEdI%2Fimage.png?alt=media&#x26;token=4e9db2cd-3397-43a2-bad7-96aceff8854b" alt=""><figcaption></figcaption></figure>

## Use as Tool Node

It can also be used as a Tool Node in a determined workflow scenario. For example, retrieving a list of Outlook messages before proceeding to the next step.\
In this mode, **Tool Input Arguments must be explicitly defined and filled with values**.\
Unlike the [**Use as Agent Tool**](#use-as-agent-tool) option, there is no Agent to automatically determine the inputs. The user must manually populate the fields, either by entering fixed values or using variables enclosed in double curly brackets `{{ }}`.

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2FfRhJ1EM3UHVkJWaQijrN%2Fimage.png?alt=media&#x26;token=d5353010-c077-4087-8bc7-9608c9467bed" alt=""><figcaption></figcaption></figure>
