Content APIs

Overview

For any successful marketing campaign, one of the key ingredients is the relevance of the campaign goal to the recipient. Content APIs allow you to create campaigns that are personalized dynamically using the data fetched at send time from your recommendations or coupon or other Personalization APIs.

Such targeted, relevant, and timely communication has been proven to have much better engagement and conversion rates when compared to generic campaigns.

As shown in the example below, if a user books a flight, Dynamic Content APIs can be used to send emails to them with offers on hotel accommodation for the destination, keeping in mind the accommodation preferences of the user within a few hours of booking the flight.pic3.png

Such personalized, relevant emails can be used to drive conversion and unlock up-sell and cross-sell opportunities in many scenarios.

Let’s look at another example where a user has left a hotel booking incomplete in their shopping cart while looking for resorts in Bali. In this case, the website where the user has added items to their cart(in this case the hotel room) triggers an email reminding them to complete the transaction, as well as making recommendations about similar hotels for them to choose from. Targeted, contextual, and personalized emails like this are an extremely useful tool for a marketer looking to grow their business.

ContentAPIExample.png

Using Content APIs in MoEngage

Let’s take a look at how MoEngage allows you to have rich, personalized, timely conversations with your customers by creating automated campaigns to address the above-mentioned use case (users viewing the details of a hotel but not making the booking). To do this, you need to follow a three-step process:

  1. Add an API to MoEngage
  2. Create a personalized campaign using the API
  3. Run the campaign

 Picture1.png

Step 1 – Adding the API URL

To set up an API to be used during MoEngage campaigns, do the following:

  1. Navigate to the MoEngage Dashboard > Settings > APIs.
  2. Click on the Content API tab and click ADD.
    The Add Content API window is displayed.
    ContentAPI.png
  3. Add the URL, parameters, and headers of the Content API.
  4. To personalize the parameters, type @ and use the user attributes for personalization.
    For more information, refer to Derived Events & Attributes.
    ContentAPI.gif

Step 2 - Using Content APIs to create Personalized Campaigns

Once the API URL is saved, users can start creating campaigns using any existing content templates with API calls embedded in the content. These campaigns can contain placeholders for different SKUs (in this case, hotels), along with the required formatting, segmentation, and triggering schedules.

Content APIs can be added to the campaigns sent using the following channels:

  1. Push
  2. Email
  3. SMS
 

BETA

Content API is a Beta feature for the Push and SMS channels. If you wish to try out the feature, reach out to support@moenage.com.

Example of Content API

Let's take the example of a case where a marketer wants to use weather-related information to target users in a particular geography for an email campaign. In the example below, a marketer from an e-commerce company wishes to drive sales for the Autumn line of products (scarves, boots, coats, and what have you) the company is promoting in the London region by sending an email campaign. The marketer uses a content API that fetches the weather information for London and uses it in the content section during campaign creation.

PersonalizedContentAPIPreview_copy.png

Step 1: Configure Content API

Here are the steps to configure the Weather Content API.

  1. Go to the following navigation: Settings -> App -> API -> Content API tab.
  2. Click on Add on the top right corner of the screen and the following pop-up appears.Add_Content_API.png
  3. Enter the following details in the popup. For this example, we have used the below-mentioned API to fetch the weather details. The API takes in two parameters the APPID (this is the Application ID of the Weather API we have used which has been hosted on a 3rd party site) and the city name. 
    • API Name: Weather
    • API URL: http://samples.openweathermap.org/data/2.5/weather
    • Once the API Name and URL are entered, the parameters to be passed can be entered.AddingParameters_ContentAPI.png
    • In the example above, the parameters added are the city name and the APPID.
    • The city name can either be static where we enter the name of the city to be passed to the API or this can be personalized and fetched from the user attributes by entering '@' in the Value textbox as shown below.ValueFieldPersonalizartion.png
    • The user's city will be fetched using personalization while sending the campaign(when the user attribute city is chosen using personalization, this is represented as {{UserAttribute['City']}} in the value text field).ValueFieldPersonalized.png
    • Click on save.
  4. Once saved, this Content API gets added to the Content APIs search listing. This content API can now be used during content creation for any campaign.

Note: In this example, we are using the Content API with the static parameter for the city name.

Step 2: Test the Content API

  1. Click on the 'Weather' Content API created in the previous step in the following navigation: Settings -> App -> API -> Content API tab.
  2. At the right end of the listing, there are three options: Edit, View, and Test as shown below.Content_API_Search_Listing.png
  3. Click on the Test icon TestIcon_WOToolTip.pngand the following screen opens up.TestingContentAPI.png
  4. Click on the 'Test' button at the bottom right corner of the screen. This would pass the parameters to the configured ContentAPI and show the generated response as shown below.ContentAPI_Response.png
  5. The JSON response generated for this API is shown below.
    {
        "clouds": {
            "all": 90
        },
        "name": "London",
        "visibility": 10000,
        "sys": {
            "country": "GB",
            "sunset": 1485794875,
            "message": 0.0103,
            "type": 1,
            "id": 5091,
            "sunrise": 1485762037
        },
        "weather": [
            {
                "main": "Drizzle",
                "id": 300,
                "icon": "09d",
                "description": "light intensity drizzle"
            }
        ],
        "coord": {
            "lat": 51.51,
            "lon": -0.13
        },
        "base": "stations",
        "dt": 1485789600,
        "main": {
            "pressure": 1012,
            "temp_min": 279.15,
            "temp_max": 281.15,
            "temp": 280.32,
            "humidity": 81
        },
        "id": 2643743,
        "wind": {
            "speed": 4.1,
            "deg": 80
        },
        "cod": 200
    }

The response contains details such as the description, wind speed, humidity, temperature, visibility, and a description of the weather (light intensity drizzle) in this case. This response can be parsed using JINJA and can be used during content creation as shown in the step below.

Step 3: Use the Content API during campaign creation.

Create a one-time email campaign with the desired target segment and in the content creation step (step 2 of campaign creation), do the following.

  1. Choose the desired template. In the example shown below, an e-commerce template that has product recommendations for the autumn line has been chosen.Step2_ChooseTemplate.png
  2. In the text area, type the desired content. 
  3. For illustration, we have chosen the following sample text for this email campaign.
  4. "The weather is inclement and the forecast for the next few days is <add conteAPIapi call and parse the response to get the description detail from the API>.

    Why venture out for shopping when you can take a look at our top picks for you from the cozy confines of your home?"

  5. Use the following JINJA to invoke the Content API named 'Weather' and parse through its response to get the weather description. 
    {%set weatherAPI = ContentApi.Weather({
     ({"params":{"q":"London,uk","appid":"<app_id>"},
       "static_params":{},"dynamic_params":{},"request_body":{}})
      }) 
     %}
  6. The weatherAPI variable would now contain the JSON response shown above while testing the content API. To get to the description field in this response, use the following code:
    {% for weather in weatherAPI.weather %}
    {{weather.description}}
    {% endfor %} 
  7. Add the product recommendations and other necessary content. Click on 'Preview' in the top right-hand corner of the editor. The preview screen opens up as shown below.BasicPreview.png
  8. Click on the Personalized Tab in the top pane to see the personalized content as shown below. 
  9. Note: We have not added any personalization in this example. However, the content API will be run and the weather information will be fetched and used in the content as can be seen below. In case, there are any user attributes that have been personalized, they will be fetched for a random user chosen from the segment chosen for the campaign. Click here for more details about personalization.ContentAPI_PresonlizedPreview.png
  10. Select the delivery schedules and the goals in the next step of the campaign and publish the campaign.
Was this article helpful?
6 out of 10 found this helpful