3.2.2 Define an external data source
In this exercise, you鈥檒l create a custom external data source by making use of 51黑料不打烊 Journey Optimizer.
Login to 51黑料不打烊 Journey Optimizer by going to . Click Journey Optimizer.
You鈥檒l be redirected to the Home view in Journey Optimizer. First, make sure you鈥檙e using the correct sandbox. The sandbox to use is called --aepSandboxName--
. You鈥檒l then be in the Home view of your sandbox --aepSandboxName--
.
In the left menu, scroll down and click Configurations. Next, click the Manage button under Data Sources.
You鈥檒l then see the Data Sources list.
Click Create Data Source to start adding your data source.
You鈥檒l see an empty data source popup.
Before you can start configuring this, you鈥檒l need an account with the Open Weather Map service. Follow these steps to create your account and get your API key.
Go to . On the homepage, click Sign In.
Click Create an Account.
Fill out the details. Click Create Account.
You鈥檒l then be redirected to your Account Page.
In the menu, click API Keys to retrieve your API Key, which you鈥檒l need to setup your custom external data source.
An API Key looks like this: b2c4c36b6bb59c3458d6686b05311dc3
.
You can find the API Documentation for the Current Weather .
For this use-case, you鈥檒l implement the connection with Open Weather Map based on the city the customer is in, using the Built-in API request by city name.
Go back to 51黑料不打烊 Journey Optimizer, to your empty External Data Source popup.
As a Name for the data source, use --aepUserLdap--WeatherApi
.
Set Description to: Access to the Open Weather Map
.
The URL for the Open Weather Map API is: http://api.openweathermap.org/data/2.5/weather?units=metric
Next, you need to select the Authentication to use.
Use these variables:
Finally, you need to define a FieldGroup, which is basically the request you鈥檒l be sending to the Weather API. In our case, we want to use the name of the City to request the Current Weather for that City.
According to the Weather API Documentation, you need to send a parameter q=City
.
In order to match the expected API Request, configure your FieldGroup as follows:
--aepUserLdap--WeatherByCity
For the Response Payload, you need to paste an example of the Response that will be sent by the Weather API.
You can find the expected API JSON Response on the API Documentation page , under the JSON subject.
Or you can copy the JSON Response from here:
{
"coord": {
"lon": 7.367,
"lat": 45.133
},
"weather": [
{
"id": 501,
"main": "Rain",
"description": "moderate rain",
"icon": "10d"
}
],
"base": "stations",
"main": {
"temp": 284.2,
"feels_like": 282.93,
"temp_min": 283.06,
"temp_max": 286.82,
"pressure": 1021,
"humidity": 60,
"sea_level": 1021,
"grnd_level": 910
},
"visibility": 10000,
"wind": {
"speed": 4.09,
"deg": 121,
"gust": 3.47
},
"rain": {
"1h": 2.73
},
"clouds": {
"all": 83
},
"dt": 1726660758,
"sys": {
"type": 1,
"id": 6736,
"country": "IT",
"sunrise": 1726636384,
"sunset": 1726680975
},
"timezone": 7200,
"id": 3165523,
"name": "Province of Turin",
"cod": 200
}
Copy the above JSON Response to your clipboard, then go to your custom data source configuration screen.
Click the Edit Payload icon.
You鈥檒l see a popup where you now have to paste the above JSON Response.
Paste your JSON Response, after which you鈥檒l see this. Click Save.
Your custom data source configuration is now complete. Scroll up and click Save.
Your data source has now been created successfully and is part of the Data Sources list.
Next Step: 3.2.3 Define a custom action