The HTTP connector allows you to send different messages depending on the weather in the customer's location. 

This article only shows one of countless possible scenarios. Build your own creative nurture paths with the HTTP connector in Mapp Engage!

Scenario

You want to send emails to your contacts depending on the temperature in their location - two different email versions for above and below 5 degrees Celsius. Additionally, you want to set a path for when a request fails.

Prerequisites

To follow the scenario, Mapp Engage has to be activated and configured.

"City" has to be available as custom attribute.

A) Set up connection with OpenWeather API.

  1. Go to home.openweathermap.org/users/sign_up and create an account.
  2. You will receive a confirmation email including your API key and details about using the API. The How to Start documentation can also help you with this.
  3. Now you can create a new record in the Credential Store. This will allow Engage to connect to the OpenWeather API. To create this record, you will need the relevant API call and your API key. You can find examples of API calls and the relevant parameters here.

B) Create Whiteboard in Engage

  1. Create an event-based Whiteboard: Automations > Whiteboard NEW > Create > Event-based.
  2. Set the entry event to define when the whiteboard should be triggered. In our example we use Enters Group, and select the group.

    Enters Group is an Event in the Whiteboard. Engage registers this event when a new contact joins a group. This includes contacts added manually, via an automation, or with certain API methods. For more information, see Enters Group (Whiteboard Event).

  3. As a next step, we connect with OpenWeather and send the city where the user lives.
    1. Add the job Send HTTP Request
    2. Select the API connection that you configured in the Credential Store from the drop-down list under Credential Store Record. Select the GET Method and UTF-8 encoding.
    3. Click Add Parameter. OpenWeather uses the "q" parameter for the name of the city.

      1. Use "q" as parameter name.

      2. Select defined value.
      3. Add the value. In this case, the value is a Custom Attribute that defines the city: ${user.CustomAttribute[‘cityName’]}. If you don't have this Custom Attribute defined, see how you can do that here.
      4. Click Save Parameter
      5. Click Apply.

  4. Configure the HTTP Response Body Parser to use the parameter values received from the server. In our example we get the temperature of our contact's city.
    1. Select JSON from the drop-down list.
    2. Click Add Parser. The Parser Settings window opens.
    3. Insert the parsing formula. You will find the Weather fields in the API response here. Our example only uses the temperature ($.main.temp), but there is more detailed weather information that you could get from the site.

      Use the JSONPath Online Evaluator to check the validity of your parser formula.

      1. Copy the example API response from here.
      2. Paste it in the left panel of the online evaluator.
      3. Paste the parameter in the JSONPath Syntax field.
      4. Check results on the right panel.
    4. Add a name for parameter (here: "Temperature"). Click Save Parser

    5. Click Apply.
  5. Add a Multiple Event to differentiate the flow. In our case, there are three different paths. Each of the paths is using the job HTTP Response Received.
    Define the conditions in your paths. 
    1. Path 1: The response from the server was successful (HTTP Response Status range from 200 to 299) and the temperature is above 5 degrees Celsius.
      1. Click Add Event and select HTTP Response Received.
      2. Under HTTP Response Status select Status Range.
      3. Enter Value from: 200, and Value to: 299.
      4. Under HTTP Response Parameter select Specific Parameter.
      5. Click Add Criteria and enter details: Select the Criterion Temperature, the Operator Is Greater Than, and the Value 5. Click Save Criteria
    2. Path 2: The response from the server was successful (HTTP Response Status range from 200 to 299) and the temperature is below 5 degrees Celsius.
      1. Click Add Event and select HTTP Response Received.
      2. Under HTTP Response Status select Status Range.
      3. Enter Value from: 200, and Value to: 299.
      4. Under HTTP Response Parameter select Specific Parameter.
      5. Click Add Criteria and enter details: Select the Criterion Temperature, the Operator Is Less Than, and the Value 5. Click Save Criteria.
    3. Path 3: HTTP Response Status is 404 - failed. It is good practice to prepare a fallback email, in case the connection with the OpenWeather API is not succesful.
      1.  Click Add Path and select HTTP Response Received . 
      2. Under HTTP Response Status select Specific Status and enter Value: 404.
      3. Click Save Criteria.
  6. Add the job Send Email to each path. Now you can select your prepared messages.
  7. Click Apply and activate your Whiteboard. Done!


Related Topics