Edit

Share via

Invoke Dialog in Bot with Adaptive Card

Register Microsoft Entra app

The following steps help you to create and register your bot in Azure portal:

  • Create and register your Azure app.
  • Create client secret to enable SSO authentication of the bot.
  • Add Teams channel to deploy the bot.
  • Create a tunnel to your web server's endpoints using dev tunnel (recommended) or ngrok.
  • Add messaging endpoint to the dev tunnel that you created.

Add App registration

  1. Go to Azure portal.

  2. Select App registrations.

    Screenshot shows the Azure services to select App registrations.

  3. Select + New registration.

    Screenshot shows the New registration page on Microsoft Entra admin center.

  4. Enter the name of your app.

  5. Select Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant).

  6. Select Register.

    Screenshot shows the option to register the bot in Microsoft Entra admin center.

    Your app is registered in Microsoft Entra ID. The app overview page appears.

    Screenshot shows the app registration overview page.

    Note

    Save the app ID from Application (client) ID and Directory (tenant) ID for further use.

Create a tunnel

  1. Open Visual Studio.

  2. Select Create a new project.

    Screenshot shows the selection to create a new project.

  3. In the search box, enter ASP.NET. From the search results, select ASP.NET Core Web App.

  4. Select Next.

    Screenshot shows the search and selection of the template.

  5. Enter Project name and select Next.

    Screenshot shows the project name to enter.

  6. Select Create.

    Screenshot shows the project additional information.

    An overview window appears.

    Screenshot shows the overview window.

  7. In the debug dropdown list, select Dev Tunnels (no active tunnel) > Create a Tunnel....

    Screenshot shows the dropdown to select the dev tunnels.

    A pop-up window appears.

  8. Update the following details in the pop-up window:

    1. Account: Enter a Microsoft or GitHub account.
    2. Name: Enter a name for your tunnel.
    3. Tunnel Type: From the dropdown list, select Temporary.
    4. Access: From the dropdown list, select Public.
  9. Select OK.

    Screenshot shows the details to update for creation of tunnel.

    A pop-up window appears showing that dev tunnel is successfully created.

  10. Select OK.

    Screenshot shows the pop-up message that the tunnel is created.

    You can find the tunnel you've created in the debug dropdown list as follows:

    Screenshot shows the tunnel is active and selected.

  11. Select F5 to run the application in the debug mode.

  12. If a Security Warning dialog appears, select Yes.

    Screenshot shows the dialog box to accept the security warning.

    A pop-up window appears.

  13. Select Continue.

    Screenshot shows the url for the tunnel.

    The dev tunnel home page opens in a new browser window and the dev tunnel is now active.

    Screenshot shows the dev tunnel welcome page in browser.

  14. Go to Visual Studio, select View > Output.

  15. From the Output console dropdown menu, select Dev Tunnels.

    The Output console shows the dev tunnel URL.

    Screenshot shows the url in the Visual Studio output console.

Add a web authentication

  1. In the left pane, under Manage, select Authentication.

  2. Select Add a platform > Web.

    Screenshot shows the selection of web authentication.

  3. Enter the redirect URI for your app by appending auth-end to the fully qualified domain name. For example, https://your-devtunnel-domain/auth-end or https://your-ngrok-domain/auth-end.

  4. Under Implicit grant and hybrid flows, select the Access tokens and ID tokens checkboxes.

  5. Select Configure.

    Screenshot shows the option to add redirect uri and select implicit grant and hybrid flows.

  6. Under Web, select Add URI.

  7. Enter https://token.botframework.com/.auth/web/redirect.

  8. Select Save.

    Screenshot shows the option to add redirect uri and select implicit grant and hybrid flows.

Create a client secret

  1. In the left pane, under Manage, select Certificates & secrets.

  2. Under Client secrets, select + New client secret.

    Screenshot show the selection of new client secret.

    The Add a client secret window appears.

  3. Enter Description.

  4. Select Add.

    Screenshot show the client secret description option to add.

  5. Under Value, select Copy to clipboard to save the client secret value for further use.

    Screenshot show the option to copy the client secret ID value to copy value to clipboard.

Add API permission

  1. In the left pane, under Manage, select API permissions.

  2. Select + Add a permission.

    Screenshot show the option to select Add permission.

  3. Select Microsoft Graph.

  4. Select Delegated permissions.

  5. Select the following permissions:

    • OpenId permissions > email, offline_access, openid, profile.
    • User > User.Read.
  6. Select Add permissions.

    Screenshot show the option to select permissions.

    Note

    • If an app isn't granted IT admin consent, users must provide consent the first time they use an app.
    • Users need to consent to the API permissions only if the Microsoft Entra app is registered in a different tenant.

Add Application ID URI

  1. In the left pane, under Manage, select Expose an API.

  2. Next to Application ID URI, select Add.

    Screenshot shows the option to add Application ID URI.

  3. Update the Application ID URI in the api://your-devtunnel-domain/botid-{AppID} or api://your-ngrok-domain/botid-{AppID} format and select Save.

    Screenshot shows the option to add redirect uri and save.

    The following image shows the domain name:

    Screenshot shows the redirect uri.

Add a scope

  1. In the left pane, under Manage, select Expose an API.

  2. Select + Add a scope.

    Screenshot shows the selection to Add a Scope.

  3. Enter access_as_user as the Scope name.

  4. Under Who can consent?, select Admins and users.

  5. Update the values for the rest of the fields as follows:

    • Enter Teams can access the user’s profile as Admin consent display name.

    • Enter Allows Teams to call the app’s web APIs as the current user as Admin consent description.

    • Enter Teams can access the user profile and make requests on the user’s behalf as User consent display name.

    • Enter Enable Teams to call this app’s APIs with the same rights as the user as User consent description.

  6. Ensure that State is set to Enabled.

  7. Select Add scope.

    The following image shows the fields and the values:

    Screenshot shows the values filled in the field to Add a scope.

    Note

    The Scope name must match with the Application ID URI with /access_as_user appended at the end.

    Screenshot shows the details in Scopes.

Add client application

  1. In the left pane, under Manage, select Expose an API.

    Under Authorized client applications, identify the applications that you want to authorize for your app’s web application.

  2. Select + Add a client application.

    Screenshot shows the option to Select client application.

  3. Add Teams mobile or desktop and Teams web application.

    1. For Teams mobile or desktop: Enter the Client ID as 1fec8e78-bce4-4aaf-ab1b-5451cc387264.

      Screenshot shows the mobile or desktop Client ID application.

    2. For Teams web: Enter the Client ID as 5e3ce6c0-2b1f-4285-8d4b-75ee78787346.

      Screenshot shows the web Client ID application.

  4. Select the Authorized scopes checkbox.

  5. Select Add application.

    Screenshot shows the option to select authorized scopes and add application.

    The following image displays the Client Id:

    Screenshot shows the output of Client applications.