Testing a personalized message

The templating language Leanplum {{ uses is based on Jinja. This gives you powerful options to customize the text of your messages. However, due to the strict syntax of the language, any typos or other easy-to-miss mistake can lead to errors in your message. It's important to always first test your Jinja by previewing a message on your test device.

Here are two quick ways to test your personalized messages.

Test using an in-app message

The easiest way to test your message is using a Leanplum in-app message because they don't require APNS / GCM to perform the message delivery. Even if you're planning to use your message inside a push notification, we recommend you create a temporary in-app message for more rapid iteration as you write your personalized message with Jinja.

  1. Make sure you have registered your test device.
  2. Run your app on your test device.
  3. In the Message Composer, create an in-app message and choose any template (such as "Alert") and then enter your Jinja message into the Message field.
  4. Click Preview. The message should appear immediately on your test device.
702

📘

If your Jinja message references user attributes, the preview will show the user attributes corresponding to your test device.

Test using the Leanplum API

What if you don't have a Development build? Or if you want to evaluate what the message would say for another user (such as a user in another country/language, or a user with a different set of user attributes)?

A quick option to test the message is with the getVars method of our API.

  1. Follow the steps above to put your Jinja message into a new in-app message. For this example, we'll add the "firstName" and "destinationCity" user attributes.
716
  1. Add a Target for a specific User ID, the user that you are planning to test with.
717
  1. Remove the "Display when" trigger, as additional insurance that this message will never display to a real end user.
712
  1. Click the Start button to start the message.
  2. Get your App ID and Production Key from your Keys & Settings in the dashboard.
  3. In your browser or Postman, construct and send the following API call:
https://www.leanplum.com/api?appId=YOUR_APP_ID&clientKey=YOUR_PRODUCTION_KEY&action=getVars&apiVersion=1.0.6&userId=USER_ID
  1. The API response should contain a JSON object with a nested messages object that includes all messages for this user, including our test message. In this object, under message.text, you should see the rendered personalized content based on this user's data.
"5185286634471424": {
          "vars": {
            "Layout": {
              "Height": 250,
              "Width": 300
            },
            "Accept action": {
              "__name__": ""
            },
            "Message": {
              "Text": "Hey John! Your next trip is to San Diego.",
              "Color": 4278190080
            },
            "__name__": "Center Popup",
            "Accept button": {
              "Text": "OK",
              "Text color": 4278221311,
              "Background color": 4294967295
            },
            "Title": {
              "Text": "Test message",
              "Color": 4278190080
            },
            "Background color": 4294967295,
            "Background image": ""
          },
          "countdown": 86400,
          "whenLimits": {
            "verb": "AND",
            "children": [
              {
                "verb": "limitUser",
                "noun": 1,
                "subject": "times",
                "objects": []
              }
            ]
          },
          "priority": 1000,
          "action": "Center Popup"
        }