ابرووا
شروع رایگان
☰ فهرست مستندات · قالب‌ها
به‌زودی. Abrova Push به‌زودی فعال می‌شود. این صفحه توضیح می‌دهد چطور کار خواهد کرد؛ هنوز قابل استفاده نیست.
این صفحه هنوز ترجمه نشده — نسخه‌ی انگلیسی نمایش داده می‌شود. English

Message Templates

Reusable notification templates with {{variable}} placeholders and per-locale overrides. Create / list / update / delete via SDK or REST. Example templates for common industries.

به‌روزرسانی: ۵ آبان ۱۴۰۵

Create reusable notification templates with dynamic variables and localizations. Define a template once, send it many times with different variables.

Overview#

Templates let you define reusable notification content with placeholders for dynamic data. Instead of hardcoding notification text in your backend, create a template once and send it with different variables each time. Templates support localization: store per-locale copy and pick the language with locale when you send.

Dynamic Variables

Use {{variable}} placeholders that get replaced at send time with real data

Localization

Define per-locale title and body; choose the locale per send

Reusable

One template, many sends. Update the template and all future sends use the new content

Variable Syntax#

Use double curly braces to insert dynamic content: {{variableName}} (letters, digits and underscores). Variables are automatically detected from your template's title and body unless you pass an explicit variables array.

Title: Hello {{username}}! Body: Your order #{{orderId}} has been shipped to {{address}}

Detected variables: username, orderId, address.

Case Sensitivity.

Variable names are case-sensitive. {{UserName}} and {{username}} are different variables. If a variable is not provided at send time, the placeholder is left in the text as-is (e.g. {{username}}).

Create a Template#

Node.js SDK

typescript
import { AbrovaPush } from '@abrova/push-node';

const abrovaPush = new AbrovaPush({
  apiKey: 'ab_live_your_api_key',
  serverSecret: 'ab_srv_your_server_secret',
});

const template = await abrovaPush.templates.create({
  name: 'Order Shipped',
  title: 'Order #{{orderId}} Shipped!',
  body: 'Hi {{username}}, your order is on the way to {{address}}.',
  description: 'Sent when an order ships',
});

REST API

bash
curl -X POST "https://push-api.abrova.ir/templates" \
  -H "x-api-key: ab_live_your_api_key" \
  -H "x-server-secret: ab_srv_your_server_secret" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Order Shipped",
    "title": "Order #{{orderId}} Shipped!",
    "body": "Hi {{username}}, your order is on the way to {{address}}.",
    "description": "Sent when an order ships"
  }'

Response

json
{
  "id": "tpl_abc123",
  "name": "Order Shipped",
  "title": "Order #{{orderId}} Shipped!",
  "body": "Hi {{username}}, your order is on the way to {{address}}.",
  "description": "Sent when an order ships",
  "variables": ["orderId", "username", "address"],
  "createdAt": "2024-01-15T10:00:00Z"
}

Send Using a Template#

Pass the template ID and a templateVariables object when sending (any send* / broadcast call). AbrovaPush renders the template server-side and delivers the final notification. A title, body or data you pass in the same request overrides the template's value.

Node.js SDK

typescript
await abrovaPush.push.sendToUser({
  userId: 'user_123',
  templateId: 'tpl_abc123',
  templateVariables: {
    orderId: 'ORD-12345',
    username: 'John',
    address: '123 Main St',
  },
});

REST API

bash
curl -X POST "https://push-api.abrova.ir/push/send-to-user" \
  -H "x-api-key: ab_live_your_api_key" \
  -H "x-server-secret: ab_srv_your_server_secret" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "user_123",
    "templateId": "tpl_abc123",
    "templateVariables": {
      "orderId": "ORD-12345",
      "username": "John",
      "address": "123 Main St"
    }
  }'

Rendered Result

📦
Your Appnow

Order #ORD-12345 Shipped!

Hi John, your order is on the way to 123 Main St.

Localization#

Templates support per-locale overrides. Pass locale in the send request (e.g. "locale": "fa") and AbrovaPush uses the localization stored under that exact key. If locale is omitted or has no match, the default title and body are used. The locale is chosen per request, not per recipient device — send one request per language to reach a mixed audience.

bash
curl -X POST "https://push-api.abrova.ir/templates" \
  -H "x-api-key: ab_live_your_api_key" \
  -H "x-server-secret: ab_srv_your_server_secret" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Order Shipped",
    "title": "Order #{{orderId}} Shipped!",
    "body": "Hi {{username}}, your order is on the way.",
    "localizations": {
      "fa": {
        "title": "سفارش #{{orderId}} ارسال شد!",
        "body": "سلام {{username}}، سفارش شما در راه است."
      },
      "es": {
        "title": "Pedido #{{orderId}} enviado!",
        "body": "Hola {{username}}, tu pedido va en camino."
      }
    }
  }'

Use standard locale codes (en, fa, es, fr, de, etc.) — the key must match the locale you send exactly. The same {{variables}} work across all locales.

Custom Data Payload#

Besides template variables (which control notification text), you can attach a data object that gets delivered alongside the notification. Useful for deep linking, navigation, or passing metadata to your app.

bash
curl -X POST "https://push-api.abrova.ir/push/send-to-user" \
  -H "x-api-key: ab_live_your_api_key" \
  -H "x-server-secret: ab_srv_your_server_secret" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "user_123",
    "templateId": "tpl_abc123",
    "templateVariables": {
      "orderId": "ORD-12345",
      "username": "John"
    },
    "data": {
      "screen": "order_detail",
      "orderId": "ORD-12345",
      "action": "view_tracking"
    }
  }'

The data payload is not rendered in the notification text — it's passed through to your app when the user taps the notification. Use it for routing, deep linking, or storing context. A template can also store a default data object; a data object in the send request replaces it entirely (it is not merged, and variables are not substituted inside data).

Manage Templates#

List Templates (SDK)

typescript
const templates = await abrovaPush.templates.list();

List Templates (REST API)

bash
curl -X GET "https://push-api.abrova.ir/templates" \
  -H "x-api-key: ab_live_your_api_key" \
  -H "x-server-secret: ab_srv_your_server_secret"

Update a Template (SDK)

typescript
const updated = await abrovaPush.templates.update('tpl_abc123', {
  title: 'Your order #{{orderId}} is on the way!',
  body: 'Hi {{username}}, track it here: {{trackingUrl}}',
});

Update a Template (REST API)

bash
curl -X PUT "https://push-api.abrova.ir/templates/tpl_abc123" \
  -H "x-api-key: ab_live_your_api_key" \
  -H "x-server-secret: ab_srv_your_server_secret" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Your order #{{orderId}} is on the way!",
    "body": "Hi {{username}}, track it here: {{trackingUrl}}"
  }'

Delete a Template (SDK)

typescript
await abrovaPush.templates.delete('tpl_abc123');

Delete a Template (REST API)

bash
curl -X DELETE "https://push-api.abrova.ir/templates/tpl_abc123" \
  -H "x-api-key: ab_live_your_api_key" \
  -H "x-server-secret: ab_srv_your_server_secret"
Permanent Deletion.

Deleting a template is permanent. Any service or integration that references this template ID will fail to send notifications until updated with a new template ID.

Example Templates#

Common templates for different industries. Use these as starting points for your own notifications.

Welcome Message

Onboarding

Title: Welcome, {{name}}!

Body: Thanks for joining. Start exploring at {{appUrl}}

Variables: name, appUrl

Order Shipped

Notifications

Title: Order #{{orderId}} shipped!

Body: Hi {{username}}, your package is on the way to {{address}}.

Variables: orderId, username, address

Payment Received

Billing

Title: Payment of {{amount}} received

Body: Your payment for invoice #{{invoiceId}} was successful.

Variables: amount, invoiceId

Event Reminder

Scheduling

Title: Reminder: {{eventName}} tomorrow

Body: Hi {{userName}}, your meeting with {{hostName}} is at {{time}}.

Variables: eventName, userName, hostName, time

New Assignment

Education

Title: New assignment in {{courseName}}

Body: {{teacherName}} posted "{{assignmentTitle}}". Due: {{dueDate}}

Variables: courseName, teacherName, assignmentTitle, dueDate

Delivery Update

Food Delivery

Title: Your order from {{restaurantName}}

Body: {{driverName}} is on the way! Estimated arrival: {{eta}}

Variables: restaurantName, driverName, eta

Using Templates with Other Services#

AbrovaPush templates work with any service that integrates with the AbrovaPush API. Define the template once and any service can send notifications using it by passing the template ID and variables.

  1. Create a template in AbrovaPush (dashboard or API)
  2. Copy the template ID (e.g. tpl_abc123)
  3. Configure the template ID in your service (e.g. Abrova Chat, your backend)
  4. The service calls AbrovaPush with the template ID + templateVariables (and optional locale) at the right moment
  5. AbrovaPush renders the template, applies localization, and delivers the push notification

Best Practices#

Keep Titles Short

Aim for under 50 characters. Titles get truncated on most devices

Use Descriptive Template Names

Name templates by their purpose ("Order Shipped", "Password Reset") so your team can find them

Always Provide All Variables

Missing variables are left as raw {{placeholders}} in the text. Test your templates with all variables before sending

Add Localizations Early

It's easier to add translations when creating the template than retrofitting later

Use Data Payloads for Navigation

Don't put navigation info in the notification text. Use the data object so your app can route users to the right screen

این صفحه مفید بود؟
گزارش مشکل