Overview

Push Notifications

Send push notifications from Bento to your iOS app, your Android app, and your website. Write a campaign once and Bento delivers it to every device that has notifications turned on. You can also send pushes from a Flow, or one at a time from your backend with the API.

Before you start

  • Bento Chat on your plan. Push runs on Bento Chat, the $30 per month add-on to Marketing Platform. Add it from pricing.
  • An approved account. Push opens once your account is approved for sending.
  • Administrator access. Only administrators can open Marketing > Push.
  • Somewhere to add code. A website you can add two scripts and one file to, or a mobile app and a backend you control.

How it works

Every push setup has the same three parts:

  1. Connect an app in Bento. Go to Marketing > Push > Apps and choose Set up push. You add a key from Apple, a key from Firebase, or let Bento create keys for your website. Bento checks each key when you save it.
  2. Register devices. Your website or app tells Bento about each device that turns on notifications, and which person it belongs to. Websites do this with Bento's script. Mobile apps send the device to your own backend, and your backend sends it to Bento.
  3. Send. Send a campaign, add a Send push notification step to a Flow, or call the send API.

The setup guide in Bento walks you through these steps: Platform, Create a key, Add credential, Connect your app, and Send a test. It fills your site UUID and keys into every code sample, so you can copy them as they are.

Choose your guide

You are buildingPush serviceGuide
A websiteWeb push. Bento creates the keys.Web push
An iOS app in SwiftApple (APNs), or Firebase if you already use itiOS (APNs)
An Android app in KotlinFirebase (FCM)Android & Firebase (FCM)
React Native or FlutterFirebase for both platforms is simplestAndroid & Firebase (FCM)
ExpoApple (APNs) for iOS and Firebase (FCM) for AndroidAndroid & Firebase (FCM) and iOS (APNs)

You can connect as many apps and websites as you need. A campaign goes out through all of them unless you pick specific ones.

There is no Bento SDK to install in your app. The guides give you copy-paste code for Swift, Kotlin, React Native, Flutter, and Expo, plus a small backend example.

The Apps list

Marketing > Push > Apps lists each app and website you have connected, with its push service, environment, status, and number of devices.

StatusWhat it means
WorkingBento checked the key and can send with it.
Not checkedBento hasn't checked the key yet. Choose Check connection.
Not workingThe key was rejected. Open the app to see the problem, then choose Edit to fix it.

Deleting an app stops notifications to every device registered with it. This can't be undone.

Send a campaign

  1. Go to Marketing > Push > Campaigns and choose New campaign.
  2. Under Campaign, give it a name. Only your team sees it.
  3. Under Notification, write the Title and Message. You can add a Subtitle, an Image, a link under Opens, up to 3 Buttons, and Custom data for your app. Use the iOS, Android, and web tabs to change the content for one platform.
  4. Under Audience, choose Everyone subscribed or a segment. Then choose which devices get it: The device they used most recently, or All their devices.
  5. Under Pacing, set the Batch size and Time between batches. Smaller batches spread the traffic to your app over a longer time.
  6. Choose Save draft, then Send a test to send it to your own device by email address.
  7. Choose Send or schedule, then Send now or Schedule.

While a campaign is sending you can Pause and Resume it. The report shows the audience, how many were sent, devices reached, open rate, button taps, and failures, with tabs for Batches, Platforms, Taps, and Delivery.

Only people who turned on notifications get a campaign. A segment can include people without a device. Bento skips them, so the number of people sent to can be lower than the segment count.

Campaign text is sent exactly as you write it. To personalize a push with Liquid, such as the person's first name, send it from a Flow or the API.
FieldLimit
Title and subtitle200 characters
Message2,000 characters
Link and image URL2,048 characters. Images must use https.
ButtonsUp to 3, with titles up to 40 characters
Custom dataUp to 50 keys, with text values
Keep trying for1 minute to 28 days. The default is 1 day.

Send from a Flow

Add the Send push notification step to any Flow, such as after a purchase, a sign-up, or an abandoned cart.

  • Write the notification the same way as a campaign. Liquid works here, for example {{ visitor.first_name }}.
  • Under Devices per person, choose Most recently used device or All opted-in devices.
  • If the person has no device with notifications turned on, Bento skips the step and the Flow continues.

To reach people who haven't turned on notifications, add a condition before the step that checks for the $push_subscribed event, and send everyone else an email.

Send from your backend

For one-to-one messages such as "Your order has shipped", call the send API from your server. Bento finds the person by email, picks their devices, and delivers the push.

Shell
curl -X POST "https://app.bentonow.com/api/v1/push/send?site_uuid=YOUR_SITE_UUID" \
  -u "YOUR_PUBLISHABLE_KEY:YOUR_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "title": "Your order has shipped",
    "body": "Hi {{ visitor.first_name }}, it is on the way.",
    "url": "https://acme.com/orders/1042",
    "idempotency_key": "order-1042-shipped"
  }'

Send the same idempotency_key when you retry, and Bento sends the push only once. See the Push API reference for every field.

Register devices from mobile apps

Websites register browsers with Bento's script, so this section is for mobile apps.

Your app sends its push token to your backend. Your backend adds the person's email, the Credential ID from the Connect your app step, and your API keys, then calls Bento. Call it every time the app starts, gets a new token, or sees a permission change. Repeat calls are safe.

Registering a device needs your secret API key. Call Bento from your backend, never from inside your app.
Shell
curl -X POST "https://app.bentonow.com/api/v1/push/devices?site_uuid=YOUR_SITE_UUID" \
  -u "YOUR_PUBLISHABLE_KEY:YOUR_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "credential_id": 3,
    "installation_id": "9F2C6E1A-4B7D-4E5A-9C3B-2D8F1A6E7B40",
    "token": "a1b2c3d4e5f6...",
    "platform": "ios",
    "permission": "granted"
  }'

If the email is new to Bento, registering the device adds the person, so you don't need a separate step. When someone logs out, remove their device so they stop getting pushes meant for that account. See Register A Device and Remove A Device.

Backend example

This Express 5 example gives your app three routes of its own. The app calls them with its usual login session, and the backend adds the Bento keys and credential ID. The iOS and Android guides send their requests to these routes.

JavaScript
const express = require('express');

const app = express();
app.use(express.json());

const SITE_UUID = 'YOUR_SITE_UUID';
const BENTO_AUTH =
  'Basic ' +
  Buffer.from(`${process.env.BENTO_PUBLISHABLE_KEY}:${process.env.BENTO_SECRET_KEY}`).toString('base64');

async function bentoPush(method, path, { query = {}, body } = {}) {
  const url = new URL(`https://app.bentonow.com/api/v1/push/${path}`);
  url.search = new URLSearchParams({ site_uuid: SITE_UUID, ...query });

  const response = await fetch(url, {
    method,
    headers: {
      Authorization: BENTO_AUTH,
      'Content-Type': 'application/json',
      'User-Agent': 'MyApp/1.0',
    },
    body: body && JSON.stringify(body),
  });

  if (response.status === 204) return null;
  const json = await response.json();
  if (!response.ok) {
    // 503 means push is briefly unavailable: retry later.
    throw Object.assign(new Error(json.error), { status: response.status });
  }
  return json;
}

// Use the credential IDs Bento shows in Marketing > Push > Apps.
// If you send to iOS through FCM, return the FCM credential ID for both platforms.
function credentialIdFor({ platform, apns_environment }) {
  if (platform === 'android') return Number(process.env.BENTO_FCM_CREDENTIAL_ID);
  return apns_environment === 'sandbox'
    ? Number(process.env.BENTO_APNS_SANDBOX_CREDENTIAL_ID)
    : Number(process.env.BENTO_APNS_PRODUCTION_CREDENTIAL_ID);
}

// requireUser is your own auth middleware that sets req.user.
app.post('/me/push-device', requireUser, async (req, res) => {
  const { installation_id, token, platform, permission, app_version, os_version, locale, timezone } = req.body;

  await bentoPush('POST', 'devices', {
    body: {
      email: req.user.email,
      credential_id: credentialIdFor(req.body),
      installation_id,
      token,
      platform,
      permission,
      app_version,
      os_version,
      locale,
      timezone,
      last_seen_at: new Date().toISOString(),
    },
  });
  res.sendStatus(204);
});

app.delete('/me/push-device', requireUser, async (req, res) => {
  await bentoPush('DELETE', 'devices', {
    query: {
      credential_id: credentialIdFor(req.query),
      installation_id: req.query.installation_id,
    },
  });
  res.sendStatus(204);
});

app.post('/me/push-opens', requireUser, async (req, res) => {
  await bentoPush('POST', 'opens', { body: { open_token: req.body.open_token } });
  res.sendStatus(204);
});

The iOS app sends apns_environment (sandbox or production) so your backend can pick the matching Apple credential. See Sandbox and production.

Opens

Every notification carries a bento_open_token. When someone taps it, your app or website sends the token to Bento, and Bento records a $push_opened event on the person. The web script does this for you. The mobile guides show the few lines your app needs.

Bento counts an open once per person, even when a campaign reached several of their devices.

Events

Bento records these events on the person. Use them in segments and Flows like any other event.

EventWhen it is recorded
$push_subscribedA device can now receive pushes.
$push_unsubscribedA device can no longer receive pushes, for example because notifications were turned off or the app was uninstalled.
$push_openedThe person tapped a notification or one of its buttons.

Each person's profile also lists their Push devices, with each device's status and when it was last seen. You can remove a device from there.

When a device stops working

Bento stops sending to a device when Apple, Google, or the browser reports that its token is no longer valid, such as after the app is uninstalled. The device's status changes and Bento records $push_unsubscribed. Your app registers a fresh token the next time it opens, so you don't need to clean up anything yourself.

Troubleshooting

ProblemWhat to do
Push doesn't appear in the Marketing menu, or opens Bento Chat insteadAdd Bento Chat to your plan, and make sure your account is approved.
"Only administrators can open Push notifications"Ask an administrator on your team for access.
An app shows Not workingOpen it to see what the push service rejected, then fix the key with Edit.
The test push doesn't arriveThe test finds the person by email. Check that the device was registered with that email, and that notifications are allowed on the device.
422 "Check the subscriber's email address or uuid."Register the device with the person's email or uuid. Bento adds them if they're new.
503 "Push is temporarily unavailable. Try again shortly."Retry the request later.
A campaign reached fewer people than the segmentOnly people with a device that has notifications turned on get a push.

For platform-specific problems, see troubleshooting in the web, iOS, and Android & Firebase guides.

Learn more