Hackathon Store
Get all the hackathon needs from the general store.
Structure
hackathon-store/
├── src/
│ ├── plugins/
│ ├── notion.ts
│ ├── index.ts
│ ├── prompt.ts
├── package.json
├── tsconfig.json
└── .env
Agent
The process that starts listening to messages and replying to them.
src/index.ts
import { agentReply, Context, createAgent } from "@xmtp/message-kit";
import { downloadPage } from "./plugins/notion.js";
import fs from "fs";
setupFiles();
export const agent = createAgent({
name: "Hackathon Store",
tag: "@store",
description: "Hackathon Store",
systemPrompt: fs.existsSync("src/prompt.md")
? fs.readFileSync("src/prompt.md", "utf-8")
: "",
onMessage: async (context: Context) => {
const {
message: {
content: { skill },
},
} = context;
if (skill === "update") {
const page = await downloadPage();
fs.writeFileSync("src/prompt.md", page);
await context.reply("Notion DB updated");
}
await agentReply(context);
},
}).run();
async function setupFiles() {
const page = await downloadPage();
fs.writeFileSync("src/prompt.md", page);
console.log("Notion DB updated");
}
Notion file
This prompt loads from a notion package. You can manually update the prompt by running the update
skill. or it will update each time you run the agent.
Plugins
- Notion: Interact with Notion
Prompt
Here is the prompt that the agent will use to reply to messages.
src/prompt.md
You are a helpful agent that lives inside a messaging app. You manage the general store from XMTP that delivers goodies, POAPs and testnet funds.
{rules}
{user_context}
{skills}
### Goodies
- When greeted for the first time, give the full menu.
- The user can select the option by number or name
- Once the option is selected confirm the order
## Response Scenarios:
- Welcome message:
Welcome to The General Store powered by ENS + XMTP, where web3 builders can get supplies, anytime, day or night.
Below is our menu. Let us know the number of the item you want, and it's yours. If it's a digital good, our bot will deliver those items right to your wallet.
- Chewing Gum
- TicTacs
- Deodorant
- RedBull
- Toothbrush
- Toothpaste
- XMTP Swag
- Testnet funds
- POAP
- Delivering goodies
Let me get your TicTacs... Your order is confirmed. Enjoy!
Variables
Set up these variables in your app
cmd
TEST_ENCRYPTION_KEY= # test encryption key
KEY= # key of xmtp bot
NOTION_API_KEY= # notion api key
NOTION_PAGE_ID= # notion page id
OPENAI_API_KEY= # openai api key
REDIS_CONNECTION_STRING= # redis connection string