Objective
|
Create a simple bot using Visual Studio 2017.
|
Audience
|
Dot Net developer
|
Tools
|
Visual Studio 2017, Bot Emulator
|
Open visual studio 2017
Click on File > New > Project
Select “Bot Application”
Name the project “SampleBot”
Note: If you do not find “Bot Application” project template.
1] Download it from here : http://aka.ms/bf-bc-vstemplate
2] Unzip to : %USERPROFILE%\Documents\Visual Studio 2017\Templates\ProjectTemplates\Visual C#\
Once the project is created from Visual Studio, update the NuGet packages by Right Click on Solution > Manage NuGet Packages for Solution..
Under the Updates tab, update the NuGet packages.
Run the application by pressing F5.
This will open a browser.
You will get a screen indicating message to register a bot, however we are running bot locally. To test its functionality we need to open an url like : http://localhost:3979/api/messages.
However if we open this URL we will get like this:
To communicate with Bot we need to have Bot Emulator, please download and install it from link : https://github.com/Microsoft/BotFramework-Emulator/releases/tag/v3.5.33
You will get Bot emulator installed.
Open the emulator.
Enter the URL as : http://localhost:3979/api/messages and click on simply connect. [Please keep in mind that our Bot Visual Studio Project is still in execution state]
Now we are connected to BOT.
At the end of the screen type a sample message to test the output.
We get the expected output.
The logic is written in the file “RootDialog.cs” as shown in image.
Here you can write further things to handle complex logic as per business requirement. We will cover that in next session.
No comments:
Post a Comment