Chatbot Conversation Architecture · Chapter 3 · 12 min
Menus, slots and context
When to offer buttons, how to fill slots out of order, and carrying context across turns.
The role of menus and slots
Free-text interaction is powerful but inherently unpredictable and prone to common user errors. Quick replies or button-based menus, when supported by the communication channel, force user input into defined events. For less capable channels like standard SMS, you can achieve a similar effect by offering numbered options for the user to select. Always prioritize menus at critical decision points to ensure the conversation stays on the intended path. This combination of guided and open input makes your bot both flexible and reliable for all users.
Sophisticated users will often provide multiple pieces of information at once, such as "Book a table for four tomorrow at 8". Instead of a rigid, step-by-step sequence, your system should use a slot-filling design that extracts all provided data simultaneously. The state machine then focuses on identifying which required slots are still empty, prompting the user only for those specific missing pieces of information. This leads to a much more natural and efficient user experience that respects the user's time.
−if (state === "askDate") { date = text; state = "askTime"; }−else if (state === "askTime") { time = text; state = "askSize"; }−else if (state === "askSize") { size = text; state = "confirm"; }
Implementing the extractor
function extractSlots(text: string) {
const slots: Record<string, string> = {};
const dateMatch = text.match(/tomorrow|today|on \d{2}-\d{2}/i);
if (dateMatch) slots.date = dateMatch[0];
const partyMatch = text.match(/for (\d+)/);
if (partyMatch) slots.partySize = partyMatch[1];
return slots;
}Managing context windows
Maintaining a short, relevant history of recent turns and current slot values is essential for natural dialogue. This context allows your system to handle complex requests, such as "actually make it five people," by referencing the current session state. You must be careful to bound the size of this context data, as unlimited history makes system behaviour impossible to reason about and unnecessarily expensive to store. Effective context management is the key to creating bots that feel truly intelligent and responsive.
Storing context efficiently requires a strategy that prioritizes the most recent and relevant information. You should avoid cluttering your context store with data that is no longer needed for the current task. By regularly pruning old information, you ensure that your bot's reasoning remains sharp and focused on the user's immediate needs. This approach also helps to keep your session storage lightweight and fast, which is critical for maintaining high performance.
Designing the user journey
As your bot grows, managing context becomes about more than just data; it's about understanding the user's journey. Use context to personalize greetings or remember preferences across different sessions if privacy policies allow. Just ensure that your context management remains efficient and that you always clear data when a conversation ends. By personalizing the experience, you increase user engagement and build a stronger connection between the user and your brand.
Ultimately, menus and slots are tools to guide users toward their goals effectively. When you combine them correctly, you create an experience that feels effortless for the user. Focus on minimizing the number of turns required to complete a task, and always provide clear paths for the user to follow. A well-designed user journey is the most important product of your conversational engineering efforts, ensuring long-term success for your bot.
Discussion (3)
Clear and opinionated. One nit: worth mentioning clock skew between producer and consumer when choosing the tolerance window.
Good point — we're adding a short section on this in the next revision.
The callout about alerting on queue age instead of depth changed how we page people. Thank you.