Enhancing data with current weather information

The targeting of advertisements or messages can be based on external data like weather information. This type of communication with recipients is especially relevant to companies from the medical, fashion, beverage or agricultural industries. By collecting data on cloud cover, air temperature and pressure, we are able to better advertise offered products, arouse customer interest and even strengthen the positive perception of a brand. In the presented example, the targeting of a marketing communication for the fashionn industry will be reinforced with data on the current weather forecast.

Example of use - Fashion Industry

A client from the fashion industry wanted to send marketing communication to their clients at a time when the weather conditions outside change in order to better match the products to customer needs. For this purpose, Synerise had a list of offline stores with their exact locations. The system additionally collected weather data from an external tool and combined it with the location of those physical stores. The marketing communication was directed to customers who belonged to the club and were assigned to a specific POS - therefore, knowing the weather at the POS, it was possible to direct the appropriate communication to customers.

Screenshot presenting pop-upfor fashion industry with weather information
Email with abandoned cart

Requirements


  • Access to the selected weather API that provides the data we need (weather, temperature, other elements that we want to use for our communication).

A CSV file for import with a list of POS stores with:

How to do it


To collect weather information in Synerise, you have to follow 5 important steps.

  1. Import a list of offline stores
  2. Build a segment
  3. Prepare a catalog
  4. Create an automation
  5. updated weather data to the catalog

Import a list of offline stores


To collect weather information for individual stores, you must import it into Synerise. As a result of the import, each POS will be able to use its location (longitude and latitude) to check the weather by API, and post information about it on its card in CRM webhook.response.

Note: If you want to inquire about the weather for individual clients and they have location data (longitude and latitude) in their attributes, you can skip point 1 (import list of POS).

1. Import the list of POS to Synerise


  • POS ID (or another element that is on the customer’s profile in CRM as a value corresponding to the assignment to a given POS),
  • Longitude and latitude,
  • Email address of a given POS - if your offline stores do not have an email address, we will prepare them during the mapping stage,
  • Optionally, elements such as the name of a given POS, city or town may be useful.

2. Import the list of client


Prepared file to Synerise as import Clients according to the manual found at import clients. An example of mapping might look like screen below.

Screenshot presenting clients mapping
Mapping
Explanation

Map the data describing individual stores as custom attributes, creating them using the attributes prefix (attributes.shopAddress). If your file does not contain the email addresses that are necessary for creating users, you can create fictitious addresses at the mapping stage. To do this, create an additional column in our import by clicking Add Column and then, in the template field, as its value enter the Jinjava code - {{ root.Id }} shop@pos.weather.

Note: Id is the name of the column containing the shop id, the column name may differ in your file. Jinjava will make the beginning of the address dynamically added based on the ID column, while the rest of the created address will be the same for each user. As a result, for the shop with the number ID 01, our address will be {{ root.Id }} shop@pos.weather.

After the import is completed, you can find POS profiles on the CRM list. Their latitude and longitude are saved as the attributes, which will be used later

Build a segment


Go to Analytics > Segmentation > New segmentation and then filter out POS by using the constant fragment of their email address - shop@pos.weather.

Screenshot presenting Building a segment
Segment settings
Tip: If this segment is to include customers, not points of sales (POS), you can, for example, use the attribute responsible for longitude and latitude with the value “is true” - then all customers who have this value defined on their profile in CRM.

Prepare a catalog


Go to the Data Management > Catalogs > New Catalog. After creating the catalog, its URL looks as follows: https://app.synerise.com/spa/modules/catalogs/catalogs/1234. The number at the end is your catalog ID, you will need it later.

Tip: Instruction on creating catalogs is available here.

Create an automation


To enrich Synerise data with weather data from an external system, create an automation that looks like this:

`Screenshot presenting prepare Automation
The diagram of the workflow

1. Add the Audience node


  1. Start with the Audience node.
  2. To define how often you want to update the weather data, select the repeatable option (in our example it is every two hours).
  3. Define when your workflow starts.
  4. Select the audience (the segment you created in the Build a segment with your users procedure.
Screenshot presenting prepare Automation
Automation Trigger

2. Add the Outgoing Webhook node


Add the Outgoing Webhook node - this way you download the weather details from the selected system.

  1. Select the Custom webhook tab.
  2. Enter the name in the Action name field - in our case it is get weather.
  3. Select the GET method to download the weather via the API.
  4. Enter the endpoint for getting the specific weather API endpoint you want to use. Information on how to get to the resources of a given API can be found in its documentation.
  5. In the Headers section leave the content-type to default. At this stage, you do not need the body of your request or additional authorization.
Screenshot Custom webhook
Custom webhook configuration step 1
Screenshot Custom webhook
Custom webhook configuration step 2
Explanation

Important: Remember that you will need an API key of a given website that will allow you to authorize yourself. After reading the specific API documentation, your URL will be built from the specific weather API endpoint, your individual API key and query. In our case, the URL looks like this: https: // example endpoint? example API key & q** = **{{customer ['latitude']}}, {{customer ['longitude']}}

The API used in this example defines that in order to inquire about the weather in a given location, the URL should be built with the parameter q = latitude, longitude. Since we want to build the query dynamically (for each POS / user it has to be built according to its location data), we will use Jinjava. The {{ customer['latitude'] }},{{ customer['longitude'] }} element allows you to dynamically retrieve the value of the client’s attribute assigned successively to the ‘latitude’ attribute and then to ‘longitude’. If your attributes are named differently, you should use their names in these places.

Important: Remember that your API documentation should define their order to properly build your query. If you want to base the query on other location data (for example, IP address), you can do it in the same way in accordance with the API documentation.

3. Add the Client Event Filter node


This is a necessary step and thanks to its construction, we wait until the weather API answers us, and the webhook.response event with response parameters will be placed on the profile of a shop in CRM.

  1. Select the webhook.response event.
  2. Select name.
  3. Enter the value of the webhook action name - in our example it is get weather.
Screenshot Custom webhook
Client Event Filter

4. Add the Outgoing Integration node


This webhook will be used to save the gathered information (in this case the weather) to the directory so that the data can be easily used in communication.

  1. Select the Custom webhook tab.
  2. In the Action name field, enter save weather (you can use different name, it’s just an example).
  3. Select POST method
  4. Enter the endpoint.
  5. Leave the content-type to default: application / json.
  6. In the body of the request, paste the Jinjava code:
Check the Jinjava code

 "temp_c": "{{event.params ['body.current.temp_c']}}" 

 For example, the whole thing might look like this: 

 { 

 "value": { 

 "StoreId": "{{ customer['store_id'] }}", 

 "condition_text": "{{ event.params['body.current.condition.text'] }}", 

 "condition_code": "{{ event.params['body.current.condition.code'] }}", 

 "location_name": "{{ event.params['body.location.name'] }}", 

 "last_updated": "{{ event.params['body.current.last_updated'] }}", 

 "temp_c": "{{ event.params['body.current.temp_c'] }}" 

 }, 

 "itemKey": "{{ customer['store_id'] }}" 
 
 

Your node will look like this:

Screenshot presenting enter the API Key
Generate API Key step 1
Screenshot presenting enter the API Key
Generate API Key step 2
Explanation

Here we need to map our API responses to individual columns in our directory. We need to have a POS ID in our catalog for which we ask about the weather, so we build the StoreID column and as its value we will take the value of the store_id attribute assigned to a given customer (our POS), responsible for storing this number. In addition, each of the parameters that we get from our weather API can be saved in our catalog by mapping it to the appropriate column according to the formula below. For example, if in webhook.response you get temp_c with the temperature value for a given POS, you can create such a column and assign its value to webhook.response, which is put in the parameter with the same name.

Important:
  1. Remember that you have to enter your itemKey at the end. In our case, it is the ID of the POS. Also remember that you don’t have to save every bit of information you get from API in your directory - it’s up to you what information you need and what you want to use.
  2. The end of the Outgoing Webhook node when using Synerise API, you need to authorize the API key appropriate for the business profile on which you create the automation. Your API key must have the necessary permissions. You can find more about them here.

5. Set up final settings of automation


  1. Add End nodes where the workflow should finish for customers.
  2. Define capping (here 1 for 1 day).
  3. Optionally, add titles to each node so the workflow will be more understandable to your colleagues.
  4. Name the workflow.
  5. To save it as a draft, click Save it or activate by clicking Save & Run.

Updated weather data to the catalog


As a result, you will receive a catalog with regularly updated weather data for the store which was defined in the audience (for the current example, every 2 hours).

Screenshot presenting catalog
Update weather data in catalog

Read more


This use case belongs to the following categories:

Challenges:

Features:

😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.