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.
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.
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:
- Add an API to MoEngage
- Create a personalized campaign using the API
- Run the campaign
info |
Information If your endpoints are in a VPC/are not accessible publicly, you must whitelist these MoEngage IPs depending on the region of your Workspace. |
Step 1 – Adding the API URL
To set up an API to be used during MoEngage campaigns, do the following:
- Navigate to the MoEngage Dashboard > Settings > Advanced Settings.
- Click Content API.
- Click +Add Content API. The Add Content API screen pops up.
- 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. Contact your CSM or the MoEngage Support team to enable it.
OAuth If the content API being configured supports OAuth, enable this toggle. To learn more, see FAQs.
Note: The OAuth option will be enabled on request. Contact your CSM or the MoEngage Support team 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. Dynamic values Provide a sample value for the parameters to ensure that the API is set up properly. You can select any user profile or event to populate these values.
- To personalize the parameters, type @ and use the user attributes for personalization.
For more information, refer to Derived Events & Attributes.
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:
For more information on personalizing content using content APIs, refer here.
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.
Step 1: Configure Content API
Here are the steps to configure the Weather Content API.
- Navigate to the Content API settings and configure the API.
- 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).
- Click Update.
- The Edit Content API page opens.
- To mask PII fields select Yes and then choose the preferred field names for which you want to mask the information, and then select Done. you can now mask PII value from Content API output. For more information, see here.
- Once saved, this Content API is added to the Content API search listing. It can now be used to create content for any campaign.
Step 2: Test the Content API
- Click the Content API created in the search listing of the Content API screen.
- Click the
at the end of the row to view the Test option.
- Click Test.
- 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.
Note: In this example, we are using the Content API with the static parameter for the city name. - The JSON response generated for this API is shown below.
"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.
- Choose the desired template. In the example shown below, an e-commerce template that has product recommendations for the autumn line has been chosen.
- In the text area, type the desired content.
- For illustration, we have chosen the following sample text for this email campaign.
-
"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?"
- 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":""}, "static_params":{},"dynamic_params":{},"request_body":{}}) }) %}
- 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 %}
- 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.
- Click on the Personalized Tab in the top pane to see the personalized content as shown below.
- 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.
- Select the delivery schedules and the goals in the next step of the campaign and publish the campaign.
FAQs
In case Content APIs fail owing to an API timeout, MoEngage retries the request. Retries are done up to three times, and the maximum API timeout limit is five seconds.
The total number of users in a campaign is divided into multiple batches, which are processed in parallel. In each of these batches, the API calls are made sequentially.
Example: Consider two campaigns C1 (with a target user segment of 1 Million users) and C2 (with a target user segment of 2 Million users), starting simultaneously. If the batch size is 500, then the total number of batches for both campaigns is (1M+2M)/500, which is 6000 batches. If the maximum number of machines employed for making these API calls is 100 and each machine has 10 processes, then the number of API calls going out in parallel would be 1000. For each batch of 500, the calls would be made sequentially. However, we would make 1000 API calls in parallel at a given time.
info |
Information The batch size and the count for the maximum number of machines in use are different for every channel, and the above example has been used only to explain how MoEngage makes content API calls. |
To enable OAuth, contact your Customer Success Manager or MoEngage Support team. You can create a ticket through the Support Web Form within the MoEngage dashboard. For more information, refer here.
Auth Token service supports Authorisation Code grant type and Client Credential grant type apis.
To learn more, see Application Grant Types.
The apis used above should have exipry time for the token in response. This expiry time can be in seconds, minutes, hours or as exact epoch timestamp.
To contact the MoEngage Support team, you can raise a ticket through the Support Web Form within the MoEngage dashboard. For more information, refer here.