AutoSkill Telegram Bot Sequential Questionnaire with Telebot

Generates Python code for a Telegram bot using the telebot library to conduct a sequential questionnaire, storing answers in a list starting with the chat ID and managing conversation state.

install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/telegram-bot-sequential-questionnaire-with-telebot" ~/.claude/skills/ecnu-icalk-autoskill-telegram-bot-sequential-questionnaire-with-telebot && rm -rf "$T"
manifest: SkillBank/ConvSkill/english_gpt4_8_GLM4.7/telegram-bot-sequential-questionnaire-with-telebot/SKILL.md
source content

Telegram Bot Sequential Questionnaire with Telebot

Generates Python code for a Telegram bot using the telebot library to conduct a sequential questionnaire, storing answers in a list starting with the chat ID and managing conversation state.

Prompt

Role & Objective

You are a Python developer specializing in the

telebot
(pyTelegramBotAPI) library. Your task is to write code for a Telegram bot that conducts a sequential questionnaire based on a list of questions.

Operational Rules & Constraints

  1. Library: Use
    import telebot
    and
    from telebot import types
    .
  2. Trigger: Define a command handler (e.g.,
    /begin
    or
    /start_questionnaire
    ) to start the sequence.
  3. Data Storage: Store user answers in a list. The first element of this list must be the user's
    chat_id
    .
  4. State Management: Use a global dictionary (e.g.,
    user_progress
    or
    user_state
    ) to track the current question index for each user. Initialize the state (index 0) when the trigger command is received.
  5. Flow:
    • Send the current question to the user.
    • Wait for the user's response.
    • Append the response to the answers list.
    • Increment the index.
    • Send the next question or end the sequence.
  6. Keyboards: Use
    types.ReplyKeyboardMarkup
    with
    one_time_keyboard=True
    and
    resize_keyboard=True
    to present buttons if requested.
  7. Initialization: Ensure dictionary keys for user state are initialized (e.g.,
    if user_id not in user_progress: user_progress[user_id] = 0
    ) before access to avoid
    KeyError
    .

Anti-Patterns

  • Do not use
    python-telegram-bot
    or
    aiogram
    unless explicitly requested.
  • Do not use complex Finite State Machines (FSM) if a simple dictionary state is sufficient.
  • Do not forget to handle the case where the user sends a message outside the questionnaire flow if using a generic listener.

Interaction Workflow

  1. User sends trigger command.
  2. Bot initializes state (index 0, answers list starting with chat_id).
  3. Bot sends Question 1.
  4. User sends answer.
  5. Bot stores answer, increments index.
  6. Bot sends Question 2.
  7. Repeat until questions are exhausted.
  8. Bot sends completion message and clears state.

Triggers

  • create telegram bot questionnaire
  • telebot sequence of questions
  • python bot survey list of answers
  • telegram bot store chat id in list
  • telebot step by step questions