home / skills / openclaw / skills / bvg-route

bvg-route skill

/skills/jaysonsantos/bvg-route

This skill helps you plan Berlin public transport routes using BVG API, returning 2–3 fastest options with step-by-step directions.

npx playbooks add skill openclaw/skills --skill bvg-route

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
3.6 KB
---
name: bvg-route
description: "Route planning for Berlin public transport (BVG) using the v6.bvg.transport.rest API. Use when the user asks for: (1) route suggestions between two addresses or stops, (2) live next-departure info for a stop, (3) arrival-time–based journey planning (arrive-by or depart-at). Supports outputting 2–3 options ranked by travel time, transfers, and walking, and returning step-by-step directions and refresh tokens for live updates."
---

# BVG Route Planner Skill

Purpose
- Provide concise, actionable public-transport directions in Berlin using the v6.bvg.transport.rest API.

When to use
- User asks for directions between two places in Berlin (addresses, stop names, or coordinates).
- User asks for next departures from a stop/station.
- User requests to arrive by a specific time (arrive-by) or depart at a specific time.

Core behavior
1. Resolve `from` and `to` into either stop IDs (preferred) or address/POI objects using GET /locations or /locations/nearby.
2. Call GET /journeys with arrival or departure parameter as requested, request results=3 and stopovers=true to construct step-by-step legs.
3. Format 2–3 options: show total travel time, number of transfers, walking time, and estimated departure/arrival times.
4. Provide step-by-step instructions for the selected journey: walk to stop A (distance/time), take line X toward Y, get off at stop B (platform if available), final walk to destination.
5. When appropriate, include the journey refreshToken and a GET /journeys/:ref refresh step to update realtime delays.
6. For simple next-departure queries, use GET /stops/:id/departures with duration=20 (or configurable) and return the nearest 3 departures.

Outputs
- Human-readable routes with departure times, transfers, walking distances, estimated arrival, and concise step list.
- Machine-friendly JSON (optional) containing journey id, refreshToken, legs, and stop IDs for programmatic refreshes.

References
- The skill expects to use the v6.bvg.transport.rest API (https://v6.bvg.transport.rest/api.html). See references/API.md for summary and examples.

Examples (triggers)
- "How do I get from Invalidenstraße 43 10115 to Leibnizstraße 62 by public transport?"
- "When is the next U-Bahn from U Rosenthaler Platz?"
- "Find journeys that arrive at Deutsche Oper by 17:50 tonight, fastest option first."

Notes for implementers
- **IBNR format (CRITICAL):** The `/journeys` endpoint requires **base IBNR codes only** (6 digits), not the full ID with `::` suffixes.
  - ❌ Wrong: `de:11000:900110001::3` or `de:11000:900110001`
  - ✅ Correct: `900110001` (extract base 6-digit code from `/stops` results)
  - Process: Call `/stops?query=...` first, extract the 6-digit `id` from results, use that for `/journeys`.
- **URL encoding (CRITICAL):** All query string parameters must be properly URL-encoded using `urllib.parse.quote()` or equivalent. Examples:
  - Space → `%20`
  - `ö` → `%C3%B6`
  - `ü` → `%C3%BC`
  - `Ä` → `%C3%84`
  - Special chars like `&`, `?`, `#` → their percent-encoded equivalents
  - Example: `Schönhauser Allee` → `Sch%C3%B6nhauser%20Allee`
  - Every API call with address/stop name strings in query params must encode before building the URL.
- Prefer stop/station IDs when calling /journeys (more reliable than fuzzy names): Use `/stops?query=...` to resolve names → base IBNR.
- Use `stopovers=true` to build readable step lists; include `entrances=true` when walking-to-entrance accuracy is important.
- Request `results=3` then offer the top 2–3 to the user.
- Handle timezone-aware ISO datetimes; default to Europe/Berlin if none provided.

Overview

This skill provides concise route planning for Berlin public transport (BVG) using the v6.bvg.transport.rest API. It returns 2–3 ranked journey options with travel time, transfers, walking, and step-by-step directions. It also supports next-departure lookups for stops and arrival-time–based planning (arrive-by or depart-at). Refresh tokens are included when available for live updates.

How this skill works

Resolve origin and destination into BVG stop IDs or address/POI objects via /locations or /stops, prefer base IBNR stop codes (6 digits) for /journeys. Call /journeys with arrival/departure parameters, results=3 and stopovers=true to retrieve detailed legs, then format 2–3 options ranked by travel time, transfers, and walking. For simple next-departure queries call /stops/:id/departures (configurable duration) and return the nearest 3 departures; include journey refreshToken and a /journeys/:ref refresh step when realtime updates are needed.

When to use it

  • Ask for public-transport directions between two addresses, stops, or coordinates in Berlin.
  • Request next departures from a specific BVG stop or station.
  • Plan a journey to arrive by a specific time or depart at a specific time.
  • Get step-by-step legs including walking, platform info, and transfers.
  • Receive a refreshToken for live journey status updates.

Best practices

  • Resolve stop names to base 6-digit IBNR codes via /stops before calling /journeys to avoid errors.
  • URL-encode all query parameters (use urllib.parse.quote or equivalent) including special characters and spaces.
  • Request stopovers=true and results=3 to produce readable step lists and offer top options.
  • Return compact human-readable directions and an optional machine-friendly JSON with journey id, refreshToken, legs, and stop IDs.
  • Handle timezone-aware ISO datetimes; default to Europe/Berlin if none provided.

Example use cases

  • Get 2–3 fastest routes from Invalidenstraße 43 to Leibnizstraße 62 with step-by-step walking and transfer instructions.
  • Show the next three U-Bahn departures from U Rosenthaler Platz with real-time minutes and destinations.
  • Find journeys that arrive at Deutsche Oper by 17:50 tonight and present the fastest option first.
  • Provide a refresh token so a client can poll /journeys/:ref for updated delays during a trip.

FAQ

Why must I use a 6-digit IBNR code for stops?

The /journeys endpoint requires base IBNR codes (6 digits). Extract the six-digit id from /stops results and use that value; full IDs with prefixes or suffixes will fail.

How do I get live updates for a planned journey?

Include the journey refreshToken returned by /journeys and call GET /journeys/:ref to refresh realtime delays and departure adjustments.