Use Case: Research a company and generate personalized email hooks.
const website = await ctx.thisRow.get("Website");const companyName = await ctx.thisRow.get("Company Name");// Research the companyconst research = await services.ai.generateText({ prompt: `Research ${companyName} at ${website}Find concrete signals about:- Recent news or developments- Technology stack or systems they use- Growth signals (hiring, expansion, funding)- Operational challenges or pain pointsKeep findings concise and cite sources.`, model: "gpt-5-mini", enableWebSearch: true});// Generate personalized email variableconst personalization = await services.ai.generateObject({ prompt: `Based on this research, generate a personalized email opening line.Research:${research.text}Email template:"Hi {{Name}}, I noticed that {{PERSONALIZATION}}. Would love to chat about how we can help."Generate the personalization that fills in {{PERSONALIZATION}}. Make it:- Specific and relevant- Natural and conversational- Related to their business- 1-2 sentences max`, schema: z.object({ personalization: z.string(), confidence: z.number().min(0).max(1) }), model: "gpt-5-mini"});return personalization.object.personalization;
Use Case: Scrape a company’s website and generate personalized email content.
const website = await ctx.thisRow.get('Website');const companyName = await ctx.thisRow.get('Company Name');// Scrape the websiteconst scraped = await services.scrape.website({ url: website, params: { limit: 3 } // Scrape a few pages});// Generate personalized email hooksconst result = await services.ai.generateObject({ prompt: `Based on this website content for ${companyName}, generate personalized email hooks.Website content:${scraped.markdown.substring(0, 15000)}Generate 3 personalization options:1. email1_hook - Opening line mentioning something specific about their business2. email2_hook - Follow-up line referencing their products/services3. value_prop - One-liner about how our solution helps them specificallyMake each natural, conversational, and specific to THIS company.`, schema: z.object({ email1_hook: z.string(), email2_hook: z.string(), value_prop: z.string() }), model: "claude-sonnet-4-5-20250929"});return result.object;