import { SirenClient, ProviderCode, RecipientChannel } from '@trysiren/node';
// Initialize using environment variables SIREN_API_KEY (and optional SIREN_ENV)
const client = new SirenClient();
// --- Send a direct message (no template) ---
const directMessageId = await client.message.send({
recipientValue: '[email protected]',
channel: RecipientChannel.EMAIL,
body: 'Your account has been successfully verified. You can now access all features.'
});
console.log('Sent direct message:', directMessageId);
// --- Send a message using a template ---
const templatedMessageId = await client.message.send({
recipientValue: 'U01UBCD06BB',
channel: RecipientChannel.SLACK,
templateName: 'welcome_template',
templateVariables: { user_name: 'John' }
});
console.log('Sent template message:', templatedMessageId);
// --- Send with a specific provider ---
const providerMessageId = await client.message.send({
recipientValue: '[email protected]',
channel: RecipientChannel.EMAIL,
body: 'Your account has been successfully verified.',
providerName: 'email-provider',
providerCode: ProviderCode.EMAIL_SENDGRID
});
console.log('Sent with provider:', providerMessageId);
// --- Send using an awesome template identifier ---
const awesomeMessageId = await client.message.sendAwesomeTemplate({
recipientValue: 'U01UBCD06BB',
channel: RecipientChannel.SLACK,
templateIdentifier: 'awesome-templates/customer-support/escalation_required/official/casual.yaml',
templateVariables: {
ticket_id: '123456',
customer_name: 'John',
issue_summary: 'Payment processing issue',
ticket_url: 'https://support.company.com/ticket/123456',
sender_name: 'Support Team'
},
providerName: 'slack-provider',
providerCode: ProviderCode.SLACK
});
console.log('Sent awesome template:', awesomeMessageId);