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,22 @@
|
||||
import fetchApi from "@moduletrace/twui/utils/fetch/fetchApi";
|
||||
import type { APIResponseObject } from "@moduletrace/bunext/types";
|
||||
import type { BotQuestionAnswer, BotQuestionView } from "@/src/types";
|
||||
|
||||
type Params = {
|
||||
question_id: number;
|
||||
/**
|
||||
* One per question; none skips them.
|
||||
*/
|
||||
answers?: BotQuestionAnswer[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Answers questions a bot asked from their card, or skips them, returning
|
||||
* the questions as they now stand.
|
||||
*/
|
||||
export default async function decideBotQuestion({ question_id, answers }: Params) {
|
||||
return await fetchApi<{ question_id: number; answers?: BotQuestionAnswer[] }, APIResponseObject<BotQuestionView>>(
|
||||
`/api/admin/bot-questions/${answers ? "answer" : "skip"}-question`,
|
||||
{ method: "POST", body: answers ? { question_id, answers } : { question_id } },
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user