Get the FREE Ultimate OpenClaw Setup Guide →
v

SmartRoute - Google Routes Calculator

Verified

@vemec

npx machina-cli add skill @vemec/smart-route --openclaw
Files (1)
SKILL.md
3.0 KB

Google Routes Calculator

Get real-time traffic and routing information via Google Routes API (v2).

When to use

Use this skill immediately when the user asks:

  • "How is the traffic to X?"
  • "How long does it take to drive to Y?"
  • "Give me the route to Z."
  • "What's the distance between A and B?"

Usage

This skill executes a Node.js script. It requires an API Key with "Routes API" enabled.

Command

node skills/smart-route/scripts/get_route.js --origin "Origin Address" --destination "Destination Address" [--mode DRIVE|BICYCLE|WALK]

Output Format

The script returns a JSON object:

{
  "origin": "Union Square, San Francisco, CA",
  "destination": "Golden Gate Bridge, San Francisco, CA",
  "mode": "DRIVE",
  "duration": "30 min",
  "distance": "13.5 km",
  "traffic_duration_seconds": 1835,
  "route_link": "https://www.google.com/maps/dir/?api=1&origin=...&destination=...&travelmode=driving"
}

Examples

  • Check traffic in San Francisco: node skills/smart-route/scripts/get_route.js --origin "Union Square, San Francisco, CA" --destination "Golden Gate Bridge, San Francisco, CA"

  • Drive time in Los Angeles: node skills/smart-route/scripts/get_route.js --origin "Los Angeles, CA" --destination "Santa Monica, CA" --mode DRIVE

Configuration

Privacy & Security

  • Scope: This skill only communicates with routes.googleapis.com.
  • Data Handling:
    • It does not read local files or other environment variables besides the ones specified below.
    • PII Notice: User-supplied origin and destination addresses are sent to Google Routes API and printed to stdout in the JSON response. Users should consider these addresses as potentially sensitive information (PII).
  • Credentials: API keys must be provided via environment variables. Providing keys via CLI flags is disabled for security reasons (to avoid exposing secrets in process lists).

API Credentials

This skill requires a Google Cloud API Key with the Routes API enabled.

  • Variable: GOOGLE_ROUTES_API_KEY
  • Detection: The skill will check for this environment variable at runtime.
  • Strict Mode: If the variable is missing, the script will exit with an error rather than falling back to other keys, ensuring no accidental usage of incorrect credentials.

Setup Instructions

  1. Open the Google Cloud Console.
  2. Enable the Routes API for your project.
  3. Generate an API Key under Credentials.
  4. Export the key to your environment:
    export GOOGLE_ROUTES_API_KEY="your_api_key_here"
    

Source

git clone https://clawhub.ai/vemec/smart-routeView on GitHub

Overview

SmartRoute uses Google Routes API to fetch real-time, traffic-aware routes, travel times, and distances between two locations. It returns core details like origin, destination, mode, duration, distance, and a Google Maps navigation link, helping users decide the fastest path. Ideal for questions like 'traffic to X', 'how long it takes to get to Y', or 'best route to Z'.

How This Skill Works

A Node.js script queries routes.googleapis.com with origin and destination and an optional mode (DRIVE|BICYCLE|WALK). It requires a Google Cloud API key with Routes API enabled and outputs a JSON object that includes duration, distance, traffic_duration_seconds, and a route_link for quick navigation.

When to Use It

  • When the user asks for current traffic to a location
  • When asked how long it takes to drive to a destination
  • When needing the best route to a place
  • When comparing distances between two points
  • When a drive-time estimate with a shareable map link is required

Quick Start

  1. Step 1: Ensure the API key GOOGLE_ROUTES_API_KEY is exported in your environment
  2. Step 2: Run the script with origin and destination, e.g., node skills/smart-route/scripts/get_route.js --origin "Origin Address" --destination "Destination Address" [--mode DRIVE|BICYCLE|WALK]
  3. Step 3: Read the JSON output for duration, distance, and route_link

Best Practices

  • Confirm that GOOGLE_ROUTES_API_KEY is set in the environment and the Routes API is enabled
  • Provide clear origin and destination strings (addresses or place names)
  • Specify travel mode if needed (DRIVE by default; use WALK or BICYCLE as appropriate)
  • Leverage the route_link in outputs for quick navigation in Google Maps
  • Treat origin/destination as potentially sensitive PII and handle outputs accordingly

Example Use Cases

  • Check traffic in San Francisco: origin 'Union Square, San Francisco, CA' to destination 'Golden Gate Bridge, San Francisco, CA'
  • Drive time in Los Angeles: origin 'Los Angeles, CA' to destination 'Santa Monica, CA' with mode DRIVE
  • Find a route to a landmark: origin 'Times Square, New York, NY' destination 'Central Park, New York, NY' via DRIVE
  • Distance check: origin 'Union Station, Washington DC' destination 'National Mall, Washington DC'
  • Walk route: origin 'Brooklyn Bridge' destination 'Wall Street, NY' with mode WALK

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers