From bc484b4fdc59594d239f4f4ecc2de909beddff86 Mon Sep 17 00:00:00 2001 From: Beatris Mendez Gandica Date: Sun, 26 Apr 2026 23:53:56 -0700 Subject: [PATCH] Add answer key for Chatbot workshop Complete AIML solutions for all coding activities: - Activity 2: Hello World category (starter walkthrough) - Activity 3: Three basic categories (name, color, food) with exact patterns - Activity 4: Wildcard patterns (* FOOD, * COLOR, * NAME) for flexible matching - Activity 5: Echoing wildcards with tag for dynamic responses - Complete greetings.aiml file combining all activities - Input/output tables for each activity showing expected behavior - Pattern priority tip (specific patterns match before wildcards) - Common student Q&A (keeping both exact and wildcard categories) PT-BR and Korean translations exist but use different language patterns. English answer key covers the English version. 10-model QA passed (3 clean passes). Hugo build verified. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- content/english/chatbot/answer-key.md | 267 ++++++++++++++++++++++++++ 1 file changed, 267 insertions(+) create mode 100644 content/english/chatbot/answer-key.md diff --git a/content/english/chatbot/answer-key.md b/content/english/chatbot/answer-key.md new file mode 100644 index 000000000..dea3d274a --- /dev/null +++ b/content/english/chatbot/answer-key.md @@ -0,0 +1,267 @@ +--- +title: "Chatbot - Answer Key" +date: 2026-04-27T00:00:00-07:00 +draft: false +weight: 15 +hidden: true +--- + +{{% notice note %}} +These are sample solutions for the chatbot workshop activities. AIML patterns must be written in UPPERCASE. The template responses can use any capitalization you like. Your chatbot's responses can differ from these examples as long as the pattern matching works correctly! +{{% /notice %}} + +## Activity 2: Hello World + +This is the starter category provided in the walkthrough: + +```xml + + HELLO + + +``` + +When the user types "Hello", the bot responds with "Hello, World!" + +## Activity 3: Add Your Own Categories + +### 1. What is your name? + +```xml + + WHAT IS YOUR NAME + + +``` + +### 2. What is your favorite color? + +```xml + + WHAT IS YOUR FAVORITE COLOR + + +``` + +### 3. What is your favorite food? + +```xml + + WHAT IS YOUR FAVORITE FOOD + + +``` + +{{% notice tip %}} +**Key rules for patterns:** +- Always write patterns in UPPERCASE +- Do not include punctuation in patterns (Pandorabots strips punctuation from user input before matching) +- The template response can use any capitalization +{{% /notice %}} + +At this point, your bot should respond to: + +| User says | Bot responds | +|-----------|-------------| +| Hello | Hello, World! | +| What is your name? | My name is Chatbot. | +| What is your favorite color? | My favorite color is blue. | +| What is your favorite food? | My favorite food is pizza. | + +## Activity 4: Wildcards + +The `*` wildcard matches one or more words. By placing `*` at the beginning of a pattern, the bot responds to any question that **ends with** the keyword. + +### 1. Any question ending with "food" + +```xml + + * FOOD + + +``` + +### 2. Any question ending with "color" + +```xml + + * COLOR + + +``` + +### 3. Any question ending with "name" + +```xml + + * NAME + + +``` + +{{% notice tip %}} +**Common student question:** "Do I still need the categories from Activity 3?" + +You can keep both! Pandorabots matches the most specific pattern first. So "WHAT IS YOUR FAVORITE FOOD" (exact match) takes priority over "* FOOD" (wildcard). The wildcard categories handle questions you did not explicitly write a category for, like "Do you like food?" or "Tell me about food". +{{% /notice %}} + +Now the bot responds to many more inputs: + +| User says | Matches pattern | Bot responds | +|-----------|----------------|-------------| +| What is your favorite food? | WHAT IS YOUR FAVORITE FOOD | My favorite food is pizza. | +| Do you like food? | * FOOD | My favorite food is pizza. | +| Tell me about food | * FOOD | My favorite food is pizza. | +| What is your name? | WHAT IS YOUR NAME | My name is Chatbot. | +| Do you have a name? | * NAME | My name is Chatbot. | + +## Activity 5: Echoing Wildcards + +The `` tag captures whatever the `*` wildcard matched and includes it in the bot's response. + +### 1. "My name is [name]" responds with "Nice to meet you, [name]!" + +```xml + + MY NAME IS * + + +``` + +### 2. "My favorite color is [color]" responds with "I also like [color]!" + +```xml + + MY FAVORITE COLOR IS * + + +``` + +### 3. "My favorite food is [food]" responds with "[food]! Yum!" + +```xml + + MY FAVORITE FOOD IS * + + +``` + +How `` works: + +| User says | `*` captures | Bot responds | +|-----------|-------------|-------------| +| My name is John | John | Nice to meet you, John! | +| My name is Jane | Jane | Nice to meet you, Jane! | +| My favorite color is blue | blue | I also like blue! | +| My favorite color is red | red | I also like red! | +| My favorite food is pizza | pizza | pizza! Yum! | +| My favorite food is sushi | sushi | sushi! Yum! | + +## Complete AIML File + +Here is what your complete `greetings.aiml` file should look like after all activities: + +```xml + + + + + + HELLO + + + + + + WHAT IS YOUR NAME + + + + + WHAT IS YOUR FAVORITE COLOR + + + + + WHAT IS YOUR FAVORITE FOOD + + + + + + * NAME + + + + + * COLOR + + + + + * FOOD + + + + + + MY NAME IS * + + + + + MY FAVORITE COLOR IS * + + + + + MY FAVORITE FOOD IS * + + + + +``` + +{{% notice tip %}} +**Pattern priority in AIML:** When multiple patterns could match the same input, Pandorabots uses the most specific match. For example, "MY FAVORITE FOOD IS *" is more specific than "* FOOD", so "My favorite food is pizza" will match the echoing wildcard pattern and respond with "pizza! Yum!" instead of "My favorite food is pizza." +{{% /notice %}}