Let bots ask multiple-choice questions before acting
ask_user puts up to six questions on one card (radios for one pick, checkboxes for several, an optional typed Other) as a [question:ID] chip. The user's answers are checked against the questions, stored in bot_questions and sent to the bot as their chat message; Skip says so. Offered in chat replies and user-started tasks, never in routines, hook calls or chatroom sessions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import type { BotQuestionView } from "@/src/types";
|
||||
|
||||
type Params = {
|
||||
view: BotQuestionView;
|
||||
};
|
||||
|
||||
/**
|
||||
* What the chat tells the bot once the user answered (or skipped) its
|
||||
* questions, so it carries on from their answers: each question with the
|
||||
* options picked and anything typed into "Other".
|
||||
*/
|
||||
export default function botQuestionAnswersText({ view }: Params) {
|
||||
if (view.status == "skipped" || !view.answers) {
|
||||
return `I skipped your questions (questions #${view.id}) without answering them.`;
|
||||
}
|
||||
|
||||
const lines = view.questions.map((item, index) => {
|
||||
const answer = view.answers?.[index];
|
||||
const picked = (answer?.choices || []).map((choice) => item.options[choice]).filter(Boolean);
|
||||
const other = answer?.other ? `other: ${answer.other}` : "";
|
||||
|
||||
return `- **${item.question}** ${[...picked, other].filter(Boolean).join("; ")}`;
|
||||
});
|
||||
|
||||
return [`My answers (questions #${view.id}):`, ...lines].join("\n");
|
||||
}
|
||||
Reference in New Issue
Block a user