A professional-grade custom activity for Salesforce Marketing Cloud Journey Builder that routes contacts based on real-time weather conditions at their location.
- Dynamic Field Selection: Choose any field from your Journey entry data as the location source
- Multiple Location Types: Supports coordinates, ZIP codes, city names, and full addresses
- Smart Geocoding: Automatically converts location data to coordinates using OpenWeatherMap API
- Real-time Weather Data: Fetches current weather conditions for accurate routing decisions
- Configurable Weather Conditions: Set custom weather criteria for journey branching
- Rich Data Output: Returns weather data as journey variables for use in subsequent activities
- Professional UI: Lightning Design System-styled configuration interface
- Robust Error Handling: Comprehensive validation and error management
- SFMC 2025 Compliant: Built according to latest Salesforce Marketing Cloud standards
- Salesforce Marketing Cloud account with Journey Builder
- OpenWeatherMap API key (free at openweathermap.org)
- Hosting platform with HTTPS support (Vercel, Heroku, AWS, etc.)
- Clone or download this repository
- Deploy to your hosting platform
- Set environment variables:
WEATHER_API_KEY=your_openweather_api_key JWT_SIGNING_SECRET=your_secure_jwt_secret
-
Update URLs in config.json:
- Replace
https://your-vercel-app-url.vercel.appwith your deployed application URL
- Replace
-
Create an Installed Package in SFMC:
- Go to Setup β Apps β Installed Packages
- Create New Package
- Add Component β Journey Builder Activity
- Set Endpoint URL to:
https://your-app-url.com/config.json
-
Configure the Activity:
- The activity will appear in Journey Builder under "Custom Activities"
- Drag into your journey and configure location field and weather conditions
- Journey Entry: Contact enters the journey with location data in any supported format
- Field Selection: The activity reads the configured location field from the contact record
- Geocoding: If needed, converts location data to coordinates using OpenWeatherMap's geocoding API
- Weather Check: Fetches current weather data for the coordinates
- Decision Logic: Compares weather conditions against configured criteria
- Journey Routing: Routes contact down "Adverse Weather" or "Good Weather" path
- Data Output: Saves weather details as journey variables for subsequent use
| Type | Format | Examples |
|---|---|---|
| Coordinates | "lat,lng" | "40.7128,-74.0060" |
| ZIP Code | "12345" or "12345-6789" | "10001", "90210" |
| City Name | "City, State" or "City, Country" | "New York, NY", "London, UK" |
| Address | Full street address | "123 Main St, New York, NY" |
The activity can check for these weather conditions:
- Rain: Rain, Drizzle
- Snow: Snow, Sleet
- Storm: Thunderstorm, Severe Weather
- Clear: Clear skies
- Clouds: Cloudy, Overcast
- Custom: Any OpenWeatherMap weather condition
In Journey Builder, configure these settings:
- Location Data Field: Select the field containing location information
- Location Data Type: Specify the format of your location data
- Weather Conditions: Choose which conditions trigger "Adverse Weather" path
The activity returns these variables for use in subsequent activities:
weatherCondition: Main weather condition (e.g., "Rain", "Clear")temperature: Temperature in Celsiushumidity: Humidity percentagedescription: Detailed weather description
- Adverse Weather: Contact has matching adverse weather conditions
- Good Weather: Contact has clear or mild weather conditions
Journey Builder β Custom Activity UI β Server Endpoints β Weather API
β
Configuration
β
Execution Logic
β
Journey Routing
| Endpoint | Method | Purpose |
|---|---|---|
/config.json |
GET | Activity configuration |
/edit.html |
GET | Configuration UI |
/execute |
POST | Execute weather check |
/save |
POST | Save configuration |
/validate |
POST | Validate settings |
/publish |
POST | Publish journey |
/stop |
POST | Stop journey |
- JWT token validation for all execution requests
- Environment variable protection for API keys
- Input validation and sanitization
- Error handling with fallback routing
-
Start the server:
npm start
-
Test endpoints:
# Check configuration curl https://your-app-url.com/config.json # Test execution (requires valid JWT) curl -X POST https://your-app-url.com/execute \ -H "Content-Type: application/json" \ -H "x-jwt-assertion: your-jwt-token" \ -d '{"inArguments":[{"locationField":"New York, NY","locationFieldType":"city"}]}'
- Create a test journey with your custom activity
- Use a test contact with valid location data
- Verify the contact routes correctly based on weather conditions
- Check output variables in subsequent activities
Activity doesn't appear in Journey Builder:
- Check that config.json is accessible at the correct URL
- Verify the Installed Package is properly configured
- Ensure all URLs in config.json match your deployment
Configuration UI doesn't load:
- Check that edit.html is accessible
- Verify HTTPS is enabled on your hosting platform
- Check browser console for JavaScript errors
Weather check fails:
- Verify WEATHER_API_KEY environment variable is set
- Check that location data is in the expected format
- Review server logs for geocoding errors
Journey validation errors:
- Ensure location field and type are configured
- Check that environment variables are properly set
- Verify all required endpoints are responding
Enable debug logging by checking server logs during execution. All endpoints log request bodies and responses for troubleshooting.
| Variable | Required | Description |
|---|---|---|
WEATHER_API_KEY |
Yes | OpenWeatherMap API key |
JWT_SIGNING_SECRET |
Yes | Secret for JWT token validation |
NODE_ENV |
No | Environment (development/production) |
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
MIT License - see LICENSE file for details.
For questions or issues:
- Check this README and troubleshooting section
- Review Salesforce Marketing Cloud documentation
- Open an issue on the GitHub repository
- Contact your Salesforce administrator
- Salesforce Marketing Cloud Journey Builder Documentation
- Custom Activities Development Guide
- OpenWeatherMap API Documentation
- Lightning Design System
Built with β€οΈ for Salesforce Marketing Cloud