Mustafa.
Back to all projects

Urla Shoes — Route safety with Google Maps, OpenWeather, and Salesforce Einstein

A live demo combining three external integrations to plan a route, fetch weather along five waypoints, and let an Einstein Prompt Template (GPT-4o mini) decide whether the journey is safe.

Year
2024
Role
Salesforce Developer
Tech stack
Apex (Queueable)Lightning Web ComponentsVisualforce (bridge)Salesforce EinsteinPrompt TemplatesConnectApi.EinsteinLLMNamed CredentialsRemote Site Settings

Highlights

  • Three external APIs composed in a single user flow
  • Five-waypoint parallel weather fetch via Promise.all
  • GPT-4o mini reasoning via Einstein Prompt Template — output coloured red/amber/green by keyword classifier
  • postMessage bridge between LWC and Visualforce to bypass Lightning Web Security for Google Maps
  • Queueable Apex with full HttpCalloutMock test coverage on the secondary nationalization feature

The problem

Sales reps and field technicians in logistics-heavy industries plan routes on the day. Weather and conditions vary along the path, not just at the destination, and a single 'it's sunny in Frankfurt' check fails when the midpoint is hailing. Combining route geometry, multi-waypoint weather, and a judgement call into a Salesforce-native experience is the kind of multi-system composition that breaks naïve trigger-and-callout patterns.

Architecture

The routeWeather LWC is the orchestrator. It hosts a Visualforce page in an iframe (the only way to load Google Maps under Lightning Web Security) and communicates via postMessage: the LWC sends DRAW_ROUTE, the page responds with ROUTE_DONE plus the destination coordinates. The LWC then computes five waypoints (origin, 25 %, midpoint, 75 %, destination) and fires five parallel fetches to OpenWeatherMap via Promise.all. Once weather lands, the LWC POSTs a slim six-field-per-waypoint payload to the Apex RouteWeatherAnalysisService, which formats the data as text and invokes ConnectApi.EinsteinLLM.generateMessagesForPromptTemplate('RouteWeatherAnalysis', input). The GPT-4o mini response is rendered in a colour-coded card based on a keyword classifier (storm / ice / hazard → red; caution / careful → amber; otherwise green).

The approach

Three lessons drove the design. First, the LWC stays in charge of the user-facing flow so weather cards render before the AI verdict — graceful degradation if Einstein times out. Second, payloads are minimised: only six fields per waypoint cross the Apex boundary, keeping heap and serialisation cost low. Third, the secondary Nationalize.io feature on Contact insert is intentionally separated into a Queueable with Database.AllowsCallouts — bulk-safe, mocked end-to-end (success, empty array, HTTP 500, missing FirstName, ten-record bulk insert, parser unit test), and chosen over a synchronous trigger callout precisely because the demo is meant to be a reference implementation.

The outcome

A single screen where a rep types a destination and gets three layers of decision support: the route, the weather along the route, and an AI safety verdict — all running inside Salesforce, all using platform-native AI without leaving the Trust Layer. The same composition pattern transfers directly to fleet management, field service, and delivery scheduling apps the DACH market is full of.

External integrations