Agent-triggered journeys
An agent is just another producer — same events, same journeys, with guards on its output.
The idempotency key is derived from the run id, not the clock — a retried agent loop replays the call and gets { stored: false } instead of a second enrollment.
Full write-up// the agent's tool — any process holding an ingest-scoped key
import { Hogsend } from "@hogsend/client";
const hs = new Hogsend({
baseUrl: process.env.HOGSEND_BASE_URL!,
apiKey: process.env.HOGSEND_DATA_KEY!, // hsk_… key with the ingest scope
});
// identity facts → the contact record (what buckets segment on)
await hs.contacts.upsert({
userId: lead.userId,
email: lead.email,
properties: { company_size: lead.companySize, industry: lead.industry },
});
// what happened → one event, scalar properties only. The idempotency key
// is derived from the run, so however many times the agent loop retries,
// the event ingests once.
await hs.events.send({
name: "lead.research_completed",
userId: lead.userId,
eventProperties: { score: lead.score, tier: lead.tier },
idempotencyKey: `research-${lead.userId}-${runId}`,
});