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.product.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

FieldTypeRequiredDescription
hoststringYesSMTP server host.
portstringYesSMTP port.
sender_emailstringYesFrom email address.
auth.userstringYesSMTP auth username.
auth.passstringYesSMTP auth password.
securebooleanYesUse SSL/TLS.

Example

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

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