수도권 버스 도착 알림 (Clawdbot cron)
Scheduled bus arrival alerts powered by 국토교통부 TAGO OpenAPI.
This skill is designed for users running Clawdbot Gateway + Clawdbot cron. Users register rules like:
- - "평일 오전 7시, 인천 한빛초등학교, 535"
- "평일 오후 5시30분, 고양 향동초등학교, 730, 503"
Then the system sends arrival summaries to the registering user (DM) on schedule.
Note (MVP): stop resolution is done via stop name search (cityCode + keyword). GPS-based nearby lookup exists but may return 0 results depending on key/region.
Prerequisites
- - A running Clawdbot Gateway (Telegram/Slack/etc. already configured)
- Clawdbot cron enabled/usable
- A data.go.kr API key for TAGO
- (setup 자동화 사용 시)
systemctl --user 가 동작하는 환경 (systemd user service) - (rule_wizard에서 cron 등록까지 하려면)
clawdbot CLI
One-time setup: TAGO API key
You must set a TAGO service key in your environment (never commit or paste it into markdown).
Recommended env var:
Option A (fastest): one-off test in your current shell
Good for quick manual tests;
cron jobs will NOT inherit this unless the Gateway service has it.
CODEBLOCK0
Option B (recommended): one-command setup (auto-detect systemd unit)
This is the most “set it once and forget it” flow.
Run:
CODEBLOCK1
If your network blocks the endpoint or TAGO returns 403 during the smoke test, you can still complete setup:
CODEBLOCK2
It will:
- - Auto-detect your Gateway systemd user service (supports custom unit names)
- Prompt for
TAGO_SERVICE_KEY (hidden input) - Save it to
~/.clawdbot/secrets/tago.env (chmod 600) - Write a systemd override to load that env file
- Restart the Gateway
- Run a small TAGO smoke test
(Advanced/manual) If you prefer shell scripts, korea-metropolitan-bus-alerts/scripts/set_tago_key.sh is still available, but setup.py is the recommended UX.
Safety notes
- - Never commit
.env / tago.env. - Avoid sharing outputs of
docker compose config or similar commands that may print env values.
Quick start
A) Test TAGO connectivity (manual)
CODEBLOCK3
B) Register an alert rule (interactive)
Tell the agent something like:
- - "평일 07:00, 인천 한빛초등학교, 535 알림 등록해줘"
If the stop name is ambiguous (e.g., opposite side of road), the agent MUST ask a follow-up question to pick the correct direction/stop candidate before creating the rule.
C) List rules
D) Delete a rule
- - "버스 알림 3번 삭제해줘" (confirm before delete)
E) Test a rule (run now)
- - "방금 등록한 규칙 테스트해줘" (one-time message)
Supported schedule expressions (MVP)
- - 매일 HH:MM
- 평일 HH:MM
- 주말 HH:MM
(Phase 2: arbitrary cron expressions)
Cron implementation notes
- - Use isolated cron jobs (
sessionTarget: isolated) + deliver: true. - Delivery is DM-only to the registering user.
- See
references/cron_recipe.md and scripts/cron_builder.py.
Interactive registration helper (server-side)
For integration testing (and for power users), use:
It will:
1) Ask for schedule/time/routes
2) Resolve stop candidates via GPS nearby lookup (direction disambiguation)
3) Generate the job JSON
4) Optionally call clawdbot cron add to register it
Data source
Single provider only (MVP):
- - 정류장 조회: BusSttnInfoInqireService (15098534)
- 도착 조회: ArvlInfoInqireService (15098530)
Safety / Security
- - Never write API keys/tokens/passwords into markdown files.
- For browser automation on logged-in pages: require explicit user confirmation.
- For destructive operations (cron delete): confirm before acting.
- DM-only delivery (MVP): do not broadcast to groups/channels.
Implementation notes
- - Prefer scripts under
scripts/ for deterministic behavior. - Put detailed API field mappings in
references/api_reference.md.
Deterministic helper script
Use
scripts/tago_bus_alert.py for deterministic TAGO lookups:
- -
nearby-stops (GPS → stop candidates) - INLINECODE20 (cityCode+nodeId → arrivals; optional route filtering)
수도권 버스 도착 알림 (Clawdbot cron)
국토교통부 TAGO OpenAPI 기반의 정기 버스 도착 알림 서비스입니다.
이 스킬은 Clawdbot Gateway + Clawdbot cron을 실행하는 사용자를 위해 설계되었습니다. 사용자는 다음과 같은 규칙을 등록합니다:
- - 평일 오전 7시, 인천 한빛초등학교, 535
- 평일 오후 5시30분, 고양 향동초등학교, 730, 503
그러면 시스템이 정해진 시간에 등록한 사용자(DM)에게 도착 요약 정보를 전송합니다.
참고 (MVP): 정류장 확인은 정류장 이름 검색(cityCode + 키워드)을 통해 이루어집니다. GPS 기반 주변 검색 기능도 있지만 키/지역에 따라 결과가 0개일 수 있습니다.
사전 요구사항
- - 실행 중인 Clawdbot Gateway (Telegram/Slack 등 이미 구성됨)
- Clawdbot cron 활성화/사용 가능
- TAGO용 data.go.kr API 키
- (설정 자동화 사용 시) systemctl --user가 동작하는 환경 (systemd user service)
- (rule_wizard에서 cron 등록까지 하려면) clawdbot CLI
일회성 설정: TAGO API 키
환경 변수에 TAGO 서비스 키를 설정해야 합니다 (절대 커밋하거나 마크다운에 붙여넣지 마세요).
권장 환경 변수:
옵션 A (가장 빠름): 현재 셸에서 일회성 테스트
빠른 수동 테스트에 적합합니다.
cron 작업은 Gateway 서비스에 환경 변수가 설정되어 있지 않으면 이를 상속받지 않습니다.
bash
export TAGOSERVICEKEY=...
옵션 B (권장): 원클릭 설정 (systemd 유닛 자동 감지)
가장 한 번 설정하면 잊어버리는 방식입니다.
실행:
bash
python3 korea-metropolitan-bus-alerts/scripts/setup.py
네트워크가 엔드포인트를 차단하거나 연동 테스트 중 TAGO가 403을 반환해도 설정을 완료할 수 있습니다:
bash
python3 korea-metropolitan-bus-alerts/scripts/setup.py --skip-smoke
이 스크립트는 다음을 수행합니다:
- - Gateway systemd 사용자 서비스 자동 감지 (사용자 정의 유닛 이름 지원)
- TAGOSERVICEKEY 입력 요청 (입력 내용 숨김)
- ~/.clawdbot/secrets/tago.env에 저장 (chmod 600)
- 해당 env 파일을 로드하는 systemd 오버라이드 작성
- Gateway 재시작
- 소규모 TAGO 연동 테스트 실행
(고급/수동) 셸 스크립트를 선호하는 경우 korea-metropolitan-bus-alerts/scripts/settagokey.sh도 사용 가능하지만, setup.py가 권장 UX입니다.
보안 참고사항
- - .env / tago.env를 절대 커밋하지 마세요.
- docker compose config 또는 env 값을 출력할 수 있는 유사 명령어의 출력을 공유하지 마세요.
빠른 시작
A) TAGO 연결 테스트 (수동)
bash
export TAGO
SERVICEKEY=...
python3 korea-metropolitan-bus-alerts/scripts/tago
busalert.py nearby-stops --lat 37.5665 --long 126.9780
B) 알림 규칙 등록 (대화형)
에이전트에게 다음과 같이 요청하세요:
- - 평일 07:00, 인천 한빛초등학교, 535 알림 등록해줘
정류장 이름이 모호한 경우(예: 도로 반대편), 에이전트는 규칙을 생성하기 전에 올바른 방향/정류장 후보를 선택하기 위해 후속 질문을 해야 합니다.
C) 규칙 목록 보기
D) 규칙 삭제
- - 버스 알림 3번 삭제해줘 (삭제 전 확인)
E) 규칙 테스트 (즉시 실행)
- - 방금 등록한 규칙 테스트해줘 (일회성 메시지)
지원되는 일정 표현식 (MVP)
- - 매일 HH:MM
- 평일 HH:MM
- 주말 HH:MM
(2단계: 임의 cron 표현식)
Cron 구현 참고사항
- - 격리된 cron 작업 사용 (sessionTarget: isolated) + deliver: true.
- 전달은 등록한 사용자에게 DM 전용입니다.
- references/cronrecipe.md 및 scripts/cronbuilder.py 참조.
대화형 등록 도우미 (서버 측)
통합 테스트(및 고급 사용자)를 위해 다음을 사용하세요:
- - scripts/rule_wizard.py register
다음을 수행합니다:
1) 일정/시간/노선 요청
2) GPS 주변 검색을 통해 정류장 후보 확인 (방향 구분)
3) 작업 JSON 생성
4) 선택적으로 clawdbot cron add를 호출하여 등록
데이터 소스
MVP에서는 단일 제공자만 사용:
- - 정류장 조회: BusSttnInfoInqireService (15098534)
- 도착 조회: ArvlInfoInqireService (15098530)
안전 / 보안
- - API 키/토큰/비밀번호를 마크다운 파일에 절대 작성하지 마세요.
- 로그인된 페이지의 브라우저 자동화: 명시적 사용자 확인 필요.
- 파괴적 작업(cron 삭제): 실행 전 확인.
- DM 전용 전달 (MVP): 그룹/채널에 브로드캐스트하지 마세요.
구현 참고사항
- - 결정적 동작을 위해 scripts/ 아래의 스크립트를 선호하세요.
- 자세한 API 필드 매핑은 references/api_reference.md에 작성하세요.
결정적 도우미 스크립트
결정적 TAGO 조회를 위해 scripts/tago
busalert.py 사용:
- - nearby-stops (GPS → 정류장 후보)
- arrivals (cityCode+nodeId → 도착 정보, 선택적 노선 필터링)