Contact Local Weather
Before you start
This use case has some configuration prerequisites. Make sure you review the Set up section of this page before building !
Learning focus points
Display external data in Avonni Dynamic Components
Use HTTP callout actions in flow
Populate components using on-load interactions and flows
Objective
Build a dynamic card on contacts that return the locale weather data on page load
Push the boundaries of your customer 360 knowledge
Solution
This solution uses Avonni Dynamic Components combined with Salesforce flow and HTTP callout action, all built with no code.
Users get a clean and colourful contact card displaying weather and key data.
How It Works (User Perspective)
The user opens the contact record page
The component instantly loads the contact's locale weather data
Dynamic visibility rules ensure the component's appearance reflects the weather, just like a weather app would

Beautiful weather

Nighttime

Strong wind

Storm
What we'll create
1 External service (prerequisite, completely standard configuration)
1 autolaunched Flow with an HTTP action to get the weather API data
1 Dynamic component
With an on-load interaction to ensure the component has all the relevant data upon loading
Set up
Prerequisite: Configure an external service
This use case will leverage the OpenWeather app : https://openweathermap.org/api
External Credential = “how do I authenticate?”
Named Credential = “where am I calling?”
Flow = “what endpoint + parameters?”
Configuration
External credential
Label / Name :
OpenMeteo_NoAuthProtocol =
Custom“Custom” is what Salesforce uses for no-auth / manual headers cases.
Principal
Parameter Name =
NoAuthIdentity =
Named Principal
Named Credential
Label / Name =
OpenMeteoExternal Credential =
OpenMeteo_NoAuth
Create a Permission set named
PS_OpenMeteoAccessto give users accessWith External Credential Principal Access to the
OpenMeteo_NoAuthservice
Build the Autolaunched Flow
Create the GetOpenWeather HTTP Action
Set up an HTTP flow action with the following settings
latitude
Double
45.5017
Yes
Contact.MailingLatitude
Current contact's latitude
longitude
Double
-73.5673
Yes
Contact.MailingLongitude
Current contact's longitude
current
String
comma-separated fields
Static
temperature_2m,apparent_temperature,weather_code,wind_speed_10m,precipitation,rain,showers,is_day
All current weather (now) fields the HTTP request will return. Use those needed for your use case. Output will be a variable of the weather at the time of the request.
daily
String
comma-separated fields
Static
temperature_2m_max,temperature_2m_min,precipitation_probability_max,rain_sum,showers_sum,precipitation_sum,sunrise,sunset,daylight_duration,sunshine_duration
All daily weather fields the HTTP request will return. Use those needed for your use case. Output will be a collection of the next 7 days' weather data.
timezone
String
auto
Static
auto
Timezone of the locale.
Return JSON example
This configuration provides you with extra data for full flexibility in your implementation.
We will not be using everything for this example : the daily configuration is optional.
View the Going furthersection for expanded ideas on this use case.
Assign variables for output
Use an assignment to map output variables that you want to display in the dynamic component
Create and assign output variables and formulas
Assign the action's outputs to variables for easier data management and to transfer them to the dynamic component
Use formulas to create useful booleans
Review the Flow variables table for details.
Flow variables
vCurrentTemp
Number
Current temperature
vCurFeelsLike
Number
Current "feels like" temperature
vCurPrecipitation
Number
Current amount of precipitation (mm)
vCurWindSpeed
Number
Current wind speed (km/h)
vCurStrongWind
Boolean
True if the wind is over a speed threshold (defined in the flow)
vOutCurIsDay
Boolean
True if the API returns that it is currently daytime
Formulas
F_CurStrongWind
Boolean
IF ( {!vCurWindSpeed} > 50 , true, false)
F_IsDay
Boolean
IF ( {!vCurIsDay} = 1, true, false)
Build the Dynamic Component
This arcade only goes through the On-load interaction, an image and visibility rules. View bellow fort he full setup.
Create variables
Create input variables to retrieve data from the flow (names are those used in the example)
Variables should match the flow outputs
Review the Contact Local Weather table for details.
Configure the Header
Add a container in the first slot
In the style tab, set background to
#cfe9fe(or your colour of choice)
Add a Media Object in the container to organize items
Add an Avatar, fields, chip container (tags) and buttons to customize the header
We won't go into details as these components are examples and not critical to the use case.
Navigate to the Going furthersection for guidance about configuration.
Build the image column
Drag a column component into the canvas and divide it into 2 columns
Use the left column to display weather images dynamically, this column will display the main weather image
Drag image components and set visibility rules (use your choice of images as Image Source).
"Sun / Daylight"
Set Visibility rule =
F_MainWeatherIcon=Sun
"Night"
Set Visibility rule =
F_MainWeatherIcon=Moon
"Rain"
Set Visibility rule =
F_MainWeatherIcon=Rain
"Storm"
Set Visibility rule =
F_MainWeatherIcon=Storm
"Wind"
Set Visibility rule =
F_MainWeatherIcon=Wind
Dynamic Component Variables
vCurrentTemp
Number
Current temperature
vCurFeelsLike
Number
Current "feels like" temperature
vCurPrecipitation
Number
Current amount of precipitation (mm)
vCurWindSpeed
Number
Current wind speed (km/h)
vCurStrongWind
Boolean
True if the wind is over a speed threshold (defined in the flow)
vOutCurIsDay
Boolean
True if the API returns that it is currently daytime
Formulas
F_BackgroundColour
Text
IF ( {!vOutCurIsDay} = true , '#1ab9ff' , '#107cad')
Dynamically change the background based on the vOutCurIsDay variable
F_TextColour
Text
IF ( {!vOutCurIsDay} = true , '#ffffff', '#1ab9ff')
Dynamically change the text colour to ensure it is readable with the background
F_MainWeatherIcon
Text
Used for your weather image visibility rules and be based on the variables created in 1
Going further
Ideas
Leverage the daily data returned by the HTTP action you've set up to build a 7 days forecast.
Features
On Load InteractionDynamic components
AvatarButtonChip ContainerImageLast updated
Was this helpful?
