Product

AI Automation

AutoPilot's AI layer translates plain English financial goals into structured, on-chain automation rules using Groq's ultra-fast LLM API. This page covers how the AI pipeline works end-to-end.

End-to-End Flow

1
User Input
User types: "Save 10% of every XLM payment I receive"
2
API Call
Frontend posts to /api/chat → backend /api/chat route
3
Groq LLM
Groq llama-3.3-70b-versatile model parses intent and returns structured JSON
4
Rule Storage
Rule saved to PostgreSQL: trigger, action, amount, isPercentage, vaultType
5
Horizon Stream
Backend opens SSE stream for user's wallet. On payment arrival → rule fires
6
Execution
Engine sends XLM to savings/investment vault. Transaction logged to DB.

AI System Prompt

The backend sends Groq a strict system prompt instructing it to output only valid JSON:

text
You are an AutoPilot financial automation assistant for the Stellar blockchain.
Parse the user's financial goal and return ONLY valid JSON with this structure:
{
  "description": "Human-readable rule description",
  "trigger": "on every payment received",
  "action": "save" | "invest" | "buffer",
  "amount": <number>,
  "isPercentage": <boolean>,
  "memo": "<optional short memo>"
}
Rules must only involve XLM. Do not create USDC rules.
If the user's intent is unclear, return null.

Rule Matching (processor.ts)

When a payment arrives on the Horizon SSE stream, processPaymentDirect() runs these checks:

typescript
function doesPaymentMatchTrigger(trigger: string, asset: string): boolean {
  // Only XLM payments can trigger rules on Testnet
  if (asset !== "XLM") return false;

  const t = trigger.toLowerCase();
  return (
    t.includes("every payment") ||
    t.includes("payment received") ||
    t.includes("incoming payment")
  );
}

// Execution logic
const execAmount = rule.isPercentage
  ? (rule.amount / 100) * paymentAmount
  : rule.amount;

await executeRuleTransaction(vaultPublicKey, execAmountStr, memo);

Groq Model & Performance

Model
llama-3.3-70b-versatile
Avg. Response
~800ms
Temperature
0.1 (deterministic)
Max Tokens
256 (JSON only)

See the full system architecture including the stream engine.

View Architecture