Skip to main content

Setting Up Notification Environments

In Ductape, you can set up credentials for each Environment. This means your sandbox, staging, and production environments can have different credentials, channels, and optionally exclude certain behavior from specific environments.

Example: Creating a Notification Environment

await ductape.notifications.create({
name: "Notify Users",
tag: "notify-users",
description: "Create Notifications",
envs: [
{
slug: 'prd',
push_notifications,
callbacks,
emails,
sms
},
{
slug: 'snd',
push_notifications,
callbacks,
emails,
sms
}
]
});

Notification Credential Interfaces

Push Notifications

FieldTypeRequiredDescription
typeNotifiers.EXPO or Notifiers.FIREBASEYesType of push notifier.
credentialsobjectOptional for Expo, Required for FirebaseFirebase service account details.
databaseUrlstringRequired for FirebaseFirebase realtime database URL.

Expo Example

const push_notifications = {
type: Notifiers.EXPO
};

Firebase Example

const push_notifications = {
type: Notifiers.FIREBASE,
credentials: {
type: "service_account",
project_id: "...",
// other service account fields
},
databaseUrl: "https://project.firebaseio.com"
};

Email Notifications

Ductape supports 5 email providers: SMTP, SendGrid, Mailgun, Postmark, and Brevo. Configure them by setting the provider field and providing the corresponding provider configuration.

Configuration Structure

FieldTypeRequiredDescription
providerEmailProviderYesEmail service provider (smtp, sendgrid, etc.).
smtpobjectWhen provider is 'smtp'SMTP configuration.
sendgridobjectWhen provider is 'sendgrid'SendGrid configuration.
mailgunobjectWhen provider is 'mailgun'Mailgun configuration.
postmarkobjectWhen provider is 'postmark'Postmark configuration.
brevoobjectWhen provider is 'brevo'Brevo configuration.

SMTP Configuration

FieldTypeRequiredDescription
smtp.hoststringYesSMTP server host.
smtp.portstringYesSMTP port.
smtp.sender_emailstringYesFrom email address.
smtp.auth.userstringYesSMTP auth username.
smtp.auth.passstringYesSMTP auth password.
smtp.securebooleanOptionalUse SSL/TLS.
smtp.tlsobjectOptionalTLS configuration.

SMTP Example

const emails = {
provider: 'smtp',
smtp: {
host: 'smtp.elasticemail.com',
port: '2524',
sender_email: 'noreply@ductape.app',
auth: {
user: 'fikayo@ductape.app',
pass: '***'
},
secure: false,
tls: {
rejectUnauthorized: false
}
}
};

SendGrid Configuration

FieldTypeRequiredDescription
sendgrid.apiKeystringYesSendGrid API key.
sendgrid.sender_emailstringYesFrom email address.

SendGrid Example

const emails = {
provider: 'sendgrid',
sendgrid: {
apiKey: 'SG.xxxxxxxxxxxxxxxxxxxxx',
sender_email: 'noreply@ductape.app'
}
};

Mailgun Configuration

FieldTypeRequiredDescription
mailgun.apiKeystringYesMailgun API key.
mailgun.domainstringYesMailgun domain.
mailgun.sender_emailstringYesFrom email address.
mailgun.regionstringOptional'us' or 'eu' (default: 'us').

Mailgun Example

const emails = {
provider: 'mailgun',
mailgun: {
apiKey: 'key-xxxxxxxxxxxxxxxxxxxxx',
domain: 'mg.ductape.app',
sender_email: 'noreply@ductape.app',
region: 'eu' // Optional - for EU region
}
};

Postmark Configuration

FieldTypeRequiredDescription
postmark.serverTokenstringYesPostmark server token.
postmark.sender_emailstringYesFrom email address.

Postmark Example

const emails = {
provider: 'postmark',
postmark: {
serverToken: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
sender_email: 'noreply@ductape.app'
}
};

Brevo Configuration

FieldTypeRequiredDescription
brevo.apiKeystringYesBrevo API key.
brevo.sender_emailstringYesFrom email address.
brevo.sender_namestringOptionalSender display name.

Brevo Example

const emails = {
provider: 'brevo',
brevo: {
apiKey: 'xkeysib-xxxxxxxxxxxxxxxxxxxxx',
sender_email: 'noreply@ductape.app',
sender_name: 'Ductape Notifications'
}
};

EmailProvider Enum Values

Enum ValueDescription
smtpTraditional SMTP email server
sendgridSendGrid email service
mailgunMailgun email service
postmarkPostmark email service
brevoBrevo (formerly Sendinblue) service

Callback Notifications

FieldTypeRequiredDescription
urlstringYesCallback URL (use :param for dynamic segments).
methodHttpMethodsYesHTTP method.
auth.headersobjectOptionalKey-value headers.
auth.bodyobjectOptionalKey-value body values.
auth.queryobjectOptionalQuery parameters.
auth.paramsobjectOptionalURL params.

Example

const callbacks = {
url: 'https://test.apicall.com/send-message',
method: HttpMethods.POST,
auth: {
headers: { Authorization: "Bearer token" },
body: {},
query: {},
params: {}
}
};

SMS Notifications

Ductape supports 3 SMS providers: Twilio, Plivo, and Vonage (Nexmo). You configure them by setting the appropriate fields based on the provider.

FieldTypeRequiredDescription
providerSmsProviderYesSMS service provider.
accountSidstringFor TwilioTwilio Account SID.
authTokenstringFor TwilioTwilio Auth Token.
apiSecretstringFor NexmoNexmo API Secret.
apiKeystringFor Plivo/NexmoAPI Key for provider.
senderstringYesSender phone number or ID.

Example

const sms = {
provider: 'twilio',
accountSid: 'ACxxxxxxxxxx',
authToken: 'xxxxxxxx',
sender: '+1415xxxxxxx'
};

SmsProvider Enum Values

Enum ValueDescription
twilioTwilio SMS service
nexmoNexmo (Vonage) SMS service
plivoPlivo SMS service

Notes

  • You can configure one or all notification channels in each environment.
  • Push Notifications support only one type per environment either Expo or Firebase.
  • SMS providers require specific credential fields ensure you supply what's needed based on your chosen provider.

Next Steps