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 > Advanced Settings.
  2. Click Content API.
  3. Click +Add Content API. The Add Content API screen pops up.

    ContentAPI.png

  4. Fill in the following details:
    Field Description
    API name Add the name for the content API here.
    Method

    The following methods are supported for Content APIs:

    • GET
    • POST
    • PUT

    Select the HTTP Request method of the content API being configured.

    Note: The POST option will be enabled on request. Please reach out to your CSM or drop an email to support@moengage.com to enable it.

    OAuth

    If the content API being configured supports OAuth, enable this toggle.

    Note: The OAuth option will be enabled on request. Please reach out to your CSM or drop an email to support@moengage.com to enable it.

    URL Add the URL of the Content API to which the request will be sent.
    URL Parameters Add the URL parameters to be passed in the request. Click +KV pair if more than one URL parameter is required.
    Headers Add the Headers to be added to the request. Click +KV pair if more than one header is required.
  5. To personalize the parameters, type @ and use the user attributes for personalization.
    For more information, refer to Derived Events & Attributes.

    Personalization in 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 (Mobile and Web Push)
  2. Email
  3. SMS
  4. On-Site Messaging
  5. In-App
  6. Whatsapp
  7. Connectors

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. Navigate to the Content API settings and configure the API.
  2. We have used the below-mentioned API to fetch the weather details using a weather API. 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.
    • In this example, 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.
    • 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['LastKnownCity']}} in the value text field).Add Content API1.png
    • Click on save.
  3. Once saved, this Content API gets added to the Content API search listing. This content API can now be used during content creation for any campaign.

Note: Content API supports only GET requests.

Step 2: Test the Content API

  1. Click on the Content API created in the search listing of the Content API screen.
  2. Click the Icon.png at the end of the row to view the Test option.

    TestOption.png

  3. Click Test.
  4. Click Test 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. 

    TestContentAPI.gif

    Note: In this example, we are using the Content API with the static parameter for the city name.
  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 12 found this helpful

How can we improve this article?