Upgrade Bot Framework V1 to V3

I built a bot several weeks ago. But when I open and ran the bot emulator today, I saw a notification like this:

upgrade_notification

Then I followed the instruction and installed the new version of bot framework emulator. What happed then was then the bot application didn’t work anymore. When I typed message in the emulator, it just returned an exception.

After visiting Bot Framework offical site, I realized that Microsoft had just released a new version of Bot Framework: V3.

upgrade_officialsite.png

On this page, we can see the majoy change made for V3. But in order to convert our v1 bot to V3 bot, here are some things we need to look at:

  1.  In the new Bot Framework version, “BotBuilder and Connector are now one SDK”. We need to first remove the Bot Connector package reference and update the Microsoft.Bot.Builder package to latest version.
  2. Another big change is that Message object has been replaced by a new object called Activity. So the MessageController will be different. You can download the new Bot Application template from this link to create a V3 Hello World Application and see the new MessageController. NewMessageController
  3. Web.config got some change also. The appsettins used to look like this:oldsetting.pngNow it becomes this:newsetting.pngSo we get a new setting  for Bot ID.
  4. Previously when testing the bot locally, we need to put our AppId and AppSecret in the emulator. oldemulatorsetting.pngNow we don’t need to do this anymore. Just keep them empty like this:newemulator.pngOtherwise, you will get internal exception when typing a message.

There are other code change you may need to make when converting to V3 bot.

For example, my bot is using :

context.PerUserInConversationData.SetValue(“SomeState”, 0);

To save/access conversation state. Now I should use this instead:

context.ConversationData.SetValue(“SomeState”, 0);

Please check the Bot Framework offical documentation.They all have been updated for V3.

 

 

 

Leave a comment