How to create a sample Bot application, test it with the bot emulator and then publish it in Azure

I am trying the Microsoft BOT Framework and here you can find my first experiences.

First I followed the instructions available in Create a bot with the Bot Builder SDK for .NET and in the following you can find some notes and screenshots that could help to understand, if needed, the steps explained in that quick start, and then make the sample bot run bot on the bot emulator and  then deployed in Azure.

First of all, to have your VS have the templates related to the Bot, copy the Bot Application, Bot Controller, and Bot Dialog .zip files to your Visual Studio 2017 project templates directory located in %USERPROFILE%\Documents\Visual Studio 2017\Templates\ProjectTemplates\Visual C#\

Insert the templates in the proper VS directory

 

You will then find a specific selectable Bot Application template when you will create a new project.

Boot Application template

Boot Application template

To test with the botframework-emulator, download it, install it and run it. Set the endpoint of the BOT (e.g. http://localhost:3979/api/messages ) where the base URL can be taken both from the URL of the browser page opened when you run the bot project with Visual Studio or in the project properties: remember to add to that string the /api/messages to let the endpoint be defined properly!

From VS, run the BOT in a browser (e.g. Edge)

From VS, run the BOT in a browser (e.g. Edge)

Page displayed when you run the BOT: it shows the port used and remember you that the endpoint to be set must be of a specific type (https and end with /api/messages)

Page displayed when you run the BOT: it shows the port number used and remember you that the endpoint to be set must be of a specific type (https and end with /api/messages)

Properties of the project that shows the URL with the used port number

Properties of the project that shows the URL with the used port number

For this time, because the bot is not registered yet, in the emulator you have to leave blank the Microsoft App ID and Microsoft App Password fields: you will have to set them only after you register your bot in the MyBot section of the Bot Framework portal.

Bot emulator with the endpoint properly set as previously described

Bot emulator with the endpoint properly set as previously described

Clicking on the CONNECT  button  (and having the bot project running in Visual Studio), you can send messages to that bot and have it answers to you, as designed in his code.

Dialogue with the bot, using the emulator

Dialogue with the bot, using the emulator

Now, if you want to register and run that sample BOT  in Azure, you have publish it: this will give you the site URL that you will have to change in https when you register this bot in the Bot Framework portal (as clearly stated in the suggestion of the Messaging endpoint input field when you register it).

Build -> Publish projectName

Build -> Publish projectName

Set API Name, Resource Group and App Service plan and click the Create button

Set API Name, Resource Group and App Service plan and click the Create button

In the Summary you can find the base URL to be used as endpoint

Register the new bot in the dev.botframework.com portal clicking the Create a bot button

Click the Register button

Click the Register button

Set the mandatory fields and note the suggestion about the Messaging endpoint (it must be https)

Specify the <em>Messaging endpoint</em> using the <em>https</em>, the <em>base URL</em> and then the path <em>/api/messages</em>

Specify the Messaging endpoint using the https, the base URL and then the path /api/messages

In the apps.dev.microsoft.com portal, generate the AppID and the app password (ion the bot registration form only APP ID is needed while both must be set in the code of the Bot)

Take note of the generated password

Set the App ID in the bot registration page

Register the bot

Register the bot

Bot created

Bot created

The bot is already associated to two channels but you can add more

The bot is already associated to two channels but you can add more

In the My bots page the new bot is listed

In the My bots page the new bot is listed

Open the Web.config file ot the bot project and search for the appSetting keys MicrosoftAppId and MicrosoftAppPassword

Set MicrosoftAppId and MicrosoftAppPassword keys with the proper values given when you generate an App ID and password associated to your Microsoft Account

Set MicrosoftAppId and MicrosoftAppPassword keys with the proper values given when you generate an App ID and password associated to your Microsoft Account

Update the code and re-publish it (1)

Update the code and re-publish it (1)

Update the code and re-publish it (2)

Update the code and re-publish it (2)

You can test the new bot directly from the Bot Framework portal

You can test the new bot directly from the Bot Framework portal

If you now want to test/debug that bot from the emulator, you have to define in it also the App ID and password

If you now want to test/debug that bot from the emulator, you have to define in it also the App ID and password

The dialogue with the bot works again even after the setting of App ID and password ...

The dialogue with the bot works again even after the setting of its App ID and password

In the Azure Dashboard you can see the new Bot

In the Azure Dashboard you can see the new Bot

Azure Dashboard – all resources

 

_____________________________________

Now, for sure you want to delete all the resources associated to that just created sample bot! You need  to manage in the following places:

You can select the bot and then delete it if you don't need anymore

You can select the bot and then delete it if you don’t need anymore

Copy&past the bot name in the proper input field to let the deletion be done

Copy & past the bot name in the proper input field to let the deletion be done

Also in apps.dev.microsoft.com you still have in your app list the just tested bot with the related App ID / Client Id association: you may want to dele also that

Also in apps.dev.microsoft.com you still have in your app list the just tested bot with the related App ID / Client Id association: you may want to dele also that

Delete the sample bot also from the dev.botframework.com portal

Delete the sample bot also from the dev.botframework.com portal

That’s all, for now …

Annunci

Informazioni su Enzo Contini

Electronic engineer
Questa voce è stata pubblicata in Aziendali, Review e test, Windows. Contrassegna il permalink.

Lascia un Commento/Leave a comment

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...