New Beta Feature: Linked Data

Thanks for agreeing to be a beta tester for one of our newest features. Your feedback is essential to the continued improvement of the Leanplum Platform.

What it Does

Linked Data allows you to inject automated contextual data stored in other sources, such as your data warehouse or any service provider, into all messaging channels. Linked data can be combined with existing Leanplum user profile data to create highly personalized and relevant message campaigns. The data is pulled down from the source you define and injected into the content of a message at the time it is sent, allowing you to send messages with content such as: top recommended products, weather right now or today’s menu. Linked data is one of our most flexible messaging features we've ever built and is available in beta right now.

Once you have set up and defined your Linked Data sources in the Leanplum App Settings (see Setup section below), you can immediately begin to reference Linked Data information in your messages. We built Linked Data for unlimited flexibility by allowing you to use Jinja-­style syntax to help turn raw data from any source into a useful, human-readable message.

Setup

To get started, you need an API or some other server that returns a JSON response. This can be your own backend, or you could be using a third­party backend. Later in this document, there will be a tutorial that walks you through using a third­party backend.

  1. Define your Linked Data sources by providing the base URLs.
  2. On the Leanplum dashboard, go to Manage Apps > Keys & Settings.
  3. Each Linked Data source has a name and a URL.
  4. The URL may optionally have parameters, which are indicated with {} symbols.
    1. If there are parameters, then these parameters will be filled out when you compose your message in Leanplum.

Here are some example URLs:

  • https://www.quandl.com/api/v3/datasets/YAHOO/INDEX_DJI.json?rows=1
    • This requires no parameters, it always returns the current Dow Jones Industrial Average
  • http://jsonplaceholder.typicode.com/users
    • This also requires no parameters, it returns a list of all users
  • http://jsonplaceholder.typicode.com/users/{}
    • This is an example of using one parameter, which is the ID of the user. This will return a record for that user. E.g., http://jsonplaceholder.typicode.com/users/4 

Add the Linked Data URLs in Leanplum Keys & Settings:

How You Could Use it

As we mentioned earlier, once your Linked Data source is connected to Leanplum, you can use Jinja-style syntax in your message.

For example, suppose the "recommend" Linked Data returns a JSON payload representing the 3 products most recommended for the given user id, such as:

[
{"name": "Bracelet", "sku": 1234, "price": 19.99},
{"name": "Scarf", "sku": 5678, "price": 39.99},
{"name": "Belt", "sku":4501, "price": 24.67}
]

The most basic example is to import the contents of the Linked Data directly into the message. If you want to send a push notification with the contents of the first recommended item:

We think you'll love this {{ linkedData.recommend[userId][0]['name'] }},
on sale for ${{ linkedData.recommend[userId][0]['price'] }}

You can also use Jinja syntax in the Open Action of the push notification, so you can deep link the user to the correct item:

myapp://view_item/{{ linkedData.recommend[userId][0]['sku'] }}

You can leverage Jinja for more sophisticated things, like constructing a For loop that iterates through all the product recommendations, or using an if/else block to make the message conditional on the contents of the Linked Data, such as showing alternate content if there are no product recommendations for that user.

For more details on all of your syntax options, please see the Leanplum Templating Language reference.

Tutorial

We've put together a comprehensive sample tutorial to help you get up and running with Linked Data. Please contact support@leanplum.com with any additional questions.

 


Was this article helpful?
Have more questions? Submit a request