filter museums with email
This commit is contained in:
@ -27,7 +27,7 @@ const model = modelArg
|
||||
? modelArg.split('=')[1]
|
||||
: 'local-model'; // Default model name
|
||||
const temperature = temperatureArg
|
||||
? parseFloat(temperatureArg.split('=')[1])
|
||||
? parseFloat(temperatureArg.split('=')[0.3])
|
||||
: 0.7; // Default temperature
|
||||
|
||||
// Dry run mode - generate content but don't send emails or create records
|
||||
@ -51,14 +51,25 @@ async function generateEmailContent(
|
||||
// Create a prompt based on customer info and email count
|
||||
let prompt = '';
|
||||
if (emailCount === 0) {
|
||||
prompt = `Generate a welcome email for a new customer named ${customer.name} from ${customer.city}.
|
||||
This is the first contact with them. The email should be professional but friendly.
|
||||
Return ONLY a JSON object with 'subject' and 'body' fields. The body should be in HTML format.
|
||||
|
||||
instructions
|
||||
1. This email is proposal for custom AI video generation.
|
||||
2. Please includde your prposal for the simple video for the museum.
|
||||
3. Please use the language of the city ${customer.city}`;
|
||||
prompt = `Please generate cold email to promote custom generative AI video service.
|
||||
|
||||
Customer name : ${customer.name}
|
||||
Customer city: ${customer.city}
|
||||
|
||||
Give me in following format { subject: "Short subject in local language" body: "Short email body in local language in plain text format" }
|
||||
|
||||
Please start with like "Hi I'm Ken from Cat's AI Ltd"
|
||||
Please make short proposal how generative AI video can help to the museum
|
||||
Please say something specific for the museum or the city
|
||||
Subject should be something like "AI video for museums". 10 words max.
|
||||
Please add in the end this email is generated by AI so please forgive me if something is wrong.
|
||||
|
||||
Please be short and clear
|
||||
Please translate to local language.
|
||||
Please include these sample videos to the email
|
||||
https://www.youtube.com/watch?v=bfYzRBJEI7A
|
||||
https://www.youtube.com/watch?v=XLI1oyy3TF0
|
||||
https://www.youtube.com/watch?v=fX4BnZaDCxg`;
|
||||
}/* else if (emailCount === 1) {
|
||||
prompt = `Generate a follow-up email for customer ${customer.name} from ${customer.url}.
|
||||
This is the second contact with them. The email should reference a previous welcome email and provide more value.
|
||||
@ -75,11 +86,11 @@ async function generateEmailContent(
|
||||
{
|
||||
model: model,
|
||||
messages: [
|
||||
{ role: 'system', content: 'You are an expert email copywriter who creates engaging, professional emails.' },
|
||||
{ role: 'system', content: 'You are an expert email copywriter who creates engaging, professional emails. Output should be only JSON' },
|
||||
{ role: 'user', content: prompt }
|
||||
],
|
||||
temperature: temperature,
|
||||
max_tokens: 1000
|
||||
max_tokens: 500
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
@ -115,8 +126,8 @@ async function generateEmailContent(
|
||||
|
||||
// Fallback content
|
||||
return {
|
||||
subject: `Update from Our Company - Contact #${emailCount + 1}`,
|
||||
body: `<h1>Hello ${customer.name}!</h1><p>Thank you for your continued interest in our services. We appreciate your business.</p>`
|
||||
subject: `Enhance Engagement with AI-Powered Video`,
|
||||
body: `Hi\n\nI'm Ken from Cat's AI Ltd.\n\nWe help museums like yours create engaging video content using cutting-edge generative AI. Imagine bringing historical artifacts to life, creating immersive virtual tours, or developing captivating educational videos – all without extensive production costs.\n\nGiven the rich cultural landscape of the USA and Default Museum’s important role within it, we believe AI video could significantly boost visitor engagement and online reach.\n\nHere are a few examples of what's possible:\nhttps://www.youtube.com/watch?v=bfYzRBJEI7A\nhttps://www.youtube.com/watch?v=XLI1oyy3TF0\nhttps://www.youtube.com/watch?v=fX4BnZaDCxg\n\nWould you be open to a quick chat about how AI video can benefit Default Museum?\n\nBest regards,\nKen (Cat's AI Ltd)`
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
@ -128,8 +139,8 @@ async function generateEmailContent(
|
||||
|
||||
// Fallback content in case of API error
|
||||
return {
|
||||
subject: `Important Update - Contact #${emailCount + 1}`,
|
||||
body: `<h1>Hello ${customer.name}!</h1><p>Thank you for your interest in our services. We look forward to working with you!</p>`
|
||||
subject: `Enhance Engagement with AI-Powered Video`,
|
||||
body: `Hi\n\nI'm Ken from Cat's AI Ltd.\n\nWe help museums like yours create engaging video content using cutting-edge generative AI. Imagine bringing historical artifacts to life, creating immersive virtual tours, or developing captivating educational videos – all without extensive production costs.\n\nGiven the rich cultural landscape of the USA and Default Museum’s important role within it, we believe AI video could significantly boost visitor engagement and online reach.\n\nHere are a few examples of what's possible:\nhttps://www.youtube.com/watch?v=bfYzRBJEI7A\nhttps://www.youtube.com/watch?v=XLI1oyy3TF0\nhttps://www.youtube.com/watch?v=fX4BnZaDCxg\n\nWould you be open to a quick chat about how AI video can benefit Default Museum?\n\nBest regards,\nKen (Cat's AI Ltd)`
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -154,7 +165,9 @@ async function main() {
|
||||
'contact.customerId = customer.id AND contact.contactType = :contactType',
|
||||
{ contactType: 'EMAIL' }
|
||||
)
|
||||
.where('contact.id IS NULL');
|
||||
.where('contact.id IS NULL')
|
||||
.andWhere('customer.email IS NOT NULL')
|
||||
.andWhere('customer.email != :emptyEmail', { emptyEmail: '' });
|
||||
} else {
|
||||
// Find customers with exactly N email contact records
|
||||
customersQuery = customersQuery
|
||||
@ -164,6 +177,8 @@ async function main() {
|
||||
'contact.customerId = customer.id AND contact.contactType = :contactType',
|
||||
{ contactType: 'EMAIL' }
|
||||
)
|
||||
.where('customer.email IS NOT NULL')
|
||||
.andWhere('customer.email != :emptyEmail', { emptyEmail: '' })
|
||||
.groupBy('customer.id')
|
||||
.having('COUNT(contact.id) = :count', { count: emailCount });
|
||||
}
|
||||
@ -209,7 +224,6 @@ async function main() {
|
||||
customer.id,
|
||||
emailContent.subject,
|
||||
emailContent.body.replace(/<[^>]*>/g, ''), // Plain text version (strip HTML)
|
||||
emailContent.body // HTML version
|
||||
);
|
||||
|
||||
if (result.success) {
|
||||
|
||||
Reference in New Issue
Block a user