add LLM-based enterprise lead scoring and auto-replies

Extract delivery logic from the enterprise route into a dedicated
module that grades inquiries via the Zen responses API, falls back
to simple regex scoring on failure, and sends templated auto-replies
for generic and procurement-blocked leads.

Made-with: Cursor
This commit is contained in:
Ryan Vogel 2026-03-19 17:38:16 -04:00
commit bc3fe8f4f5
5 changed files with 380 additions and 52 deletions

View file

@ -19,12 +19,17 @@ export namespace AWS {
export const sendEmail = fn(
z.object({
from: z.string().optional(),
to: z.string(),
subject: z.string(),
body: z.string(),
text: z.string().optional(),
html: z.string().optional(),
replyTo: z.string().optional(),
}),
async (input) => {
const text = input.text ?? input.body
const html = input.html ?? input.body
const res = await createClient().fetch("https://email.us-east-1.amazonaws.com/v2/email/outbound-emails", {
method: "POST",
headers: {
@ -32,7 +37,7 @@ export namespace AWS {
"Content-Type": "application/json",
},
body: JSON.stringify({
FromEmailAddress: `OpenCode Zen <contact@anoma.ly>`,
FromEmailAddress: input.from ?? "OpenCode Zen <contact@anoma.ly>",
Destination: {
ToAddresses: [input.to],
},
@ -46,11 +51,11 @@ export namespace AWS {
Body: {
Text: {
Charset: "UTF-8",
Data: input.body,
Data: text,
},
Html: {
Charset: "UTF-8",
Data: input.body,
Data: html,
},
},
},