Home > Software design >  BotBuilder Authentication Multitenant
BotBuilder Authentication Multitenant

Time:05-07

I want to create Microsoft BotBuilder following this tutorial. But it seems SO complicated compared to v3.(BTW: starting a tutorial with 3 authentications that cover 75% of the article is not a good sign)

So I follow the EchoBot sample (I chose MultiTenant because my server is outside AND it seems the most covered):

const credentialsFactory = new BotBuilder.ConfigurationServiceClientCredentialFactory({
    MicrosoftAppId: '***',
    MicrosoftAppPassword: '***',
    MicrosoftAppType: 'MultiTenant',
});

const botFrameworkAuthentication = BotBuilder.createBotFrameworkAuthenticationFromConfiguration(null, credentialsFactory);


const onTurnErrorHandler = async (context, error) => { /* for errors */ }
const adapter = new BotBuilder.CloudAdapter(botFrameworkAuthentication);
adapter.onTurnError = onTurnErrorHandler;

Questions:

  • How do I test everything is working ? isValidAppId() and isAuthenticationDisabled() are the only available method and seems OK.
  • How do I get MicrosoftAppPassword ? According to the documentation I have to click manage, then create a value/secret pair. Should I use value ? or secret ? Why none is named password ? Anyway none works ...

To test if it works, I follow the sample:

  • setup an HTTP POST Endpoint (with Node-RED)
  • declare the endpoint in Azure Portal Bot Configuration
  • go to webchat to test

I correctly receive the Messages then try to do some authentication/parisng (I assume) :

await adapter.process(msg.req, msg.res, (context) => {
    /* do some stuff  */
});

But it fails with a very explicit error :

Error: 1 validation issue(s)

  Issue #0: custom_error at [[root]]
  Response

I think, the errors is related to an authentication issue, since I don't understand what/how to set the password. I guess I have to go through this CloudAdapter in order to get a parsed context and be able to send messages.

CodePudding user response:

To answer second question in your case, kindly go through the link :https://docs.microsoft.com/en-us/azure/bot-service/bot-service-quickstart-registration?view=azure-bot-service-4.0&tabs=multitenant

To answer the first question in your case, kindly check disabling and enabling the authentication to test the app: https://docs.microsoft.com/en-us/azure/bot-service/bot-service-troubleshoot-authentication-problems?view=azure-bot-service-4.0&tabs=csharp

CodePudding user response:

As far as getting the password goes, when you create a new Multi Tenant Azure Bot resource, the app password goes into the Azure Key Vault created alongside it. The AppId and AppPassword are randomly generated by Azure. You can get them from the key vault in the Azure portal in the correct resource group.

If you want to create a resource manually using the CLI and define your own password, you can use this docs page for deploying a bot. Make sure you select the correct tabs. I have pre-selected C# and Multi Tenant in a new resource group for the above link.

Single Tenant is for limiting your bot's connections to Azure resources within the same tenant, and a User Assigned Managed Identity is if you want to make use of an Azure Managed Identity across the bot's resources instead of having a password for each resource.

You should be able to simply add the AppId and AppPassword to the echo bot sample and deploy it.

  • Related