Phase 2 part 7: the end of the funnel

Posts can be written for a buying signal: the prompt gets its hypothesis
and angle, and links carry its campaign tag. Plausible (Stats API v2) is
read once a day for visitors on tagged links, recorded per signal as
Visited. Stripe (restricted key) is read every hour: $0 checkouts are
Signed up, paid invoices and one-time payments are Paid with their value,
tied to a signal by the checkout's utm_campaign metadata or the payer's
email. The Core's Cal.com has no API, so booking emails from Cal.com in
the outreach mailbox count as Booked. New Settings → Website & sales;
the signal page lists its posts and tagged links. Schema 11.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 06:42:03 -07:00
co-authored by Claude Opus 5.5
parent 90d73cf907
commit d23d5e2a87
32 changed files with 1775 additions and 26 deletions
+40
View File
@@ -534,3 +534,43 @@ func TestSettings(t *testing.T) {
t.Errorf("dns: %+v", c)
}
}
func TestBookings(t *testing.T) {
d := openDB(t)
s := imapServer(t)
s.BookingFrom = "calcom@example.com"
ctx := context.Background()
ann := person(t, d, "Ann", "ann@acme.example")
deliver(t, s, "From: Cal.com <calcom@example.com>\nTo: Pat Lee <pat@example.com>\nSubject: New event: 30 min between Pat Lee and Ann Doe\n"+
"Message-ID: <b1@cal>\nContent-Type: text/plain\n\nWhat: 30 min\nWho: Pat Lee - Organizer pat@example.com\nAnn Doe ann@acme.example\n")
deliver(t, s, "From: Cal.com <calcom@example.com>\nTo: pat@example.com\nSubject: Event cancelled: 30 min with Ann Doe\n"+
"Message-ID: <b2@cal>\n\nCancelled. ann@acme.example\n")
deliver(t, s, "From: Cal.com <calcom@example.com>\nTo: pat@example.com\nSubject: New event: Intro between Pat Lee and Zed\n"+
"Message-ID: <b3@cal>\nContent-Type: text/html\n\n<p>Who: <a href=\"mailto:noreply@cal.example\">x</a> zed@else.example</p>\n")
res, err := CheckReplies(ctx, d, s, "password", now)
if err != nil {
t.Fatal(err)
}
if res.Bookings != 2 {
t.Fatalf("check: %+v", res)
}
evs, _ := signals.SubjectEvents(d, prospects.Subject("contact", ann))
var booked *signals.Event
for i := range evs {
if evs[i].Stage == signals.StageBooked {
booked = &evs[i]
}
}
if booked == nil || booked.SignalID == 0 || booked.Email != "ann@acme.example" || !strings.Contains(booked.Note, "30 min") {
t.Errorf("ann's booking: %+v", evs)
}
if zed, _ := signals.SubjectEvents(d, "booking:zed@else.example"); len(zed) != 1 || zed[0].SignalID != 0 {
t.Errorf("zed's booking: %+v", zed)
}
// Read again: nothing new.
if res, _ := CheckReplies(ctx, d, s, "password", now); res.Bookings != 0 {
t.Errorf("again: %+v", res)
}
}