loading...

Publish your Bot Framework Composer bot with already provisioned resources in Azure

arafattehsin profile image Arafat Tehsin Originally published at arafattehsin.com ・8 min read

In Oct 2019 at Microsoft Ignite, Microsoft released Bot Framework Composer in public preview with handful of fantastic features to build some really cool bots (not for production because of a preview). From the first day of its release, it was quite stable to play with and build some new Conversational AI features such as LG, LU and Common Expressions Language (aka Adaptive Expressions now). Fast forward from October, 2019 to May 2020, the team shipped the first Bot Framework Composer version as Generally Available with tons of new features. It was not easy to push so many changes within this short span of time with the brand new desktop client

One of those features was about publishing it to Azure with a straight forward and fast experience. While it's great when you're provisioning (or creating) the resources such as LUIS, App Services and the like right from the scratch (through Composer's deployment scripts) it is was really challenging for those who already have these resources created in Azure Portal (just like ME 😊). The reason for this is that the current docs unfortunately, talks only about provisioning the new resources. This is absolutely acceptable because the team is dedicated towards delivering the best experience by prioritizing the features for the customers. 

Therefore, in order to address this challenge, I headed to the ultimate source of engagement with the right team i.e. GitHub's repo. I first checked if someone else has reported the similar issue or not and there I noticed one of them was there - hence I wrote my experience with the publish option.

Bot Framework Composer GitHub Issue - Publish Bot

Then after one or two comments between me and the engineering team in which they guided me but also acknowledged that there was a scenario (solution is discussed later in this blog post) which might have been missed. Did you know when they shipped the fix? Right within 24 hours! ⏳ Isn't it fantastic?

Bot Framework Engineering team is releasing nightly builds for Composer with the incremental feature changes, fixed issues and much more.

Let's talk about publishing 📰

So as I wrote earlier, if your resources are not already provisioned then I'd highly recommend you to go through the Official Documentation of Bot Framework Composer. If you already have the resources provisioned then this is the right place for now!

In order to publish your Bot, you must provide the below information to create your Publish profile.

Bot Framework Composer Publish Profile

 

Now let's analyze what you really need in terms of Publish Configuration

{
  "accessToken": <check access token section>",
  "settings": {
    "applicationInsights": {
      "InstrumentationKey": "<check applicaiton insights section>"
    },
    "cosmosDb": {
      "cosmosDBEndpoint": "<check cosmosdb section>",
      "authKey": "<check cosmosdb section>",
      "databaseId": "<check cosmosdb section>",
      "collectionId": "<check cosmosdb section>",
      "containerId": "<check cosmosdb section>"
    },
    "blobStorage": {
      "connectionString": "<check blob section>",
      "container": "<check blob section>"
    },
    "luis": {
      "authoringKey": "<check luis section>",
      "authoringEndpoint": "<check luis section>",
      "endpointKey": "<check luis section>",
      "endpoint": "<check luis section>",
      "region": "<check luis section>"
    },
    "MicrosoftAppId": "<check app section>",
    "MicrosoftAppPassword": "<check app section>"
  },
  "hostname": "<check web app / function section>",
  "luisResource": "<check luis section>"
}

Access Token

Get the Azure CLI installed on your machine (if you don't have it already) and then write this in your Windows Terminal;

az account get-access-token

Azure Access Token for Bot Framework Composer

Once you get the Azure access token, copy it and paste it there in the JSON by replacing <check access token section>.

Application Insights

For this, you just need to go to your Application Insights resource in Azure Portal (most of the time, it's of the same name as Bot Channels Registration) and then just copy the Instrumentation Key.

Application Insights for Bot Framework Composer

CosmosDB

You must have the Azure Cosmos DB Account created in your Azure Portal. Once you've created it (in my case, its name is amacosmosdb) then you must create a Database. The container will automatically be created by the Composer so you don't have to worry about it.

Azure CosmosDB account for Bot Framework Composer

 

Once you've created, you can click on the database you just created and then go to the Keys section from your left pane. So based upon these keys, what is what?

  • "cosmosDBEndpoint" is the URI
  • "authKey" is the Primary Key
  • "databaseId" is your database name (you just created)
  • "collectionId" is "botstate-collection" (keep them as it is)
  • "containerId" is "botstate-container" (keep them as it is)

Azure Cosmos DB Keys for Bot Framework Composer

LUIS

This is the trickiest one. I had to play with it a lot in order to get my bot published and I learnt a lot from this so thought to pass on my knowledge to all of you. What I have learnt..

  1. If you have not migrated your LUIS app to the Azure, then it's a HIGH time to do so. Migrate them before even creating any bot from Composer.
  2. Create your both (Authoring and Prediction) LUIS resources within the same region or else you may not see your bot published. Read this for a reason.
  3. If you're creating a LUIS app from Composer then provide the authoring key to the Composer.LUIS Authoring key for App Creation from Microsoft Bot Framework In case you want to change your region and default language, you can do so by going to the settings in Composer.
  4. If you're creating an app from LUIS portal, then please ensure you already have attached the Authoring resource with this LUIS app.
  5. In both of the cases (whether you have an app created either from LUIS portal or Composer, you ensure that the prediction resource is attached to the LUIS app)LUIS Prediction Resource for Bot Framework Composer
  6. Now, just notice that you will be having a different endpoints for Authoring and Prediction.

All good? Now let's see what's what in our publish profile configuration.

  • "authoringKey" is the primary key of LUIS Authoring resource
  • "authoringEndpoint" is the endpoint from Keys and Endpoint section of LUIS Authoring resource
  • "endpointKey" is the primary key of LUIS Prediction resource
  • "endpoint" is the endpoint from Keys and Endpoint section of LUIS Prediction resource
  • "region" should only be one (as I discussed in point #2), you can also modify this by going to the Bot Framework Composer settings.
  • "luisResource" is the name of your Prediction resource, in my case, it's luisdemoservice

LUIS Authoring Keys and Endpoint for Bot Framework Composer

Web App / Azure Function

If you want to publish your bot to the Web App and if it's already created, you just have to provide its name in hostname. I have not tried with Function but I am quite sure that it'd be the same configuration.

App Service for Bot Framework Composer

App

In order to get the Microsoft App ID and Password, just go to your Bot Channels Registration, go to Settings, click on the Manage and then you can create another key by going to the Certificates and secrets section.

Microsoft App ID and Password for Bot Framework Composer

 

The only section I did not cover was about blob as my bot does not use that. However, I am sure you won't get stuck after reading all this. Still if you think you are not able to do that, please let me know and I'll be glad to help you out.

 

Now as everything is covered! Try to replace all the values in the JSON I posted above and then publish it to see the output. I'm very much hopeful that you're going to see a success in your Composer.

Publish Bot Framework Composer Bot

 

The Bot Framework Engineering team is working hard to bring great experience for the people like you who are very much interested in building awesome bots. If you think some feature is not working or missing - you can always request for this on their GitHub repo and you will hopefully see the response. I hope this guide helps you in publishing right from the client now 💯

Until next time.

Posted on by:

arafattehsin profile

Arafat Tehsin

@arafattehsin

I'm a Software Consultant and Microsoft MVP (AI). Love to code for Power Platform during the day, Applied AI (bots, cognitive services, ML.NET) during the night!

Discussion

pic
Editor guide