# Setup

> To enable the Microsoft Teams activities, your app must be integrated with the [Microsoft identity platform](https://docs.microsoft.com/en-us/azure/active-directory/develop/) and have the correct [Microsoft Graph API permissions](https://docs.microsoft.com/en-us/graph/auth/auth-concepts#microsoft-graph-permissions) assigned to it.

## Introduction

To enable the Microsoft Teams activities, your app must be integrated with the [Microsoft identity platform](https://docs.microsoft.com/en-us/azure/active-directory/develop/) and have the correct [Microsoft Graph API permissions](https://docs.microsoft.com/en-us/graph/auth/auth-concepts#microsoft-graph-permissions) assigned to it.

To integrate your application, assign permissions, and start building your automation project, you will first need to decide if you will create your own app or use the UiPath app (for example, UiPathStudioO365App).
:::important
If you are using the UiPath app then you will need to ensure that you add admin consent.
:::

If you do not add admin consent you will see the error below.

![docs image](https://dev-assets.cms.uipath.com/assets/images/marketplace/marketplace-docs-image-36236-12c5d0f5-b3e121f3.webp)

If you are creating your own app, you will need to follow the steps below.

After registering your Microsoft Office Teams application, Azure Active Directory assigns a unique application (client) ID that you enter in the **Microsoft Office Teams Scope**.
:::note
If you already completed the Microsoft Office 365 Activities or have an existing registered application, you can go straight to the [Add API permissions](https://integrations.uipath.com/docs/microsoft-teams-setup#section-add-api-permissions) section and add the necessary permissions for the Microsoft Teams activities.

After adding the permissions, you'll be able to use the same **ApplicationID** in both the **Microsoft Office 365 Scope** and **Microsoft Teams Scope** activities.
:::

![docs image](https://dev-assets.cms.uipath.com/assets/images/marketplace/marketplace-docs-image-33103-717b4b23-e99710e4.webp)

## Steps

### 1. Register your application

1. Sign in to the [Azure portal](https://portal.azure.com/) using your personal, work, or school Microsoft Office 365 account.
2. In the left-hand navigation panel, click **Azure Active Directory**.
3. After the **Azure Active Directory** page opens, click **App registrations**.
4. Click **+ New registration** in the top navigation bar.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/marketplace/marketplace-docs-image-36085-5b40fdbd-19fcef43.webp)
5. Enter a **Name** for your application (e.g., "*Office365App*").
6. Under **Supported account types**, select the option that applies to you.
   * For more information about which option to select, below are Microsoft's recommendations:
     + Accounts in this organizational directory only - Use this option if your target audience is internal to your organization.
     + Accounts in any organizational directory (Any Azure AD directory - Multitenant) - Use this option if your target audience is business or educational customers and to enable multitenancy.
     + Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox) - Use this option to target the widest set of Microsoft identities and to enable multitenancy.
   * Under **Redirect URI (optional)**, enter a URI address (if applicable).
   * Your selection is dependent on your authentication type. For more information on this topic, see the [Unattended and Attended Automation](https://docs.uipath.com/marketplace/automation-cloud/latest/user-guide/microsoft-teams-scope#microsoft-teams-scope) in the **Microsoft Teams Scope** activity details page).
   * In our example, the organization supports multi-tenant authentication and can only use the Interactive Token authentication type which requires a redirect URI.
   * If your authentication type is Integrated Windows Authentication or Username and Password, you don't need to register a redirect URI for your application. These flows do a round trip to the Microsoft identity platform v2.0 endpoint, and your application won't be called back on any specific URI.
   * For more information, see [Desktop app-registration](https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-desktop-app-registration) in the Microsoft identity platform documentation.
7. Click **Register**.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/marketplace/marketplace-docs-image-36208-faad13cb-5833c37c.webp)

   :::note
   Today the Microsoft Authentication Library (MSAL.NET) uses `urn:ietf:wg:oauth:2.0:oob` as the default redirect URI and this value will likely work for you when using the InteractiveToken authentication type (we use this in all of our examples and Quickstart guides). In the future, Microsoft plans to change the default redirect URI to `https://login.microsoftonline.com/common/oauth2/nativeclient`, so you may consider using this instead.
   :::

You're done! Now, let's add API permissions to your registered application.

### 2. Add API permissions

1. From your registered application page (**Azure portal > Azure Active Directory > App registrations >** *Office365App*), click **API permissions** in the left-hand navigation panel.
2. After the API permission page opens, click **+ Add a permission** (this opens the **Request API permissions** window).
3. Under **Select an API**, click **Microsoft APIs** (may be open by default).
4. Under **Commonly used Microsoft APIs**, click **Microsoft Graph**.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/marketplace/marketplace-docs-image-34279-9046010f-5d758750.webp)
5. Under **What type of permissions does your application require?**, click **Delegated permissions** to show the list of permissions.
   * While the **Application permissions** will also work, the activities are designed for apps with **Delegated permissions** assigned to the Microsoft Graph APIs.
   * For more information about permission types, see [Configure a client application to access web APIs](https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-configure-app-access-web-apis) in the Microsoft Azure documentation.
6. Use the search bar or scroll down the alphabetical list and select the following permissions:
   * **Chat.ReadWrite**
   * **Group.ReadWrite.All**
   * **User.Read.All**
7. Click **Add permissions** (returning you to your list of **API permissions**)

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/marketplace/marketplace-docs-image-34739-68e70dff-e4e50fa6.webp)
8. Verify your **API permissions** include your added **Chat**, **Group**, and **User** permissions.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/marketplace/marketplace-docs-image-36652-5e9c5c13-cca51d3f.webp)

### 3. Build your project

1. Create a new automation project.
   1. Open **UiPath Studio**.
   2. Under **New Project**, click **Process** (this opens a **New Blank Process** window).
   3. Enter a project **Name**, **Location**, and **Description**.
   4. Click **Create**.

      ![docs image](https://dev-assets.cms.uipath.com/assets/images/marketplace/marketplace-docs-image-33803-d4e1539f-b6a9faae.webp)
2. Install the **UiPath.MicrosoftTeamsActivities** package.
   1. In the **Design** ribbon, click **Manage Packages** (this opens the **Manage Packages** window).
   2. Under **All Packages**, click **Go!**
   3. In the **Search** bar, enter *Teams*.
   4. Click, install and accept the license for the **UiPath.Teams.Activities**.
      * For more information about Uipath Studio packages, see [Managing Packages](https://docs.uipath.com/studio/standalone/2023.4/user-guide/managing-activities-packages) in the Studio Guide.

        ![docs image](https://dev-assets.cms.uipath.com/assets/images/marketplace/marketplace-docs-image-34067-e99d336f-47189cb3.webp)

You're done!

Now that you have completed the setup, you can start adding the Microsoft Teams activities to your project.

## Next steps

For a hands-on learning experience and to quickly start using the activities, see the [Quickstart](https://docs.uipath.com/marketplace/automation-cloud/latest/user-guide/microsoft-teams-quickstarts) guides. These guides provide step-by-step instructions to help you create working samples of the different activities so that you can verify the connection to your registered app and get familiar with the input/output properties.

To learn more about the Microsoft Teams activities (including example property inputs/outputs), see the following activity pages for a complete activity list and links to the activity detail pages.

* [Channels](https://docs.uipath.com/marketplace/automation-cloud/latest/user-guide/microsoft-teams-channels)
* [Chats](https://docs.uipath.com/marketplace/automation-cloud/latest/user-guide/microsoft-teams-chats)
* [Messages](https://docs.uipath.com/marketplace/automation-cloud/latest/user-guide/microsoft-teams-messages)
* [Teams](https://docs.uipath.com/marketplace/automation-cloud/latest/user-guide/microsoft-teams-teams)
