With a single line of copy and paste, your very own AI character starts living on Discord [No Programming Required · 15 Minutes] #Beginner - Qiita
@FlatkeyAI

Copy and paste a single line, and your very own AI character starts living on Discord【No programming required · 15 minutes】

  • discord
  • chatbot
  • AI
  • beginner
  • Node.js
0
Posted at 2026-11-09
TAG40@@

I've put together instructions for creating an AI character that runs on your own computer and having it live in a Discord server. You don't need any programming knowledge. Copy and paste one command, and then configure everything through the browser interface.

We'll be using Mochi, the open-source (free) chatbot that I created.

  • It remembers each individual server member and can join conversations
  • You decide everything: the name, personality, speaking style, and greetings
  • It can also view images and search the web

First, a few things to note: Mochi uses a service called Flatkey as its AI brain, and I work with the Flatkey team. The steps in this article also require a Flatkey account.

The whole process takes about 15–20 minutes. You can also watch the steps in a video (about 3 minutes).

The official website (in Japanese) is here.

What You'll Need

  • A computer (Windows, Mac, or Linux are all OK)
  • A Discord account and a server where you are the administrator (you can create a new one for testing)
  • A Flatkey account (AI usage fees are paid from the balance deposited here. The software itself is free, and there are no monthly fees)

Step 1: Install Mochi

Copy the command

When you open the mochichatbot.com setup guide, the command for your computer is displayed. Click the "Copy" button.

For reference, here's what it looks like.

For Mac/Linux

curl -fsSL https://www.mochichatbot.com/install.sh | bash

For Windows

$p = Get-ExecutionPolicy -Scope Process; Set-ExecutionPolicy Bypass -Scope Process -Force; try { irm https://www.mochichatbot.com/install.ps1 | iex } finally { Set-ExecutionPolicy $p -Scope Process -Force }

The Windows command is long because Windows blocks script execution by default. This one line means “temporarily allow it only in this window, and restore the original setting when finished.” The computer's overall settings will not change.

Paste and run

  • Windows: Enter “PowerShell” in the Start menu and open it, then paste it by right-clicking (or pressing Ctrl+V) and press Enter
  • Mac: In Spotlight (⌘+Space), type “Terminal” and open it, paste with ⌘+V, and press Enter

All you need to do is wait. If necessary, Node.js (the software needed to run Mochi) will also be installed automatically. On Windows, you may be asked midway through, “Do you want to allow this app to make changes to your device?” Click “Yes.”

When it finishes, your browser will open automatically and the Mochi dashboard will appear.

Do not close the black screen (PowerShell/Terminal). Mochi will run only while this window is open.

For those curious about what’s inside: The installation script is open source,GitHub and you can read through it line by line. It does nothing other than install Node.js and Mochi and launch them.

Step 2: Set an administrator password

When you open the dashboard for the first time, a screen will ask you to create a password. Enter your preferred password twice and click “Set Password.”

Your password will not be stored as-is; it will be converted into an unreadable format before being saved. Instructions for resetting it if you forget are provided in the final “When You Get Stuck” section.

Step 3: Connect a Flatkey key

For Mochi to think and talk, it needs an AI “key.”

  1. Open “Flatkey API Key” on the dashboard and click “Create a Key on Flatkey”
  2. Log in to Flatkey (or sign up), create a new API key, and copy it
  3. Return to the dashboard, paste the key, and click “Connect Key”
  4. If “Key connected. Bot is awake.” appears, you’re all set

The cost is deducted from your balance based on your usage. You can try it out with a small initial deposit.

Step 4: Create a character

Open your first bot, “Mochi,” from “Your Bots,” and configure it in the “Persona” tab.

  • Name: The character’s name
  • Greeting: The character’s first words
  • Personality: You can write it in ordinary sentences, such as “Cheerful and a little teasing.”
  • You can also choose the tone of voice, emojis, and reply length

After configuring everything, click “Save Persona.”

When you open the “Playground” tab, you can talk to the character here before connecting to Discord and try out its personality.

Step 5: Connect to Discord

This is the most involved part, but the same instructions also appear under “Channels” → “Discord” on the dashboard.

  1. Open the Discord Developer Portal and create a new application using New Application
  2. (you can use the character’s name).
  3. Open Bot in the left menu, press Reset Token, and copy the string that appears (the bot token).
  4. On the same page, turn on Message Content Intent and save (if this is off, the bot cannot read messages).
  5. In the left menu, go to Installation → Guild Install, confirm that bot is included under Scopes, and select Send Messages, Read Message History, and Embed Links under Permissions.
  6. Return to the dashboard, paste the token into the “Bot Token” field, and press “Connect to Discord.”
  7. Open the displayed “Invite to Server” link, select your server, and invite the bot.

A bot token is like a password. Do not show it to anyone or paste it into a chat. If it is leaked, press Reset Token in the Developer Portal to make the old token unusable.

Step 6: Try Talking to It

On your Discord server, try @mentioning the bot or calling it by name. Once you receive a response, you’re done! 🎉

After chatting for a while, Mochi will start remembering things about each member.

How to Start It Again Next Time

Mochi will stop if you restart your computer or close the black window. To run it again, open PowerShell (or Terminal) and run the following:

Windows

cd "$HOME\mochi"; npm.cmd start

Mac・Linux

cd ~/mochi && npm start

You can open the dashboard at http://localhost:3000/dashboard.

View and delete what Mochi has learned

In the bot’s “Memories” tab, you can see who Mochi remembers and what it knows about them.

  • You can use the “Forget” button to delete just one specific person or one channel (group).
  • It will be deleted even if the member themselves tells Mochi, “Forget about me.”

Memories are stored in a file on your computer and are not placed on any company’s server. However, when generating a response, the message is sent to the AI model (via Flatkey).

Tips for reducing costs

  • Set a daily limit: Set a “Daily Token Budget” in the “Models and Features” tab to prevent overuse.
  • Switch to a cheaper model: You can select the AI model used for conversations in the same tab. You can keep the character and switch only to a cheaper model.

When you run into trouble

Q. The bot does not respond
The following two are the most common causes.

  • Make sure Message Content Intent is enabled in the Developer Portal
  • If bot is not included in Scopes when creating the invitation link, the bot will not join the server (check whether the bot is listed among the members)

Q. “port 3000 is already in use” appears on a black screen
Mochi is already running in another window. Open http://localhost:3000/dashboard in your browser, and you can use it as is.

Q. I forgot my password
Open the .env file in the Mochi folder (username\mochi on Windows, ~/mochi on Mac) in Notepad or another text editor, delete everything after ADMIN_TOKEN=, save the file, and then restart Mochi. The password setup screen will appear again.

Q. I want it to keep running 24/7 even when I turn off my computer
You can also host it on a small server (VPS), or on a cloud platform such as Sealos or Render. Instructions are available in the “Run on a server (24/7 operation)” tab of the site setup guide.

Q. I got stuck during setup
In the setup guide, you can copy a prompt from “Let AI set it up for you” and simply paste it into ChatGPT or Claude. It will guide you through the process while you follow along on your screen. (Do not paste API keys or tokens into the chat with the AI.)

For developers (feel free to skip this)

It uses only Node.js and SQLite, with no Redis or database server. Japanese document search uses SQLite FTS5 (trigram), with only words shorter than three characters, such as the two-character word “返金” (refund), supplemented using LIKE. Issues and pull requests are welcome.

About the AI provider (I have a vested interest)

To reiterate, Mochi uses Flatkey as its AI provider, and I work with the Flatkey team.

I chose Flatkey because the chatbot uses different AI models for conversation, images, search, and organizing memories. Contracting directly with each provider would require separate accounts and separate billing for each one. With Flatkey, a single key gives you access to official models such as GPT, Claude, Gemini, and DeepSeek, and the models you use most are more than 20% cheaper than the official pricing.

I’d appreciate comments sharing your impressions after trying it or letting me know where you “got stuck.” I’ll use your feedback to improve the instructions.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
Sign upLogin