ENS Agent
This is a simple yet powerful agent that will help users interact with ENS.
Skills
- Check: Check if a domain is available
- Cool: Show cool alternatives
- Register: Register a domain
- Reset: Reset a domain
- Renew: Renew a domain
- Info: Get info about a domain
- Tip: Tip a domain
Structure
agent/
├── src/
│ └── handler/ # ENS agent
│ ├── check.ts # Check if a domain is available
│ ├── cool.ts # Show cool alternatives
│ ├── info.ts # Check if a domain is registered
│ ├── register.ts # Register a domain
│ ├── renew.ts # Renew a domain
│ ├── reset.ts # Reset a domain
│ ├── tip.ts # Tip a domain
│ ├── index.ts # Prompt and stream
│ ├── prompt.ts # Prompt
├── package.json
├── tsconfig.json
└── .env
Runner
The runner function to start the agent and listen for incoming messages:
src/index.ts
import {
run,
agentReply,
replaceVariables,
XMTPContext,
} from "@xmtp/message-kit";
import { systemPrompt } from "./prompt.js";
import { registerSkill as checkSkill } from "./handlers/check.js";
import { registerSkill as coolSkill } from "./handlers/cool.js";
import { registerSkill as infoSkill } from "./handlers/info.js";
import { registerSkill as registerSkill } from "./handlers/register.js";
import { registerSkill as renewSkill } from "./handlers/renew.js";
import { registerSkill as resetSkill } from "./handlers/reset.js";
import { registerSkill as tipSkill } from "./handlers/tip.js";
import fs from "fs";
export const frameUrl = "https://ens.steer.fun/";
export const ensUrl = "https://app.ens.domains/";
export const txpayUrl = "https://txpay.vercel.app";
export const skills = [
{
name: "Ens Domain Bot",
tag: "@ens",
description: "Register ENS domains.",
skills: [
...checkSkill,
...coolSkill,
...infoSkill,
...registerSkill,
...renewSkill,
...resetSkill,
...tipSkill,
],
},
];
run(
async (context: XMTPContext) => {
const {
message: { sender },
skills,
} = context;
let prompt = await replaceVariables(
systemPrompt,
sender.address,
skills,
"@ens",
);
fs.writeFileSync("example_prompt.md", prompt);
await agentReply(context, prompt);
},
{ skills },
);
Prompt
This is the prompt that the agent will use to respond to the user.
src/prompt.ts
export const systemPrompt = `
Your are helpful and playful agent called {agent_name} that lives inside a web3 messaging app called Converse.
{rules}
{user_context}
{skills}
## Response Scenarios:
1. When greeting or when the user asks for an ENS domain, check if the user does not have an ENS domain:
Hey {name}! It looks like you don't have an ENS domain yet!
Let me start by checking your Converse username with the .eth suffix
/check localdev6.eth
2. If the user has an ENS domain:
I'll help you get your ENS domain.
Let's start by checking your ENS domain. Give me a moment.
/check [domain]
3. Check if the ENS domain is available:
Hello! I'll help you get your domain.
Let's start by checking your ENS domain. Give me a moment.
/check [domain]
4. If the ENS domain is available:
Looks like [domain] is available! Here you can register it:
/register [domain]
Or I can suggest some cool alternatives? Let me know!
5. If the ENS domain is already registered, suggest 5 cool alternatives:
Looks like [domain] is already registered!
What about these cool alternatives?
/cool [domain]
6. If the user wants to register an ENS domain:
Looks like [domain] is available! Let me help you register it.
/register [domain]
7. If the user wants to directly tip the ENS domain owner:
Here is the URL to send the tip:
/tip [address]
8. If the user wants to get information about the ENS domain:
Hello! I'll help you get info about [domain].
Give me a moment.
/info [domain]
9. If the user wants to renew their domain:
Hello! I'll help you get your ENS domain.
Let's start by checking your ENS domain. Give me a moment.
/renew [domain]
10. If the user wants cool suggestions about a domain:
Here are some cool suggestions for your domain.
/cool [domain]
## Most common bugs
1. Some times you will say something like: "Looks like vitalik.eth is registered! What about these cool alternatives?" But you forgot to add the command at the end of the message.
`;
Run the app
Follow the steps below to run the app
Setup
cmd
# Clone the repo
git clone https://github.com/ephemeraHQ/message-kit
# Go to the templates/agent folder
cd templates/agent
# Install the dependencies
yarn install
# Run the app
yarn dev
Variables
Set up these variables in your app
.env
KEY= # the private key of the wallet
OPENAI_API_KEY= # sk-proj-...