Create Your First Skill
To develop an AI Agent Skill, you will be using the Moxie Skills Framework as the base for your development.
In this tutorial, you will learn how to create your first Moxie Skill for your AI Agent using the Moxie Skills Framework.
The AI Agent Skill demonstrated here is straightforward and enables your AI Agent to provide the most up-to-date summarized information of your ETH balances on Base.
Pre-requisites
AI Agent Skills are essentially custom Eliza plugins that you can build to enhance your AI Agents.
Before you begin development, please ensure you have all the prerequisites for the Eliza Framework:
- Node.js 23+
- pnpm 9+
- Git for version control
- A code editor (VS Code or VSCodium recommended)
- CUDA Toolkit (optional, for GPU acceleration)
- OpenAI API Key (for OpenAI models)
Once your environment is set up, fork the Moxie Skills Framework repository and then clone it locally to your machine.
Once you cloned the repository, you can setup your environment with the following scripts:
cd moxie-agent-skills
cp .env.example .env
pnpm i --no-frozen-lockfile && pnpm build
In the newly created .env
file, you can add the following environment variables for this tutorial:
OPENAI_API_KEY= # OpenAI API key
PRIVATE_KEY= # Private key for executing tx with Moxie Lib, simulating agent wallet
AIRSTACK_API_KEY= # For fetching user's Moxie portfolio data
MOXIE_LIB_RPC_URL= # RPC URL for executing tx with Moxie Lib
Feel fee to provide other relevant API keys if you are using other AI models for your agent.
Step 1: Define a New Plugin
First, create a separate branch in your forked repository:
git checkout -b <new-branch>
Then, create a new skill by running the following command:
pnpm create:skills plugin-first-skill
Once the skill is created, a new folder packages/plugin-first-skill
will be created. Then, open the packages/plugin-first-skill/src/index.ts
file to define your plugin instance:
// all import statements no changes
const samplePlugin: Plugin = {
name: "my-first-moxie-skill",
description:
"This plugin is invoked when the user is asking for the current state of the Moxie protocol.",
actions: [],
providers: [],
evaluators: [],
services: [],
clients: [],
};
export default samplePlugin;
Step 2: Create New Action For The Agent
After defining your plugin, you will create a new Eliza provider and a new action to give your agent the ability to handle protocol-specific data.
Eliza action is a core components of the Eliza framework that help modularize and extend the functionality of your AI Agent.
An action defines how the agent responds to user inputs.
First, define an action that tells your agent how to respond when a user requests Moxie protocol information. To achieve this, you will need to fill out the following fields:
interface Action {
// Unique identifier for the action
name: string;
// Array of alternative names/variations
similes: string[];
// Detailed explanation of the action's purpose
description: string;
// Function that checks if action is appropriate
examples: ActionExample[][];
// Demonstrates proper usage patterns
handler: Handler;
// Determines if the action can be executed
validate: Validator;
// When true, suppresses the initial response message before processing the action.
// Useful for actions that generate their own responses (like image generation)
suppressInitialMessage?: boolean;
}
Create a new file in the src/actions
directory, and define the new action with your chosen name
, similes
, and description
:
import type {
Action,
HandlerCallback,
IAgentRuntime,
Memory,
State,
} from "@moxie-protocol/core";
const balanceAction: Action = {
name: "ETH_BALANCE_ON_BASE",
similes: [
"CHECK_ETH_BALANCE_ON_BASE",
"GET_ETH_BALANCE_ON_BASE",
"VIEW_ETH_BALANCE_ON_BASE",
"SHOW_ETH_BALANCE_ON_BASE",
"WALLET_ETH_BALANCE_ON_BASE",
"BASE_ETH_BALANCE_ON_BASE",
],
description: "Check the balance of your agent wallet on Base",
suppressInitialMessage: true,
} as Action;
export default balanceAction;
These metadata guide the AI Agent in selecting the appropriate action when a user sends prompts, so be sure to provide a clear and informative name
, similes
, and description
.
If you would like to add any gating logic, then you can add additional if-else statements to the validate
field where false
is returned if the requests is invalid.
After that, define the handler
field to retrieve the ETH balance of the agent's wallet and return this information to the user.
The handler
field full code should look as following:
import type {
Action,
HandlerCallback,
IAgentRuntime,
Memory,
State,
} from "@moxie-protocol/core";
import { MoxieWalletClient } from "@moxie-protocol/moxie-lib/src/wallet";
import { formatEther, http, createPublicClient } from "viem";
import { base } from "viem/chains";
const balanceAction: Action = {
// ... same as above
handler: async (
runtime: IAgentRuntime,
message: Memory,
state?: State,
options?: { [key: string]: unknown },
callback?: HandlerCallback
) => {
try {
const publicClient = createPublicClient({
chain: base,
transport: http(),
});
// Get the agent's wallet instance from state
const { address } = state.agentWallet as MoxieWalletClient;
// Get the ETH balance of the agent's wallet
const balance = await publicClient.getBalance({
address: address as `0x${string}`,
});
const balanceAsEther = formatEther(balance);
await callback?.({
text: `The balance of your agent wallet is ${balanceAsEther} ETH.`,
});
} catch (error) {
callback?.({
text: `Sorry, there was an error fetching your agent wallet ETH balancedata: ${
error instanceof Error ? error.message : "Unknown error"
}`,
});
return false;
}
},
} as Action;
export default balanceAction;
Lastly, add an examples
field to your action. By providing a range of prompts, the agent can learn different question patterns and how to respond appropriately:
import type {
Action,
HandlerCallback,
IAgentRuntime,
Memory,
State,
} from "@moxie-protocol/core";
const balanceAction: Action = {
// ... same as above
examples: [
[
{
user: "{{user1}}",
content: {
text: "what is my current ETH balance on Base?",
},
},
{
user: "{{user2}}",
content: {
text: "The balance of your agent wallet is 0.01 ETH",
action: "TOKEN_BALANCE_ON_BASE",
},
},
],
],
} as Action;
export default balanceAction;
Finally, integrate the provider and action above into your plugin by importing it and adding it to the actions array:
import { Action } from "@moxie-protocol/core";
import balanceAction from "../actions/balanceAction";
const samplePlugin: Plugin = {
name: "my-first-creator-agent-skill",
description: "My First Moxie Skill",
actions: [balanceAction],
providers: [],
evaluators: [],
services: [],
clients: [],
};
export default samplePlugin;
and add it to your agent instance on line 489 in agent/src/index.ts
:
import { Agent } from "@moxie-protocol/core";
import myFirstCreatorAgentSkill from "@moxie-protocol/plugin-first-skill";
const runtime = new AgentRuntime({
// other parameters
plugins: [
// Other plugins (if any)
myFirstCreatorAgentSkill,
],
});
Beyond Eliza providers and actions, you can further tailor your Moxie Skill by incorporating custom evaluators or services to introduce advanced features and monetization options.
Step 3: Test Your Plugin With The Agent
To test your plugin, start the Eliza framework locally by running:
- npm
- yarn
- pnpm
- bun
npm run start
yarn start
pnpm start
bun start
With the agent running, you can then start a client with a chat interface in a different terminal tab to test interactions with your AI Agent:
- npm
- yarn
- pnpm
- bun
npm run start:client
yarn start:client
pnpm start:client
bun start:client
Try out various of the following prompts to test your newly created AI Agent Skills yourself:
- What is my current ETH balance on Base?
- How much ETH is in my agent wallet?
- Check my ETH balance on Base
- etc.
Congratulations! 🥳🎉 You have successfully created your first Moxie Skill for your AI Agent.
Next, you can proceed to connect your skills to Moxie and offer your skills in the Moxie AI Agent ecosystem.
More Resources
For adding more advanced features to your AI Agent, you can refer to the following resources to further develop your AI Agent Skills:
- Eliza Developer Docs
- Best Practices For Eliza Plugin Development
- Autonomous Trading
- Wallet Secrets Management
Developer Support
If you have any questions or need help with other use cases, feel free to join the Moxie Telegram Developers Channel and ask your questions there.
Our team is always ready to help you with any questions you may have.