View Categories

AI ChatBot – AI Conversations in Scratch

💬 AI ChatBot – AI Conversations in Scratch #

The AI ChatBot extension brings AI conversations into Scratch with support for both OpenAI and Gemini.
Create intelligent chatbots, build interactive storytelling projects, get coding help, generate creative content, and make AI-powered assistants – all with simple blocks that connect to AI providers.
Perfect for students, educators, and creators exploring AI.


🌟 Overview #

  • Real AI Conversations: Ask questions and get intelligent responses from OpenAI or Gemini.
  • Multiple Providers: Choose between OpenAI and Gemini with provider-specific API keys and model lists.
  • Customizable Personas: Set assistant names, roles (teacher, storyteller, robot, etc.), and custom personalities.
  • Context Memory: AI ChatBot remembers the conversation history for natural, flowing interactions.
  • Fine-Tune Responses: Control answer length, creativity level, timeout, and response style.
  • Easy Setup: Add an API key for the provider you want to use and start chatting!

✨ Key Features #

  • Access to OpenAI and Gemini chat models.
  • Automatic language detection – replies in the user’s language.
  • 6 preset persona roles: helper, robot, teacher, storyteller, kid, talking cat.
  • Custom persona text for unique character personalities.
  • Conversation memory – remembers your last 10 questions and answers for natural conversations.
  • Adjustable answer length (max tokens) and creativity (temperature).
  • Provider-aware model listing – discover and use models for OpenAI or Gemini.
  • Built-in safety checking – automatically blocks inappropriate content for kids.
  • Safe, brief, and kid-friendly default settings.
  • Smart error prevention – keeps provider keys, models, and conversation state organized.

🚀 How to Use #

  1. Go to: pishi.ai/play
  2. Open the Extensions section.
  3. Select the AI ChatBot extension.
  4. Get an API Key:
    To use AI ChatBot, you need an API key for the provider you want to use.
    Students: ask a parent or teacher to help you create the account.

  5. set api key for [PROVIDER|rect]: Click this block and choose which provider key to set.
  6. answer to: [MESSAGE|text] using [MODEL]: Use this block to ask the chatbot anything.
  7. Customize (Optional): Set assistant name, role, persona, model, and response settings to create your perfect AI assistant.

Tips

  • Start with the default model for each provider: {openai} gpt-4o-mini for OpenAI and {gemini} gemini-2.5-flash-lite for Gemini.
  • Keep questions clear and specific for better answers.
  • clear message logs: Use this block to start fresh conversations.
  • Experiment with different roles and personas to create unique characters.
  • Monitor your provider usage to avoid unexpected costs.

🧱 Blocks and Functions #

 

💬 Main Interaction #

answer to: [MESSAGE|text] using [MODEL]

Sends a question or message to the selected AI provider and returns the AI’s response as text.
This is the core block for interacting with the AI – ask anything and get intelligent answers!

How it works:

  • Type your question or message in the MESSAGE field.
  • The extension checks your question to make sure it’s kid-friendly.
  • The selected provider and model are used for the reply.
  • The chatbot thinks about your question and creates an answer.
  • The answer is also checked to make sure it’s appropriate for kids.
  • You get the answer as text – you can make your sprite say it, display it, or use it however you want!
  • The conversation is saved automatically (your last 10 questions and answers) so the chatbot can give better responses.

Examples:

  • answer to: [What is 5 + 3?|text] using [{openai} gpt-4o-mini] → AI ChatBot replies: “8”
  • answer to: [Tell me a joke|text] using [{gemini} gemini-2.5-flash-lite] → AI ChatBot tells a short joke
  • answer to: [What fun Scratch project should I make?|text] using [{openai} gpt-4.1-mini] → AI ChatBot suggests a project idea

Note: This block requires a valid API key for the selected provider. If no key is set, it returns a helpful error message.

 

last answer

Returns the most recent answer generated by AI ChatBot without making a new API call.
This is useful when you need to access the previous answer multiple times in your project.

How it works:

  • Returns the text of the last answer from the “answer to:” block.
  • If no answer has been generated yet, it returns an empty string.
  • Does not make any API calls – it’s completely free and instant!
  • The value updates automatically each time you use the “answer to:” block.

Tip: Use this block to avoid unnecessary API calls when you need the same answer in multiple places in your project!

 


🎭 Persona & Role Customization #

set assistant name [NAME|text]

Sets the display name for the AI assistant.
This affects how the AI introduces itself and how it behaves in conversations.

Default: Pishi.ai

 
Examples:

  • set assistant name [Scratch Helper|text]
  • set assistant name [Professor Bot|text]
  • set assistant name [Felix the Cat|text]

Tip: Choose names that match your project’s theme or character!

 

act as [ROLE]

Sets the AI’s persona role from a menu of predefined options.
Each role changes how the AI communicates and responds.

Available Roles:

  • helper – Friendly assistant (default)
  • robot – Playful robot character
  • teacher – Patient Scratch teacher
  • storyteller – Creative story creator
  • kid – Friendly kid-like speech
  • talking-cat – Fun cat character from a Scratch project

Examples:

  • act as [teacher] → AI acts like a patient teacher explaining concepts clearly
  • act as [storyteller] → AI creates short, creative stories
  • act as [robot] → AI uses playful robot-like language

 

set persona [PERSONA|text]

Adds custom personality instructions to the AI’s system prompt.
Use this for detailed character customization beyond the preset roles.
Limited to 500 characters for safety and performance.

How it works:

  • Type a brief description of the personality or behavior you want.
  • This text is appended to the system instructions, shaping the AI’s responses.
  • Keep it short and clear – the AI still follows safety rules and brevity guidelines.

Examples:

  • set persona [You are a pirate who loves treasure hunts|text]
  • set persona [You speak in rhymes and riddles|text]
  • set persona [You are enthusiastic about science experiments|text]

Tip: Combine with “set assistant name” and “act as” for rich, unique characters!

 


🤖 Provider and Model Selection #

The model is chosen directly using: answer to: [MESSAGE|text] using [MODEL].
The model dropdown contains both provider and model together, so selecting a model also selects the provider.

Default Models:

  • {openai} gpt-4o-mini – Fast, affordable, great for most OpenAI projects (default for OpenAI)
  • {openai} gpt-4.1-mini – Newer mini OpenAI variant
  • {openai} gpt-4.1-nano – Very fast, minimal OpenAI model
  • {openai} gpt-4o – More powerful OpenAI model for higher quality responses
  • {gemini} gemini-2.5-flash-lite – Fast, affordable, great for most Gemini projects (default for Gemini)
  • {gemini} gemini-2.5-flash – Strong Gemini model for more detailed answers

Note: The list of models shown here can change. When you use the “update [PROVIDER] model list” block, the extension updates the model dropdown with the latest chat-compatible models for that provider.
GPT-5 note: GPT-5 models use some tokens for internal thinking, so the extension automatically gives them extra completion space to help answers finish cleanly.

How to choose:

  • For everyday chatbots and cost-effective projects, use the default model for your provider.
  • For deeper reasoning or more detailed explanations, choose a stronger model.
  • For the latest models and pricing, check the provider documentation.

Note: Each model has different costs per token – monitor your usage to control expenses.

 

update [PROVIDER|rect] model list, filter: [FILTER|text]

Fetches a list of available models from the selected provider and updates the model menu.
Returns a comma-separated list of models (up to 50) that match the filter.

How it works:

  • Queries the provider API for available models.
  • Filters out non-chat models.
  • Optionally filters by a substring (e.g., “gpt-4” or “gemini”).
  • Returns the list as text and updates the model dropdown.

Examples:

  • update [openai|rect] model list, filter: [gpt-4|text] → Lists OpenAI GPT-4 models
  • update [gemini|rect] model list, filter: [flash|text] → Lists Gemini Flash models
  • update [openai|rect] model list, filter: [‌|text] → Lists all available chat models for OpenAI

Tip: Use this block at the start of your project to discover new models as providers release them!

 

last error

Returns the last error message from the AI provider, or an empty string if there is no error.
This is useful for debugging and for showing user-friendly error messages in your project.

Tip: Use this block after an error happens to show a custom message or to detect failed requests.

 


⚙️ Response Configuration #

set max tokens [MAX_TOKENS|text]

Sets the maximum length of AI ChatBot’s responses in tokens.
Tokens are word fragments – roughly 1 token = 0.75 words.

How it works:

  • Higher values = longer, more detailed answers.
  • Lower values = shorter, more concise answers.
  • Range: 1–2048 tokens (the extension keeps it within safe limits automatically).
  • Default: 360 tokens (~270 words) – keeps answers brief and kid-friendly.

Examples:

  • set max tokens [50|text] → Very short answers (1–2 sentences)
  • set max tokens [200|text] → Moderate-length answers (a few sentences)
  • set max tokens [500|text] → Longer, detailed explanations

Tip: Shorter answers are faster, cheaper, and easier for kids to read!

 

answers type: [TYPE]

Controls the creativity and randomness of AI ChatBot’s responses (temperature setting).
Choose from a menu of preset styles or enter a custom value (0–2).

Options:

  • accurate (0) – Focused, consistent, predictable answers
  • normal (1) – Balanced creativity and accuracy (default)
  • creative (2) – More varied, imaginative, surprising responses

Examples:

  • answers type: [accurate] → Good for math, facts, consistent responses
  • answers type: [creative] → Good for storytelling, brainstorming, jokes

 

set timeout [TIMEOUT|text]

Sets the maximum time (in milliseconds) to wait for a response from the selected provider.
If the request takes longer, it will timeout and return an error.
Default: 30000 (30 seconds)

Examples:

  • set timeout [60000|text] → Wait up to 60 seconds
  • set timeout [15000|text] → Wait up to 15 seconds (faster failure for slow connections)

Tip: Longer timeouts are helpful for complex questions or slower internet connections.

 


🗑️ Conversation Management #

clear message logs

Clears the entire conversation history with AI ChatBot.
Use this to start a fresh conversation without context from previous questions.

When to use:

  • Starting a new topic or conversation.
  • When the chatbot seems confused or is talking about old stuff.
  • To give your assistant a “fresh start” for testing or demos.
  • When you’ve had a long conversation (the extension remembers your last 10 questions & answers, then starts forgetting older ones).

Note: Your assistant’s name, role, persona, provider, and selected model stay the same – only the conversation memory is erased.

 


🔑 API Key Setup #

set api key for [PROVIDER|rect]

Opens a prompt to enter or update the API key for the selected provider.
Your key is stored in the browser’s session storage (cleared when you close the tab).

How to use:

  • Click this block.
  • Choose the provider you want to set a key for.
  • A text input prompt appears.
  • Paste your API key and click OK.

Security Notes:

  • API keys are stored temporarily – only while your browser tab is open.
  • Keys are deleted when you close the browser tab.
  • Never share your API key publicly or in shared projects!
  • The extension automatically cleans up your API key – it removes invisible characters that sometimes get copied by accident.
  • Your key must use regular English letters and numbers only. If you paste something weird, you’ll get a friendly error message.
  • If you see an error about “invalid characters,” just copy the key again from the provider dashboard and paste it fresh.

Tip: Generate separate API keys for different projects to track usage and costs separately.

 


🎓 Educational Uses #

  • AI Literacy – Learn how AI models work, how prompts influence responses, and how to use AI responsibly.
  • Creative Learning – Build interactive tutors, storytellers, role-playing characters, and educational chatbots.
  • Language Skills – Practice real conversations in different languages with AI-driven characters.
  • API Understanding – Discover how Scratch connects to external services in a simple, visual way.
  • Physical Computing + AI:
    • Natural-Language Robot Control – Command robots using phrases like “drive in a square” or “wave hello.”
    • AI Decision Making – Combine sensors with the chatbot so the robot decides what to do next.
    • Story-Acting Robots – The chatbot writes scenes and the robot acts them out with motions or LEDs.

🎮 Example Projects #

– On-Screen Projects #

  • Interactive Storyteller – AI ChatBot creates new story chapters based on player choices.
  • AI Quiz Generator – Endless trivia generated instantly during gameplay.
  • Creative Writing Partner – Get characters, worlds, and plot twists in seconds.
  • AI Dungeon Master – A full text-adventure narrator powered by the chatbot.

– Physical Computing + AI ChatBot #

  • AI Robot Assistant – Type or speak commands like “move forward slowly” or “spin like a dancer,” and the robot performs them.
  • Emotion-Aware Robot – The chatbot interprets user messages and the robot reacts with gestures or LED mood colors.
  • Interactive Pet Robot – The chatbot handles personality and dialogue while the robot moves or animates in response.
  • Adventure Robot – The chatbot tells a story and the robot acts out moments with lights or movements.
  • AI Task Translator – High-level commands like “patrol the room” or “draw a square” are converted into step-by-step robot actions.

🧩 Try it yourself: pishi.ai/play

 


🔧 Tips and Troubleshooting #

 

💬 AI ChatBot Specific Tips #

  • “Enter the api key” error? You need to set your API key for the selected provider first – click “set api key for [PROVIDER]” and paste your key from the provider dashboard.
  • “API key contains invalid characters” error? Sometimes when you copy and paste, invisible characters sneak in! The extension checks for these automatically. Just go back to the provider site, copy your key again carefully, and paste it fresh.
  • “Insufficient quota” or billing errors? Your provider account ran out of credits or has a billing issue. Add funds or try a different provider/model.
  • “Let’s talk about coding and creativity instead!” This means your question or the answer was flagged as not kid-friendly. Don’t worry – just ask something about coding, art, games, or stories instead!
  • “The answer was too long. Raise the max tokens and try again.” The chatbot had more to say but ran out of space! Increase the max tokens setting to get longer answers.
  • Slow responses? Try a faster model for the selected provider. Also check your internet connection.
  • Answers too long? Lower the max tokens (try 50–120 for short answers).
  • Answers too short? Increase the max tokens (try 200–500 for detailed responses).
  • AI not following instructions? Try rephrasing your question or clearing message logs to start fresh.
  • Unexpected costs? Monitor usage in your provider dashboard and use smaller models for cost-effective projects.
  • Context confusion? AI ChatBot remembers your last 10 questions and answers. Use “clear message logs” to make it forget and start over.
  • Timeout errors? Increase the timeout value or check your internet connection. Complex questions may take longer.
  • Want more creative answers? Set answers type to “creative” or increase temperature.
  • Want consistent, factual answers? Set answers type to “accurate” or lower temperature.
  • Same question = same answer? If you ask the exact same thing twice in a row, the extension reuses the previous answer to save time and money. For short questions (3 words or less), this lasts 2 seconds. For longer questions, this lasts until you ask something different or change settings.
  • Need the last answer again? Use the “last answer” block to get the previous response without making a new API call – it’s free and instant!

🔒 Privacy and Safety #

  • Your API key is saved temporarily in your browser – it disappears when you close the tab.
  • All conversations are sent to the selected provider’s servers for processing – review the provider’s privacy policy before use.
  • Conversation data may be used by the provider for model improvement unless you opt out in your account settings.
  • Automatic Safety Checking: Both your questions and the chatbot’s answers are checked to make sure everything is kid-friendly. Anything inappropriate gets blocked automatically – you’ll just see a message suggesting to talk about coding and creativity instead!
  • The extension is set up to give short, safe, kid-friendly answers by default.
  • Only your last 10 questions and answers are remembered, so conversations don’t get too long or confusing.
  • Always have a parent or teacher nearby when using AI tools – AI is smart but can still make mistakes!
  • Never share personal information (names, addresses, passwords) with AI chatbots.
  • Costs are charged to your provider account – monitor usage to avoid unexpected bills.
  • API keys grant access to your provider account – never share them publicly or in shared Scratch projects!

💰 Costs and Usage #

  • Providers charge per token (input + output). Check current pricing in the OpenAI and Gemini pricing pages.
  • Smaller models are usually more affordable – great for educational projects and experimentation.
  • Monitor your usage in your provider dashboard.
  • Set usage limits in your account settings to prevent overspending.
  • Use shorter max tokens to reduce costs per request.
  • Educational discounts or credits may be available – check the provider’s programs.

🧪 Technical Info #

  • API: OpenAI or Gemini chat APIs, plus shared local safety checking
  • Default Models List: OpenAI and Gemini chat-compatible models
  • Default Models: gpt-4o-mini for OpenAI, gemini-2.5-flash-lite for Gemini
  • Providers: OpenAI and Gemini
  • Conversation Memory: Automatically remembers your last 10 questions and answers
  • Answer Caching: Repeated questions return cached answers instantly – short questions (≤3 words) cache for 2 seconds, longer questions cache until changed
  • Max Tokens Range: 1–2048 (default: 360)
  • Temperature Range: 0–2 (default: 1 / “normal”)
  • Timeout: 30 seconds default (adjustable)
  • Language Detection: Automatic – AI ChatBot replies in whatever language you use
  • Safety Settings: Built-in rules to keep answers short, safe, and perfect for kids
  • Safety Checking: Your questions and answers are checked automatically
  • API Key Storage: Saved temporarily in your browser (deleted when you close the tab)
  • Smart Key Cleanup: Automatically removes invisible “junk” characters that sometimes sneak in when you copy/paste
  • Smart Answer Reuse: If you ask the same question twice in a row, you get the same answer instantly (saves time and money!)
  • Internet Required: Yes – all requests are sent to the selected provider’s servers

🔗 Related Extensions #

  • 🎤 Speech Recognition – convert voice to text, then send it to AI ChatBot
  • 🔊 Text to Speech – speak AI ChatBot’s responses out loud
  • 📝 Translate – translate AI ChatBot responses between languages
  • 🖼️ Image Trainer – train custom models directly inside Scratch

📚 Learn More #


Scroll to Top