Skip to content

Add direct payment links and Addie email response capability#507

Merged
bokelley merged 5 commits into
mainfrom
bokelley/direct-payment-links
Jan 3, 2026
Merged

Add direct payment links and Addie email response capability#507
bokelley merged 5 commits into
mainfrom
bokelley/direct-payment-links

Conversation

@bokelley

@bokelley bokelley commented Jan 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds two related features for streamlining prospect-to-member conversion:

1. Direct Payment Links (Admin UI + Addie)

  • Quick Action Bar on admin prospects page for search-as-you-type and one-click payment link generation
  • send_payment_request Addie tool for generating payment links or invoices with optional discounts
  • Support for pre-applied discounts via Stripe coupons/promotion codes

2. Addie Email Response Capability

  • When CC'd on prospect emails (e.g., addie+prospect@agenticadvertising.org), Addie can now respond
  • Requires explicit invocation (e.g., "Addie, send a payment link to this prospect")
  • Properly threads replies with In-Reply-To and References headers
  • Supports admin tools when sender is an admin user

Security Improvements

  • Sanitize email From/Subject before including in Claude prompts (prevent injection)
  • Validate fromEmail is from agenticadvertising.org domain (prevent spoofing)
  • Use domain-based pattern for excluding our addresses from recipients
  • Pass workosUserId (not contactId) for proper admin authorization

Files Changed

  • server/src/addie/email-handler.ts - New: Email invocation detection and processing
  • server/src/addie/mcp/admin-tools.ts - Added send_payment_request tool
  • server/src/notifications/email.ts - Added sendEmailReply function
  • server/src/routes/webhooks.ts - Wire up email handler, include workosUserId in contacts
  • server/src/addie/types.ts - Added 'email' event type to interaction log
  • server/src/billing/stripe-client.ts - Added discount support to checkout sessions
  • server/public/admin-prospects.html - Quick Action Bar UI

Test plan

  • Test Quick Action Bar search functionality in admin UI
  • Test payment link generation with and without discounts
  • Send test email CC'ing addie+prospect@agenticadvertising.org with Addie invocation
  • Verify Addie responds in thread with proper email headers
  • Verify admin tools are only available to admin users

🤖 Generated with Claude Code

bokelley and others added 5 commits January 3, 2026 14:01
- Add `send_payment_request` Addie tool that:
  - Finds or creates prospects by name/domain
  - Shows contacts and registered users
  - Generates Stripe payment links
  - Sends invoices with billing address
  - Suggests membership tier based on company size

- Add Quick Action Bar to admin prospects page:
  - Type-to-search for companies
  - One-click payment link or invoice generation
  - Create new prospect if not found
  - Pre-fills forms with contact info

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add couponId and promotionCode parameters to createCheckoutSession
- Pre-apply discounts to Stripe checkout sessions
- Add discount_percent, discount_amount_dollars, discount_reason
  parameters to send_payment_request Addie tool
- Auto-apply existing org discounts when generating payment links
- Create new discounts on-the-fly when requested

Now Addie can handle requests like:
- "Give Acme a 20% discount and send them a payment link"
- "Send a discounted link to the startup"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When Addie is CC'd on prospect emails and explicitly invoked (e.g., "Addie,
send a payment link"), she can now process the request and reply in the
email thread.

Changes:
- Add email-handler.ts for detecting Addie invocations and processing requests
- Add sendEmailReply to notifications/email.ts with proper threading headers
- Add 'email' event type to AddieInteractionLog for audit logging
- Wire up email handler in bolt-app.ts initialization
- Pass workosUserId (not contactId) for proper admin authorization
- Sanitize email metadata in prompts to prevent injection
- Validate fromEmail domain to prevent spoofing
- Fix recipient filtering to use domain-based exclusion

Security improvements based on code review:
- Sanitize email From/Subject before including in Claude prompt
- Validate fromEmail is from agenticadvertising.org domain
- Use domain-based pattern for excluding our addresses from recipients

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Resolve merge conflict in admin-tools.ts by keeping both:
- Payment link/invoice imports (from this branch)
- Organization merge imports (from main)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bokelley bokelley merged commit ba32b79 into main Jan 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant