How to use single user notifications?

Scale

More often than not, notifications that are custom crafted for each one of your users will get a much higher engagement. So whether you are sending out custom crafted offers to your users, or you want to build your own user notification center without hassle, single user notifications will be your best bet.So, how can you use Beamer to send out single user notifications? It’s actually pretty simple:

Step 1: Fill in the user_id parameter in your embed script.

While the rest of the parameters containing your user’s personal information (such as user_firstname and user_lastname) remain optional, the only parameter that’s required for single user notifications to work is the user_id.This is simply a string meant to represent your own user’s unique ID. This parameter can have any format whatsoever, as long as you make sure it is an unique identifier for each of your users.Here’s an example of how the embed script could look for a user that’s logged into your platform:<script>
var beamer_config = {
product_id : 'your-product-id',
button_position : 'bottom-right',
user_firstname : 'John',
user_lastname : 'Doe',
user_email : 'john.doe@getbeamer.com',
user_id : '1234'// This should be your app's user ID
};
</script>
<script type="text/javascript" src="https://app.getbeamer.com/js/beamer-embed.js" defer="defer"></script>Great! Now your user will be correctly identified by Beamer. All the user info (it’s ID and all the other fields, if completed) will now show up in your Analytics section so you can see which posts your user has viewed or clicked on, and any of it’s feedbacks and reactions.Let’s now send a notification that will be visible only to this user.

Step 2: Make use of the API to create the notification.

To create notifications in Beamer, you can make use of the /posts endpoint in our API. A POST request to this endpoint will create a notification in the account you are authenticating the request with.

First, we’ll create a JSON object with some example content and an image for the notification:{
"publish": true,
"title": ["This is the title"],
"content": ["This is the post content! It includes an image: https://i.imgut.com/wXWQQAK.png"],
"category": "new",
"filterUserId": "1234"
}
In this step, it’s crucial to make use of filterUserId as described in the API docs. This parameter is matched against the user_id parameter of the embed script. As you would expect, this will create a notification visible only to the user with id ‘1234’.Now, we’ll send this JSON to the /posts endpoint of the API (we’ll use curl in this example):curl --header "Content-Type: application/json" \
--header "Beamer-Api-Key: YOUR-BEAMER-API-KEY" \
--request POST \
--data '{"filterUserId": "1234", "publish:" true, "title":["This is the title!"], "content":["This is the post content! It includes an image: https://i.imgut.com/wXWQQAK.png"]'
https://api.getbeamer.com/v0/posts
It’s important that all requests to the API include your API key in the Beamer-Api-Key header, as unauthenticated requests will be rejected.Since we didn’t schedule this post to be published in a future date, it should be published immediately! If push notifications are enabled in the account, the example user should receive one now.

Push notification example

When opening Beamer in your site, that post should now be visible as well:

Beamer widget example

So that’s it! You’ve just sent a single user notification.Quick recap: Make sure you pass in the user_id parameter to the embed script in your site, and then the filterUserId parameter when creating a post through the API. What’s inside the notification is up to you!

Your Data Security and Privacy is our Priority.

At Beamer, we care about our customers’ data and this is how we protect it.

icons

Data Ownership

Your account and data belongs to you and will not be sold in any case. We can delete your account and data upon your request. Learn more

icons

Encryption

Beamer data is encrypted in transit (advanced TLS protocols and 2,048-bit keys or better) and at rest (using AES 256 encryption with integrity).

icons

Access

Customer data is always backed up and uptime is over 99.9%.

icons

GDPR

Beamer is GDPR Compliant and has the Data Processing Agreements in place. Learn more

icons

Penetration testing

Third party network, application and physical security tests are conducted regularly. Learn more