New Fresh deep-dives on cloud, AI, mobile & web now publish on blog.msdevbuild.com Read the latest → Install the app
Azure

Bot Framework Composer: Prompt for user input

By   Wednesday, February 19, 2020 comments
reads
React:
The Bot Framework Composer is a fantastic tool for creating/developing Microsoft bots, as it gives you the ability to sketch out and compose the whole simple and complex Bot applications within a visual interface instead of writing actual code. Composer to create the bot solution’s code and run it immediately to test it in the emulator and deploy it to Azure using the CLI. Bot developers should check out the Composer awesome tool, as this will make your Bot development even easier in terms of building smart and engaging bots with ease.

A conversation between a bot and a user often involves asking the user, for information and parsing the user's response. Bot should track the context of a conversation, so that it can manage the behavior and remember answers to previous questions. Bot Framework composer has provided different question format, in this article we are going to see how we can use the Text, Number and Datetime input from users and How we can retrieve state information from Bot state.



Prerequisites

  • Read my previous article to build and setup the bot framework Composer development environment.
  • Read, How to create Multiple Dynamic Greeting message using Bot Framework ComposerCreate New Bot Application
On the Bot Framework Composer homepage, click on New. Select Create from scratch. Click on Next. Give your bot a name. Once created, you should be able to see the following screen


Asking Questions to user

Bot Framework Composer makes it easier to collect information to the user and composer provided feature for validation and a variety of data types as follows
  1. Text Input
  2. Number Input
  3. Confirmation
  4. Multiple Choice
  5. File or attachment
  6. Date or time
  7. OAuth Login



In this article, You are going to learn more about Text, Number and Date/Time Input format and how bot can ask questions to the users. 

Composer Input Control Property – Bot Ask

  • Ask question Input dialog has 3 category options - Bot Asks, User Input and other.
  • Prompt Property -Create your custom message for Bot will send a message to the user .
  • Max turn Count – Maximum number of re- prompt attempts to collect information from user
  • Default Value - Expression to examine on each turn of the conversation as possible value to the property.
  • Allow interruptions - A boolean expression that determines whether the parent should be allowed to interrupt the input.


User Input

User Input tab options have “Property to Fill”. It’s a Property to store collected information. Input will be skipped if the property has value (unless 'Always prompt' is true). Example(user.name), user.name property can access anywhere you want to display or store. While displaying you need to use @{user.name} format.


Bot Text Input Question

The Greeting conversation activity screen, you can click on the “+” button and select the Ask question options and click on Text input .

Step 1: Add “Bot Asks” prompt of text in the text box, which you Bot required to ask questions to the user and the type of value will allow only as text .

Step 2: If you want to save user input and display somewhere else or store into the database, you can select “user Input” section and add the variable property as - user.name.

Bot Number Input Format

Bot can ask users to enter any number value using number input. To prompt a user for a number, click the + button in your screen, mouse over Ask a Question and Select the Number input.
In this following example 
  • Bot asking users to enter the no of years’ experience and provided max turn count as 1 and provided default value as 2.
  • Suppose users enter any text or any invalid character at one time, Bot will take as default value as 2.
  • In user Input options Bot will save the value “user.exp” property, it will be helpful for retrive somewhere else.


Bot Date Time Input Format

Bot Date Time Input format control which is returned as a Timex.
  • You can add the “Bot Ask” question to the Prompt text box
  • Create Property for store the datetime value, here property as “user.date”.
  • after asking for a date, the bot returns a Timex into “user.date” like below
[{

"value": "2020-02-01",

"timex": "2020-02-01"

}]

Because it's a json array with one item. So you can access the components like user.date[0].timex (or) user.date[0].value

Confirmation Message

We have asked 3 different questions to the user; now let us show confirmation message to the user with whichever user responded to the bot. You can compose messages like below 


Hello @{user.name} , You have @{user.exp} years’ experience and please join our company on @{user.date[0].value}




Test Bot Application

Next, click on “Test in Emulator” after that browser will ask you permission to open the bot emulator, once you confirmed the message, Bot emulator will open and automatically navigate to your Bot service. You can start responding to the message to the bot.

Summary

You have successfully created and run the “Ask Question bot” using Bot framework composer. I hope you have enjoyed learning. If you have any questions/feedback/issues, please write them in the comment box.
SJ
Suthahar Jegatheesan

Cloud, AI & Mobile Solutions Architect · 18+ years across Azure, Google Cloud and Firebase, C#, Python, .NET MAUI and Flutter. Author of the Xamarin Q&A Book.

More in this series

1 comment:

sponsored

What Colleagues Say

“Suthahar is one of the most thorough and knowledgeable cloud architects I’ve worked with. His depth on Azure and ability to make complex mobile solutions work cross-platform is remarkable. He always delivers beyond expectations.”

AT Arun T. Senior Engineering Manager · Direct Manager

“I’ve followed Suthahar’s MSDEVBUILD blog for years — practical, deep, always current. Working alongside him confirmed what I suspected: he’s as sharp in person as on paper, and a genuinely generous mentor and architect.”

RK Rajesh K. Lead Developer · Mindtree

Certifications & Recognition

AZ-300 · Azure Architect Technologies AZ-301 · Azure Architect Design AZ-104 · Azure Administrator Associate AI-100 · Designing Azure AI Solutions DP-900 · Azure Data Fundamentals MCPD · Windows Phone Certified SAFe® 4 Scrum Master

Technical Expertise

☁ Cloud Platforms Microsoft Azure — Expert · 18 yrs App Services · AKS · Functions · Cosmos DB · APIM · Entra ID AWS & Google Cloud — Advanced
πŸ€– AI & Automation Azure OpenAI / GenAI — Advanced · 5 yrs RAG Pipelines · Bot Framework · Cognitive Services · Vision & Speech AI · ML.NET
πŸ“± Mobile Architecture .NET MAUI & Xamarin — Expert · 12 yrs Flutter · Native iOS/Android · Offline-First · Secure Storage & Auth
πŸ”’ Identity & Security Microsoft Entra ID — Expert OAuth 2.0 · OIDC · Zero Trust · Conditional Access · RBAC · Key Vault

Speaking & Community

Microsoft User Group Malaysia Recurring speaker on Azure architecture, AI integration and .NET mobile development across Malaysia and APAC.
Global Azure Bootcamp — Chennai Presented “AI into Xamarin Mobile Apps” at GAB Chennai, part of the worldwide Global Azure community event.
AI & Azure OpenAI Community Events Workshops and live demos on RAG pipelines, AI agents and intelligent workflow automation since 2023.
Mobile & Cloud Workshops — Coimbatore Multi-day deep-dive sessions at GRG Computer Technology, KG Microsoft Innovation Center and RVS College of Arts and Science.
500+Blog Articles
50+Conference Talks
10K+Monthly Readers
30Public Repositories
3Continents Delivered
New home

MSDEVBUILD now publishes on blog.msdevbuild.com

Every new article lands there first — cloud and Azure, AI and GitHub Copilot, .NET MAUI and Flutter, web and Firebase. It installs as an app, opens like a native one and keeps working offline.

MSDEVBUILD Assistant Ask about Suthahar, Azure, AI or mentorship
Hi! I’m a simple FAQ bot for MSDEVBUILD. Tap a question below or type your own.