Branch: master
Find file History
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
DeploymentScripts/MsbotClone echo sample name changes for csharp .net core and webapi (#964) Nov 25, 2018
Properties echo sample name changes for csharp .net core and webapi (#964) Nov 25, 2018
Scripts echo sample name changes for csharp .net core and webapi (#964) Nov 25, 2018
wwwroot echo sample name changes for csharp .net core and webapi (#964) Nov 25, 2018
CounterState.cs echo sample name changes for csharp .net core and webapi (#964) Nov 25, 2018
EchoBotAccessors.cs echo sample name changes for csharp .net core and webapi (#964) Nov 25, 2018
EchoBotWithCounter.csproj Update all relevant samples to 4.2.2 Packages Feb 12, 2019
EchoBotWithCounter.ruleset echo sample name changes for csharp .net core and webapi (#964) Nov 25, 2018
EchoWithCounterBot.cs Remove "Obsolete" State accessors Feb 12, 2019
Program.cs echo sample name changes for csharp .net core and webapi (#964) Nov 25, 2018
README.md Fixes: 969, 970, 971 Various Sample READMEs use v3 content instead of… Nov 27, 2018
Startup.cs Remove "Obsolete" State accessors Feb 12, 2019
appsettings.json
echo-with-counter.bot echo sample name changes for csharp .net core and webapi (#964) Nov 25, 2018

README.md

This sample demonstrates a simple echo bot with state with ASP.Net Core 2. The bot maintains a simple counter that increases with each message from the user.

To try this sample

  • Clone the samples repository
git clone https://github.com/Microsoft/botbuilder-samples.git
  • [Optional] Update the appsettings.json file under botbuilder-samples/samples/csharp_dotnetcore/02.b.echo-with-counter with your botFileSecret. For Azure Bot Service bots, you can find the botFileSecret under application settings.

Running Locally

Visual Studio

  • Navigate to the samples folder (botbuilder-samples/samples/csharp_dotnetcore/02.b.echo-with-counter) and open EchoBotWithCounter.csproj in Visual Studio.
  • Run the project (press F5 key).

.NET Core CLI

  • Install the .NET Core CLI tools.
  • Using the command line, navigate to botbuilder-samples/samples/csharp_dotnetcore/02.b.echo-with-counter folder.
  • Type dotnet run.

Testing the bot using Bot Framework Emulator

Microsoft Bot Framework Emulator is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel.

  • Install the Bot Framework emulator from here.

Connect to bot using Bot Framework Emulator V4

  • Launch the Bot Framework Emulator.
  • File -> Open bot and navigate to botbuilder-samples/samples/csharp_dotnetcore/02.b.echo-with-counter folder.
  • Select echo-with-counter.bot file.

Bot state

A key to good bot design is to track the context of a conversation, so that your bot remembers things like the answers to previous questions. Depending on what your bot is used for, you may even need to keep track of conversation state or store user related information for longer than the lifetime of one given conversation.

In this example, the bot's state is used to track number of messages.

A bot's state is information it remembers in order to respond appropriately to incoming messages. The Bot Builder SDK provides classes for storing and retrieving state data as an object associated with a user or a conversation.

- Conversation properties help your bot keep track of the current conversation the bot is having with the user. If your bot needs to complete a sequence of steps or switch between conversation topics, you can use conversation properties to manage steps in a sequence or track the current topic. Since conversation properties reflect the state of the current conversation, you typically clear them at the end of a session, when the bot receives an end of conversation activity.

- User properties can be used for many purposes, such as determining where the user's prior conversation left off or simply greeting a returning user by name. If you store a user's preferences, you can use that information to customize the conversation the next time you chat. For example, you might alert the user to a news article about a topic that interests her, or alert a user when an appointment becomes available. You should clear them if the bot receives a delete user data activity.

Deploy this bot to Azure

You can use the MSBot Bot Builder CLI tool to clone and configure any services this sample depends on. In order to install this and other tools, you can read Installing CLI Tools.

To clone this bot, run

msbot clone services -f deploymentScripts/msbotClone -n <BOT-NAME> -l <Azure-location> --subscriptionId <Azure-subscription-id> --appId <YOUR APP ID> --appSecret <YOUR APP SECRET PASSWORD>

NOTE: You can obtain your appId and appSecret at the Microsoft's Application Registration Portal

Further reading