In order to build a Teams app that is a bot you need to register your bot in the Microsoft bot framework and link it to your Aurinko app. If you have any trouble registering bot in the Microsoft bot framework, get in touch with support@aurinko.io and we’d be happy to help you out!

  1. Provision Office 365 / Azure AD app registration for your new Aurinko app. Remember your Azure AD app id and secret, you’ll need them on the next steps.

  2. To create a new bot registration navigate to the bot framework link dev.botframework.com/bots/new

    To link this bot configuration with your Aurinko app make sure to enter the Aurinko endpoint https://api.aurinko.io/push/office/bot/{AurinkoAppId}/chat as the ‘Messaging endpoint’ and the Azure AD app id (from step 1) as the ‘App Id’.

    Then click ‘Register’ button.

  3. Connect your bot to the ‘Microsoft Teams’ channel:

  4. Back in the Aurinko app settings open MS Teams Bot OAuth section and enter your Azure AD app id and secret for ‘Client id’ and ‘Client secret’. Then generate a new universal unique identifier (UUID) for your bot and enter it as ‘Bot id’. Store this bot id as you will use it as your ID in the Teams manifest file.

    Keep ‘External app’ checkbox checked while you’re developing your app and distributing it by uploading the manifest file. Other tenants consider this app ‘External’ if it’s installed from the manifest file. Uncheck the box and update the bot id after you’ve published your app to the Office store and it has become listed in the store catalogue.

    Image Placeholder

    Note: MS Bot Framework has limitations, bots don’t get notified on channel events and receive only the messages explicitly addressing the bots. The bots can really do just two things: reply to a conversation initiated by a user or initiate a conversation (needs to know user id or channel id first). If your Teams app needs capabilities beyond this you will have to configure your app to request application level permissions.

  5. With this configuration in place Aurinko platform starts receiving events generated by Microsoft bot framework for your bot and automatically provisions a new service account for every installation of your Teams app.

    You’ll see all those service accounts in your Aurinko portal under Accounts:

    Image Placeholder

  6. Use the following API request to retrieve the list of these service accounts:

    curl -u ClientId:Secret -X GET https:/api.aurinko.io/v1/svc\_accounts \
        -G -d serviceType='MsTeamsBot'
    
    {
        "records": [
             {
                "id": 2152,
                "serviceType": "MsTeamsBot",
                "active": true,
                "daemon": true,
                "loginString": "c345743-ecea-47fa-97d4-b4b4b6c70fa52",
                "name": "yoxel.net",
                "authOrgId": "c345743-ecea-47fa-97d4-b4b4b6c70fa52"
            },
            {
                "id": 2262,
                "serviceType": "MsTeamsBot",
                "active": true,
                "daemon": true,
                "loginString": "48f3456a-61d5-4673-8cd2-d24c39ee34f3",
                "name": "team.onmicrosoft.com",
                "authOrgId": "48f3456a-61d5-4673-8cd2-d24c39ee34f3"
            },
            ...
      ],
      "totalSize": 5,
      "offset": 0,
      "done": true
    }
    
  7. Use these accounts to call our unified Chat API. An account id has to be specified in the header X-Aurinko-AccountId:

    curl -u ClientId:Secret  \
        -H 'X-Aurinko-AccountId: 2152' \
        -X POST https:/api.aurinko.io/v1/chat/channels/{id}/messages \
        -d '{ message json payload }'