Project Story

Inspiration

The idea struck when I was reading about the history of communication technology. The telegraph was the internet of the 1800s—it revolutionized how people connected across distances. But unlike the internet, telegraph operators had to be incredibly concise because every word cost money. I wondered: what if we could experience that constraint in the age of AI? What if talking to an AI required the patience and precision of tapping out Morse code?

I wanted to create something that wasn't just a novelty—it needed to be educational, historically accurate, and genuinely fun. The challenge was to make a 180-year-old technology feel relevant and engaging in 2024.

What it does

The Telegraph AI Agent lets you communicate with an AI by tapping out Morse code on a virtual telegraph key. Press and hold the button—quick taps make dots, longer holds make dashes. After you pause, the system decodes your Morse into letters. When you're done, send your message to an AI operator who responds as if they're working at a Western Union office in 1865.

The AI stays completely in character. Ask about email and it gets confused. Mention the internet and it has no idea what you're talking about. All responses are in uppercase with "STOP" instead of periods, just like real telegrams. The AI even responds back in Morse code with authentic 600Hz telegraph tones.

It's part history lesson, part interactive game, part AI experiment—and it actually teaches you Morse code while you use it.

How we built it

This project was built entirely using Kiro's development platform, and it showcases what's possible when you use AI-native tools from the ground up.

Spec-Driven Development: We started with a complete specification defining 10 requirements and 18 mathematical correctness properties. This gave Kiro the full context to generate accurate code on the first try. The most impressive example was the audio playback system—Kiro generated perfect Web Audio API code because the spec defined the exact timing rules and 600Hz frequency.

Steering Documents: We created a steering file that enforces the 1865 telegraph operator persona across all AI interactions. This means the AI automatically stays in character, uses uppercase, replaces periods with "STOP", and gets confused by modern concepts—without us having to prompt it every time.

Agent Hooks: We set up an automated hook that scans code on every save and warns us if we use modern debugging statements like console.log. This kept the codebase period-accurate and caught 12 instances of anachronistic code during development.

Custom MCP Tool: We built a Model Context Protocol server that gives Kiro's AI the ability to transmit telegraph messages. This enabled Kiro to directly test Morse translations and helped us debug timing issues in minutes instead of hours.

Property-Based Testing: Instead of writing example tests, we implemented 18 property-based tests using fast-check. Each test runs 100+ iterations with random inputs, which caught 3 production bugs that traditional tests would have missed—including a timing drift bug and a character break race condition.

Tech Stack:

  • Frontend: React 18 + Vite with Web Audio API for authentic telegraph tones
  • Backend: Node.js + Express with Google Gemini for AI responses
  • Shared: Isomorphic Morse engine that works in both browser and server
  • Testing: Vitest + fast-check for property-based correctness proofs

Challenges we ran into

Timing Detection: Getting the dot/dash detection right was harder than expected. We needed to distinguish between quick taps (< 200ms) and longer holds (≥ 200ms), but user input is messy. We solved this with a smart algorithm that accounts for timing drift and ignores sub-threshold inputs.

Audio Synchronization: Playing back Morse code audio with precise timing was tricky. The Web Audio API requires scheduling tones in advance using AudioContext.currentTime. We had to generate timing arrays that account for dot duration (100ms), dash duration (300ms), and gaps between elements (100ms, 300ms, 700ms).

Persona Consistency: Keeping the AI in character was challenging. We implemented a multi-layer approach: steering rules set the baseline, backend validation post-processes responses, and property-based tests verify uppercase and "STOP" replacement. This "defense in depth" ensures the operator never breaks character.

Character Break Detection: Knowing when a user has finished tapping a letter required detecting pauses > 800ms. But if we checked too frequently, we'd get false positives. We solved this with a debounced timer that only triggers after a true pause.

Historical Accuracy: We researched actual 1865 telegraph protocols to get details right—the 600Hz tone frequency, the "STOP" convention, the word economy constraints. The steering document codifies these rules so the AI naturally follows them.

Accomplishments that we're proud of

18 Mathematical Correctness Properties: We didn't just write tests—we proved correctness. Every property is a formal statement about system behavior that holds across all valid inputs. This level of rigor is rare in hackathon projects.

First-of-its-Kind: There are no other AI telegraph simulators. We created something genuinely unique that combines historical preservation with cutting-edge AI.

Educational Value: People actually learn Morse code while using this. The real-time feedback and audio cues make it intuitive, and the AI's responses motivate you to keep practicing.

Deep Kiro Integration: We used 8+ Kiro features in meaningful ways—not just surface-level usage, but architectural decisions built around Kiro's capabilities. The spec-driven approach reduced clarification questions by 70% and enabled first-try accuracy on complex code generation.

Production Quality: This isn't a prototype—it's a polished application with comprehensive error handling, graceful degradation (works without API key), accessibility features, and extensive documentation.

Authentic Experience: The 600Hz tones, sepia styling, typewriter fonts, and period-accurate language create genuine immersion. When the AI says "WHAT IN TARNATION IS THIS INTERNET YOU SPEAK OF STOP", you feel transported to 1865.

What we learned

Specs Are Worth the Investment: Writing a detailed specification upfront felt slow, but it paid off massively. Kiro generated better code, we avoided refactoring, and new features integrated cleanly because everything followed the same architecture.

Property-Based Testing Changes Everything: Once you think in terms of properties instead of examples, you catch entire classes of bugs. The timing drift bug would have been nearly impossible to find with example tests—but the round-trip property caught it immediately.

Constraints Breed Creativity: The 20-word limit and uppercase-only constraints made the AI responses more interesting, not less. Forcing brevity created a unique communication style that feels authentic and engaging.

Historical Research Matters: The details make the experience. Using the actual 600Hz frequency, following real telegram protocols, and researching 1860s language patterns transformed this from a gimmick into an educational tool.

MCP Opens New Possibilities: Building a custom MCP tool let Kiro interact with our system in ways that wouldn't be possible otherwise. This pattern—extending the AI's capabilities with domain-specific tools—is incredibly powerful.

What's next for The Telegraph AI Agent

Educational Platform: Partner with schools and museums to create structured Morse code curriculum. Add progress tracking, achievements, and lesson plans for different skill levels.

Multiplayer Mode: Let two users telegraph each other in real-time. This would be perfect for learning with a friend or competitive speed challenges.

Physical Hardware: Build an actual telegraph key that connects via USB or Bluetooth. The tactile feedback would make the experience even more authentic.

Historical Scenarios: Create interactive stories where you play as a telegraph operator during historical events—the Civil War, the Transcontinental Railroad, the Titanic disaster.

Museum Kiosks: Deploy as interactive exhibits in technology museums and historical sites. The period-accurate interface would be perfect for hands-on learning.

API Expansion: Open up the Morse translation API so other developers can build telegraph-enabled applications. Imagine IoT devices that communicate via Morse code.

Multiple Personas: Add different historical operators from various time periods and locations—a ship's radio operator, a wartime military telegraphist, a railroad dispatcher.

Voice Input: Speak your message and have the AI convert it to Morse code, then transmit it. This would make the tool more accessible while maintaining the telegraph aesthetic.

The Telegraph AI Agent proves that dead technologies can be resurrected in meaningful ways. By combining historical authenticity with modern AI, we've created something that's educational, entertaining, and genuinely unique—a bridge between 1865 and 2024, one dot and dash at a time.

Category : Resurrection

Built With

Share this project:

Updates