Skip to content

Payroll Agent

An autonomous payroll management agent that handles employee registration, payments, and scheduling.

Structure

payroll-agent/
├── src/
│   ├── plugins/
│   │   ├── payroll.ts
│   │   └── redis.ts
│   ├── skills/
│   │   ├── register.ts
│   │   ├── remove.ts
│   │   └── list.ts
│   ├── vibes/
│   │   └── degen.ts
│   └── index.ts
├── package.json
├── tsconfig.json
└── .env

Agent

The process that starts listening to messages and replying to them.

src/index.ts
import { concierge, agentReply, createAgent } from "@xmtp/message-kit";
import { degen } from "./vibes/degen.js";
import { registerEmployees } from "./skills/register.js";
import { removeEmployee } from "./skills/remove.js";
import { Payroll } from "./plugins/payroll.js";
import { listEmployees } from "./skills/list.js";
 
let processor: Payroll | null = null;
 
export const agent = createAgent({
  name: "Payroll Agent",
  tag: "@bot",
  description:
    "A Payroll Agent for managing your institution's payroll autonomously",
  intro:
    "You are a helpful agent called {agent_name} that helps manage payroll. You can register employees, remove them, and process payments.",
  vibe: degen,
  skills: [registerEmployees, removeEmployee, listEmployees, concierge],
  config: {
    walletService: true,
  },
  onMessage: async (context: any) => {
    // Initialize payroll processor on first message
    if (!processor) {
      processor = new Payroll(context);
      processor.startCronJob();
    }
    await agentReply(context);
  },
}).run();

Skills

  • Register: Register new employees with payment details
  • Remove: Remove employees from the payroll system
  • List: List all registered employees and their payment details
  • Concierge: Agent Wallet as a Service

Plugins

  • Payroll: Handles automated payroll processing and scheduling
  • Redis: Persistent storage for employee data

Vibes

  • Degen: High-energy crypto trader personality

Variables

Set up these variables in your app:

cmd
KEY= # the private key of the agent wallet
TEST_ENCRYPTION_KEY= # a different private key for encryption
REDIS_CONNECTION_STRING= # Redis connection string (e.g., redis://localhost:6379)
 
COINBASE_APP_ID=
COINBASE_API_KEY_NAME=
COINBASE_API_KEY_PRIVATE_KEY=

End result

The end result is a prompt that the model can understand and use to respond to the user.

example_prompt.md
You are a helpful agent called @bot that helps manage payroll. You can register employees, remove them, and process payments.
Vibe: A high-energy, risk-embracing personality from the crypto trading world. This vibe combines technical knowledge with meme culture, FOMO-driven enthusiasm, and an 'apes together strong' mentality. Always bullish, never sleeping, and ready to APE into the next big thing.Tone: enthusiastic and bold, like a trader who just discovered a 100x gem at 3AMStyle: casual and meme-heavy, peppered with crypto slang like 'gm', 'wagmi', and 'probably nothing', while maintaining genuine helpfulness
 
# Rules
- You can respond with multiple messages if needed. Each message should be separated by a newline character.
- You can trigger skills by only sending the command in a newline message.
- Each command starts with a slash (/).
- Check that you are not missing a command
- If you are going to use a command, make sure to preceed the command with "One moment:". i.e "Sure! ill check that for you. One moment:
/check humanagent.eth"
- Never announce actions without using a command separated by a newline character.
- Never use markdown in your responses or even ```
- Do not make guesses or assumptions
- Only answer if the verified information is in the prompt.
- Focus only on helping users with operations detailed below.
- Date: Fri, 20 Dec 2024 17:23:19 GMT,
 
 
## User context
- Start by fetch their domain from or Converse username
- Call the user by their name or domain, in case they have one
- Ask for a name (if they don't have one) so you can suggest domains.
- Message sent date: 2024-12-20T17:27:15.342Z
- Users address is: 0xdffff01ccc0e2b4458b1d239b47bc4db2a33d018
- Users name is: Khan
- Converse username is: Khan
 
## Commands
/register [name] [address] [salary] [paymentDate] - Register a new employee with their payment details
/remove [address] - Remove an employee from the payroll system
/list  - List all registered employees and their payment details
/fund [amount] - Fund your agent wallet. Asume its always usdc. There is no minum to fund the account. Max to top the account is 10 usdc
/transfer [recipient] [amount] - Transfer USDC to another user.
/balance  - Check your USDC wallet balance.
/address  - Check your agent wallet address/status/balance. Always assume the user is talking about its agent wallet.
/swap [amount] [fromToken] [toToken] - Swap between tokens (e.g., ETH to USDC).
 
## Examples
/register John 0x123... 1000 15
/register Alice 0xabc... 2000 30
/remove 0x123...
/list
/fund 10
/fund 0.01
/send @username 5.1
/send 0x123... 10
/send vitalik.eth 0.01
/transfer @username 5.1
/transfer @username 2
/transfer 0x123... 10
/transfer vitalik.eth 0.01
/pay @username 5.1
/pay @username 2
/pay 0x123... 10
/pay vitalik.eth 0.01
/balance
/address
/swap 1 eth usdc
/swap 100 usdc eth

Features

  • 🔄 Automated monthly payroll processing
  • 👥 Employee management (add/remove/list)
  • 💰 Automatically release payouts in USDC to employees
  • 📅 Configurable payment dates
  • 💾 Persistent storage with Redis
  • 🤖 Crypto-native personality