Skip to content

EricDahlvang/MultiTurnPromptBot-SyncId

Repository files navigation

multi-turn prompt (with sync id)

Sample copied from https://github.com/Microsoft/botbuilder-samples.git and modified to include a synchronization id on messages sent to and from the bot.

Users sometimes send multiple messages in quick succession. If the bot has already processed and replied to a specific message, successive messages intended as reponses to the same bot message should be ignored.

This is an interesting problem. No doubt there are different ways to solve it. One method for WebChat/DirectLine could be to track the last message sent from the bot using a generated id. On the WebChat side, ensure messages sent to the bot include that same id. When the bot receives messages, ensure only one per conversation is processed at a time. And finally, ignore those which do not contain the expected id.

This bot has been created using Bot Framework, it shows how to use the prompts classes included in botbuilder-dialogs. This bot will ask for the user's name and age, then store the responses. It demonstrates a multi-turn dialog flow using a text prompt, a number prompt, and state accessors to store and retrieve values.

Prerequisites

  • Bot Channels Registration This is required in order to obtain a MicrosoftAppId and MicrosoftAppPassword, as well as a DirectLineSecret, for appsettings.json

  • .NET Core SDK version 2.1

    # determine dotnet version
    dotnet --version

To try this sample

  • Clone the repository

    git clone https://github.com/EricDahlvang/MultiTurnPromptBot-SyncId.git
  • Add required settings to appsettings.json MicrosoftAppId MicrosoftAppPassword DirectLineSecret

  • In a terminal, navigate to MultiTurnPromptBot-SyncId

  • Run the bot from a terminal or from Visual Studio, choose option A or B.

    A) From a terminal

    # run the bot
    dotnet run

    B) Or from Visual Studio

    • Launch Visual Studio
    • File -> Open -> Project/Solution
    • Navigate to samples/csharp_dotnetcore/05.multi-turn-prompt folder
    • Select MultiTurnPromptBot.csproj file
    • Press F5 to run the project

Testing the bot using Bot Framework Emulator

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 version 4.3.0 or greater from here

Connect to the bot using Bot Framework Emulator

  • Launch Bot Framework Emulator
  • File -> Open Bot
  • Enter a Bot URL of http://localhost:3978/api/messages

Prompts

A conversation between a bot and a user often involves asking (prompting) the user for information, parsing the user's response, and then acting on that information. This sample demonstrates how to prompt users for information using the different prompt types included in the botbuilder-dialogs library and supported by the SDK.

The botbuilder-dialogs library includes a variety of pre-built prompt classes, including text, number, and datetime types. This sample demonstrates using a text prompt to collect the user's name, then using a number prompt to collect an age.

Deploy the bot to Azure

To learn more about deploying a bot to Azure, see Deploy your bot to Azure for a complete list of deployment instructions.

Further reading

About

Copied from https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/05.multi-turn-prompt and modified to demonstrate how a bot can be made to ignore superfluous messages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published