Testing a personalized message

The Leanplum Templating Language, based on Jinja, gives you powerful options to customize the text of your messages. However, the flexibility of the syntax means it's also possible to have typos and other easy-to-miss mistakes that can lead to errors in your message. So, it's important to test your Jinja.

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. Be 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.

Note: If your Jinja message references user attributes, they will be 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.
  2. Add a Target for a specific User ID, the user that you are planning to test with.
  3. Remove the "Display when" trigger, as additional insurance that this message will never display to a real end user.
  4. Click the Start button to start the message.
  5. Get your App ID and Production Key from your Keys & Settings in the dashboard.
  6. 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

  7. 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"
            }
    
    

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