# Microsoft Teams: Deploy an Endpoint

**Cognigy Support**  
October 24, 2022

Within our **Cognigy.AI** platform you're able to connect your Cognigy.AI Flows to **Microsoft Teams** by using our Microsoft Teams Endpoint integration.

**Microsoft Teams Deployment Options**  
This Endpoint is used to deploy a virtual agent to a Microsoft teams channel that answers when it is **mentioned by a user in a post**. To deploy a **direct messaging bot** that can be contacted via direct chat, please use the [Azure Bot Services Endpoint](https://support.cognigy.com/hc/en-us/articles/360016183720).

## Description  
This tutorial covers the necessary steps for creating and connecting a Microsoft Teams Endpoint to Microsoft Teams. If you want to get information about assigning a Flow to the Endpoint and setting up the Data Management see [Endpoints](https://docs.cognigy.com/docs/endpoints).

## Setup Process  
1. Create a **Microsoft Teams Endpoint** in Cognigy.AI  
2. Integrate the **Microsoft Teams Endpoint** with your **Microsoft Teams** team  
3. Send messages to your Teams Bot

### 1. Create a Microsoft Teams Endpoint  
**Location:** Cognigy.AI  
Firstly, you must create an Endpoint of the type _Microsoft Teams_ (see **Figure 1.1**). To do this, navigate to the _Endpoints_ menu, found under _Deploy_ in the resources panel on the left side of the Cogngiy.AI UI. Select _"+ New Endpoint"_, give the endpoint a name and select _Microsoft Teams_ from the available options.

_Figure 1.1: Creating a Microsoft Teams Endpoint_

After creating your Endpoint, you should be navigated to the Endpoint configuration of your Microsoft Teams Endpoint. Here you need to set the Flow that the Endpoint should point to.

_Figure 1.2: A Created Microsoft Teams Endpoint_

Now that you have created the Microsoft Teams Endpoint, all that is left to do is to connect it to Microsoft Teams. The Microsoft Teams Endpoint contains `Microsoft Teams Settings` which is one setting we need in order to connect to your Microsoft Teams team. The setting is:  
- A security token

The next chapter will describe where you can find this setting in Microsoft Teams.

### 2. Integrate the Microsoft Teams Endpoint with Microsoft Teams  
**Location:** [Microsoft Teams Platform](https://teams.microsoft.com)

**Requirements**  
✔ Endpoint URL

In order to connect your Microsoft Teams Endpoint to Microsoft Teams, you have to create a Webhook in `Microsoft Teams` so that all messages that mention your bot is sent to your Cognigy.AI Flow. Do this by opening the menu next to the Microsoft Team where you wish to add the bot, and click on `Manage team`.

_Figure 2.1a: Navigating to the Webhooks page._

You now need to navigate to the `Apps` tab in your team overview. This will give you a list of all apps that are currently installed in your team, as well as the option to create new ones. We need to create a new outgoing Webhook for our bot, which you can do by clicking the `Create an outgoing webhook` button in the lower right corner.

**Button to create Webhook is missing**  
In case you cannot see the `Create an outgoing webhook` button in the lower right corner, then you have to follow this guide here: [Outgoing Webhooks](https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/outgoingwebhook). The guide covers how to setup your Office 365 tenant to allow for uploading Webhooks.

_Figure 2.1b: Team apps_

_Figure 2.1c: Creating a Webhook_

When creating the Webhook, you first need to give the Webhook a name. This will be the name of your Bot. You thereafter need to copy the EndpointURL of your Microsoft Teams Endpoint which will be used as the Webhook URL. You can find the EndpointURL in your Microsoft Teams Endpoint in the Cognigy.AI User Interface.

You can then give your Webhook a description and upload an optional image for your Bot. When finished, click on `Create` to create the Webhook. This will open a popup containing a security token. Copy this token and paste it into the `Microsoft Teams Settings` tab in the Endpoint configuration in the Cognigy.AI User Interface. If you lose the security token, then you have to create a new Webhook.

_Figure 2.1d: Getting the security token_

_Figure 2.1e: Configuring the Endpoint with the security token_

You are now finished connecting your Endpoint with your Microsoft Teams! Go into a channel in your team and mention your bot to talk to it.

**Mentioning the bot**  
You always have to mention the bot, e.g. @Bot, when saying something to it. Otherwise the message will not be sent to your Flow.

_2.1.f: Sending a message to the bot_

### 3. Sending Messages to a Teams Bot  
You can have your bot reply **simple text messages** by just adding text to the Default tab of a [Say](https://docs.cognigy.com/docs/say-nodes) Node or you can reply with **structured content**, called [Cards](https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/cards/cards) in Teams.

_Card in Microsoft Teams_

You can simply enter the Teams Card JSON into the Microsoft Teams tab on a [Say](https://docs.cognigy.com/docs/say-nodes) Node.

**Card Reference**  
Microsoft offers a large number of Card examples on the [Teams Card Reference Page](https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/cards/cards-reference).

The JSON for the example card above is shown below.

Teams Card Sample  
```
{
  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.hero",
      "content": {
        "title": "Seattle Center Monorail",
        "subtitle": "Seattle Center Monorail",
        "text": "The Seattle Center Monorail is an elevated train line between Seattle Center (near the Space Needle) and downtown Seattle. It was built for the 1962 World's Fair. Its original two trains, completed in 1961, are still in service.",
        "images": [
          {
            "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/49/Seattle_monorail01_2008-02-25.jpg/1024px-Seattle_monorail01_2008-02-25.jpg"
          }
        ],
        "buttons": [
          {
            "type": "openUrl",
            "title": "Official website",
            "value": "https://www.seattlemonorail.com"
          },
          {
            "type": "messageBack",
            "title": "My MessageBack button",
            "displayText": "I clicked this button",
            "text": "User just clicked the MessageBack button",
            "value": "{\"property\": \"propertyValue\" }"
          }
        ]
      }
    }
  ]
}
```

**Postbacks are unsupported on the Microsoft Teams Endpoint**  
If your card includes postback functionality (e.g. messageBack), then this is not supported in the Microsoft Teams endpoint. To get this functionality, you can use the [Azure Bot Services](https://support.cognigy.com/hc/en-us/articles/360016183720-Azure-Bot-Services-Deploy-an-Endpoint#description-0-0) endpoint together with Microsoft Teams instead.

### Endpoints & Channels  
- [Azure Bot Services: Advanced Deployment with SSO (Microsoft Teams): SSO and Graph API Nodes](https://support.cognigy.com/hc/en-us/articles/6422300559388-Azure-Bot-Services-Advanced-Deployment-with-SSO-Microsoft-Teams-SSO-and-Graph-API-Nodes)  
- [Azure Bot Services: Advanced Deployment with SSO (Microsoft Teams): Apps Developer Portal](https://support.cognigy.com/hc/en-us/articles/6422298661404-Azure-Bot-Services-Advanced-Deployment-with-SSO-Microsoft-Teams-Apps-Developer-Portal)  
- [Azure Bot Services: Advanced Deployment with SSO (Microsoft Teams): Azure Portal](https://support.cognigy.com/hc/en-us/articles/6422296629404-Azure-Bot-Services-Advanced-Deployment-with-SSO-Microsoft-Teams-Azure-Portal)  
- [Azure Bot Services: Advanced Deployment with SSO (Microsoft Teams): Azure Active Directory Portal](https://support.cognigy.com/hc/en-us/articles/6422293904540-Azure-Bot-Services-Advanced-Deployment-with-SSO-Microsoft-Teams-Azure-Active-Directory-Portal)  
- [Azure Bot Services: Advanced Deployment with SSO (Microsoft Teams): Intro](https://support.cognigy.com/hc/en-us/articles/6417377133596-Azure-Bot-Services-Advanced-Deployment-with-SSO-Microsoft-Teams-Intro)  
- [Amazon Connect: Intro](https://support.cognigy.com/hc/en-us/articles/6229662732444-Amazon-Connect-Intro)  
- [Amazon Connect: Setup Amazon Connect](https://support.cognigy.com/hc/en-us/articles/6229664156060-Amazon-Connect-Setup-Amazon-Connect)  
- [Amazon Connect: Control Amazon Connect from Cognigy.AI](https://support.cognigy.com/hc/en-us/articles/6229683335196-Amazon-Connect-Control-Amazon-Connect-from-Cognigy-AI)  
- [Amazon Connect: Enable SSML replies from Cognigy.AI](https://support.cognigy.com/hc/en-us/articles/6229684421916-Amazon-Connect-Enable-SSML-replies-from-Cognigy-AI)  
- [Amazon Lex: Setup AWS Lambda (Amazon Lex NLU)](https://support.cognigy.com/hc/en-us/articles/6229644597020-Amazon-Lex-Setup-AWS-Lambda-Amazon-Lex-NLU)
