const API_URL = 'https://sdk.senso.ai/api/v1';
const API_KEY = 'YOUR_API_KEY';
async function createTemplates() {
try {
// Create a JSON template for product data
const jsonResponse = await fetch(`${API_URL}/templates`, {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Product JSON Template',
text: `{
"product": {
"name": "{{product_name}}",
"summary": "{{summary}}",
"features": {{features}},
"benefits": {{benefits}},
"price_range": "{{price_range}}",
"target_audience": "{{target_audience}}"
}
}`,
output_type: 'json'
})
});
const jsonTemplate = await jsonResponse.json();
console.log('JSON template created:', jsonTemplate.template_id);
// Create a text template for email content
const emailResponse = await fetch(`${API_URL}/templates`, {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Customer Email Template',
text: `Subject: {{subject}}
Dear {{customer_name}},
{{greeting}}
{{main_content}}
Key Points:
{{key_points}}
{{call_to_action}}
Best regards,
{{sender_name}}
{{company_name}}`,
output_type: 'text'
})
});
const emailTemplate = await emailResponse.json();
console.log('Email template created:', emailTemplate.template_id);
} catch (error) {
console.error('Error creating templates:', error);
}
}
createTemplates();