# Microsoft (MS) Teams (Azure Bot)

MS Teams Azure bot Service provides an integrated development environment for bot building. Its integration with Power Virtual Agents, a fully hosted low-code platform, enables developers of all technical abilities to build conversational AI bots—no code needed.

At the end of this document you will learn how to setup a new Microsoft Teams bot.

In order to setup MS Teams Azure bot, you need to follow the steps below:

## Create an Azure App (Azure Bot)

**NOTE:** The Azure Bot can be created on either Aisera's OR on the customer's Azure portal.

* **Aisera Azure Portal:** Aisera has always access to change settings, i.e. messaging endpoint, make branding changes, create new secrets, check for errors, etc.
* **Customer's Azure Portal:** Any change needs to be done on the customer's end.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FJhDsYbDMgyHzkRvnrQSO%2Fbot1.png?alt=media&#x26;token=b7eeed5a-96ee-4ecf-b6c8-eb3e54e1f49b" alt=""><figcaption><p>Aisera Architecture with MS Teams</p></figcaption></figure></div>

1. Login on [https://portal.azure.com](https://portal.azure.com/)
2. Click on **All Resources**.
3. Choose **Create Resources**.
4. Select **Azure Bot** from the drop down menu.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FidgdSdJVfrAouyaoGvJr%2Fbot2.png?alt=media&#x26;token=d4260b48-1361-40a5-aa3f-188a8023b4e2" alt="" width="477"><figcaption><p>Create the Azure Bot</p></figcaption></figure></div>

5\. Set values for the following deployment parameters:

* **Bot Handle:** `<customerName><Environment><bot>`
* **Subscription:** (select one)
* **Resource group:** (create one with the same name as Bot handle)
* **New Resource group Location:** West US
* **Type of App:** Single Tenant (Multi Tenant is no longer supported by Microsoft. Now you can only choose Single Tenant or User-Assigned Managed Identity.)
* Create a new Microsoft App ID

**NOTE:** Make sure you create a **new Microsoft App ID**, instead of using an existing app registration.

6. Click the **Create** button.

**NOTE:** Please wait for 2-5 minutes until the deployment is complete.

Your deployment is complete when you see the following window:

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FpnwVCrkqAwg6uajYtjiB%2Fbot4.png?alt=media&#x26;token=9ae45a13-f116-4485-ae06-d18ff34926af" alt="" width="399"><figcaption><p>Deployment Complete Verification</p></figcaption></figure></div>

Continue on to set up resources for the bot.

7. Click on **Go to Resource**.
8. Select **Channels**.
9. Choose **Microsoft Teams**.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FVQWwclUw9yjp54GKe5FS%2Fbot5.png?alt=media&#x26;token=235b563b-5fc2-4d39-abb1-96cc3c7e0aa8" alt="" width="551"><figcaption><p>Choosing MS Teams Channel</p></figcaption></figure></div>

10\. Select the **MS Teams Workspace** where you want to deploy the application/bot. \
The **Commercial** Workspace is commonly chosen.

**NOTE:** For Government organizations, select **Microsoft Team Government**. The configuration is the same for both of these workspaces.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2F6vjUEjUTVsVFZ0WqgO4y%2Fbot6.png?alt=media&#x26;token=8f57a658-81f5-46f0-ad72-7be60b07d98d" alt="" width="479"><figcaption><p>Choose an MS Teams Workspace</p></figcaption></figure></div>

11\. Navigate to the **Bot Profile** wndow to set the required values:

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FjAS3mX0154Nlf5OmNPex%2Fbot7.png?alt=media&#x26;token=619f9451-9b5a-48ce-a9d4-557722f089b5" alt="" width="563"><figcaption><p>Set the Bot Profile Parameters</p></figcaption></figure></div>

* **Icon:** upload the color icon (png, square, max 30K, 192x192px).
* **Display Name:** Set Bot-Name.
* **Description:** optional.

12\. Navigate to the **Configuration** window and set the values for:

* **Messaging endpoint:** Use your Aisera tenant url as the MS Teams Messaging endpoint. \
  \
  Example with tenant url as Messaging endpoint: `https://<tenant-url>/teams/receive`.\
  \
  **Vanity URL**\
  \
  You can use a vanity url such as `https://<chatbot.tenant-url>/teams/receive`. \
  In this example, the 'vanity' or custom url is created by adding your bot name as a sub-domain at the  beginning of the url.\
  \
  Example vanity endpoint with bot name as sub-domain: `https://chatbot.acme.aisera.cloud/teams/receive`<br>
* **Microsoft App ID:** Copy this ID, we will use it later.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2F4seNJcIjynmGJvijyl0m%2Fbot8.png?alt=media&#x26;token=338cb386-c694-4869-82ee-018a08a00646" alt="" width="563"><figcaption><p>Aisera Bot Configuration Window</p></figcaption></figure></div>

13\. Navigate to the **Manage** window and get a new Client Secret.

14\. Delete an existing secret.

15 Create a new Client Secret and copy it (we will use it later).

16\. Set the **Expiration** to `24 months`.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FIrOAYvpO28DKv9AZSzyN%2Fbot9.png?alt=media&#x26;token=9d7ed027-e9a6-4d94-a74e-077753801bf9" alt="" width="563"><figcaption><p>Add a Client Secret</p></figcaption></figure></div>

### **Create the Manifest**

In order to use an app/bot in MS Teams, you need to upload a manifest.zip bundle in a Team workspace.\
Create a .zip archive of the following file:

```
{
  "$schema": "https://developer.microsoft.com/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
  "manifestVersion": "1.16",
  "version": "1.0.0",
  "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  "packageName": "com.package.name",
  "name": {
    "short": "Name of your app (<=30 chars)",
    "full": "Full name of app, if longer than 30 characters (<=100 chars)"
  },
  "developer": {
    "name": "Aisera Inc",
    "mpnId": "6234286",
    "websiteUrl": "https://www.aisera.com",
    "privacyUrl": "https://www.aisera.com/privacy",
    "termsOfUseUrl": "https://www.aisera.com/termsofuse"
  },
  "description": {
    "short": "Aisera automates complex and standard IT requests and HR tasks.",
    "full": "Aisera automates complex and standard IT requests and HR tasks, directly in Microsoft Teams, so you can work more efficiently using chat. With Aisera GPT you can resolve automatically routine actions via chat, and find answers for frequently asked questions."
  },
  "icons": {
    "outline": "outline.png",
    "color": "color.png"
  },
  "accentColor": "#FFFFFF",
  "staticTabs": [
    {
      "entityId": "conversations",
      "scopes": [
        "personal"
      ]
    },
    {
      "entityId": "about",
      "scopes": [
        "personal"
      ]
    }
  ],
  "bots": [
    {
      "botId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "scopes": [
        "personal",
        "team",
        "groupchat"
      ],
      "isNotificationOnly": false,
      "supportsCalling": false,
      "supportsVideo": false,
      "supportsFiles": true
    }
  ],
  "validDomains": []
}
```

Ask your Aisera Team for 2 Aisera logos to add to the manifest.zip:

* Color.png → Logo 192x192px, full-color icon.
* Outline.png → Logo 32x32px, transparent.

A useful guide for how to design the icon can be found here:

<https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/build-and-test/apps-package#icons>

#### **Edit/Create the manifest.json**

The manifest contains basic configuration of an app.

**Important:** Modify the following fields:

* **id:** Use the "Microsoft App Id".
* **bots > botId:** Use the "Microsoft App Id".
* **name > short:** Display name (by convention: Aisera App (\<cluster>)
* **name > full:** Display name (by convention: Aisera App (\<cluster>).
* **description > short:** You may add a description. \* In case we don't want to display the \<cluster> in 'Display Name', please add the cluster it is running on here.
* **description > full:** You may add a description. \* in case we don't want to display the \<cluster> in 'Display Name', please add the cluster running on here.

It's a best practice to use an existing manifest file for a faster approach.&#x20;

Example manifest.json file:&#x20;

```
{
  "$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.14/MicrosoftTeams.schema.json",
  "version": "1.0.0",
  "manifestVersion": "1.22",
  "id": "8c928e46-6cec-4254-ae2a-19724450eb14",
  "packageName": "com.package.name",
  "name": {
    "short": "New Virtual Agent",
    "full": "My New Virtual Agent"
  },
  "developer": {
    "name": "Aisera Inc",
    "mpnId": "",
    "websiteUrl": "https://www.aisera.com",
    "privacyUrl": "https://www.aisera.com/privacy",
    "termsOfUseUrl": "https://www.aisera.com/termsofuse"
  },
  "description": {
    "short": "My New Virtual Agent automates complex and standard IT requests and HR tasks.",
    "full": "This Virtual Agent automates complex and standard IT requests and HR tasks, directly in Microsoft Teams, so you can work more efficiently using chat."
  },
  "icons": {
    "outline": "outline.png",
    "color": "color.png"
  },
  "accentColor": "#FFFFFF",
  "staticTabs": [
    {
      "entityId": "conversations",
      "scopes": [
        "personal"
      ]
    },
    {
      "entityId": "about",
      "scopes": [
        "personal"
      ]
    }
  ],
  "bots": [
    {
      "botId": "8c928e46-6cec-4254-ae2a-19724450eb14",
      "scopes": [
        "personal",
        "team",
        "groupchat"
      ],
      "isNotificationOnly": false,
      "supportsCalling": false,
      "supportsVideo": false,
      "supportsFiles": true
    }
  ],
  "validDomains": []
}

```

### **Create a channel in Admin UI and add it to the Aisera app**

Use the following steps to create an MS Teams channel for your bot.

1. Create a new MS Teams channel.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FtvOhLrtnSFsbdPcP25L1%2Fbot12.png?alt=media&#x26;token=07baf55e-fb62-44d8-99dd-e87e21dd980a" alt="" width="386"><figcaption><p>Create an MS Teams Channel</p></figcaption></figure></div>

2. Set values for the required parameters:

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FdvNYwOhNwWef3NxfOOYi%2Fms_teams2b.png?alt=media&#x26;token=1cfe65be-ff3d-46e3-bf47-2e75d0ff40dd" alt="" width="563"><figcaption></figcaption></figure></div>

* **Name**
* **Microsoft App ID** (from Creating Azure App section)
* **Microsoft App Client Secret** (from Creating Azure App section)\
  **Important:** makes sure you use the **Secret Value** , NOT the **Secret ID.**

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FKzCYzOvd84l5ainr1DjU%2Fbot14.png?alt=media&#x26;token=837b85e1-d4e4-4f23-818f-f7a46b7be3de" alt=""><figcaption><p>Use the Secret Value</p></figcaption></figure>

* **Team Tenant ID** (get the Tenant ID from the Teams workspace as shown below)
  * Navigate to **Teams** in the main navigation menu.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FRnKpyQB52ZELInYEatuz%2Fbot15.png?alt=media&#x26;token=8d5a02c8-fbd7-4c4a-87c5-7e1b16968d04" alt="" width="297"><figcaption><p>Navigate to Teams</p></figcaption></figure></div>

* Select **Get link to team**

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FuPE2Aa87C1UTjBwJNLvA%2Fbot16.png?alt=media&#x26;token=869d7864-740d-40c2-8963-322d17cd6eda" alt="" width="419"><figcaption><p>Get link to team</p></figcaption></figure></div>

* Copy the link after `tenantId=`

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FNFQQnbPHPZ7OI28Vrl3H%2Fbot17.png?alt=media&#x26;token=71ef6693-a9eb-46aa-b792-272fb7eac53b" alt="" width="563"><figcaption></figcaption></figure></div>

3. IMPORTANT: Select the **Is Single Tenant Bot?** checkbox. MS Teams no longer supports Multi-Tenant Bots.
4. Click **OK** and add the channel to the appropriate app in the Aisera Admin UI.

#### **Upload the Manifest file on MS Teams**

Please use one of the following two options:

* Upload through Teams Admin Center OR
* Upload through Microsoft Teams client

**Upload through Teams Admin Center**

1. Log in to[ https://admin.teams.microsoft.com/](https://admin.teams.microsoft.com/) . You will need an account with the required permission to add the app to a workspace.
2. Navigate to **Teams apps > Manage Apps** and click on **+ Upload new app** and upload the manifest.zip file.

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FxmyRAwaUUKHfeyip5LVz%2Fbot18.png?alt=media&#x26;token=fc089026-a8e8-4e2a-8839-ba0741248c86" alt=""><figcaption><p>Manage apps</p></figcaption></figure>

**Upload through Microsoft Teams client**

1. Log in to your company Microsoft teams app. You will need to have permissions to add a custom app.
2. Select **Apps** on the left vertical menu and then select **Manage your apps.**

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FpoosHbbevqmzP3SiFueP%2Fbot19.png?alt=media&#x26;token=5f3aac12-fe5a-4172-8458-1d5392ef8f04" alt="" width="563"><figcaption><p>Choose Manage your apps</p></figcaption></figure></div>

3. Click on the “Upload an app”, choose “Upload an app to your org’s app catalog” and upload the manifest.zip

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FHX1b7BiRxX9dTmMXz9do%2Fbot20.png?alt=media&#x26;token=acc1c356-7375-4d3d-9b84-9f59120da1e1" alt="" width="563"><figcaption><p>Upload an appp</p></figcaption></figure></div>

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FUjAOuhV9TCnabmIcr8yJ%2Fbot21.png?alt=media&#x26;token=beb8f6b3-3572-44dc-988f-f5c4467be11e" alt="" width="563"><figcaption><p>Upload an app to a catalog</p></figcaption></figure></div>

4. Find the **Virtual Agent** app in the Microsoft Teams client.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FuRvoR8N6HMUfwMlauZk2%2Fbot22.png?alt=media&#x26;token=868ac0fe-2a26-4555-9adc-d98b4dc181c2" alt="" width="563"><figcaption><p>Virtual Agent</p></figcaption></figure></div>

5. Click **Add to a team**.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FbrMgWUJy2BQQKzDDIojM%2Fbot23.png?alt=media&#x26;token=cf6eb93f-c522-4c34-afc2-74a0ee14d40c" alt="" width="563"><figcaption><p>Add the bot to a team</p></figcaption></figure></div>

6. Select a channel and click on **Set up a bot**.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FcVr7v3vTSA505gxIfAnP%2Fbot24.png?alt=media&#x26;token=4c13b23d-b74f-44a1-a5b8-e89cf83ec169" alt="" width="563"><figcaption></figcaption></figure></div>
