A minimal example demonstrating how to build and coordinate a tool as a service using Orra's Plan Engine. It's Orra Hello World!
sequenceDiagram
participant CLI as Orra CLI
participant PE as Plan Engine
participant ES as Echo Tool as Service
participant WH as Webhook Server
CLI->>PE: Send action
PE->>ES: Orchestrate task
ES->>PE: Return echo
PE->>WH: Send result
Note over WH: See result in terminal
- 🔄 Basic service registration and coordination
- 📡 Real-time WebSocket communication
- ⚡ Reliable message delivery
- 🛡️ Built-in health monitoring
- 🚀 Simple but production-ready patterns
- Docker and Docker Compose
- OpenAI API key for Orra's Plan Engine
PLAN_CACHE_OPENAI_API_KEY
- OpenAI API key or Groq API key for Orra's Plan Engine reasoning models config
- OpenAI API key for the
writer_crew
andeditor
Agents
-
First, setup Orra and the CLI by following the installation instructions:
-
Setup your Orra project:
# Create project, add a webhook and API key
orra projects add my-echo-app
orra webhooks add http://host.docker.internal:8888/webhook
orra api-keys gen echo-key
- Configure the Echo tool as service:
cd examples/echo-js
echo "ORRA_API_KEY=echo-key-from-step-2" > .env
- Start the webhook server (in a separate terminal):
# Start the webhook server using the verify subcommand
orra verify webhooks start http://localhost:8888/webhook
- Start the Echo service:
# Start Echo Service
docker compose up
- Try it out:
# Send a test message
orra verify run "Echo this message" --data message:"Hello from Orra!"
# Check the result
orra ps
orra inspect <orchestration-id>
You should see the result both in the webhook server terminal and through the inspect command.
Here's the complete Echo service implementation showing how simple Orra integration can be:
import { initService } from '@orra.dev/sdk';
import schema from './schema.json' assert { type: 'json' };
const echoToolSvc = initService({
name: 'echo',
orraUrl: process.env.ORRA_URL,
orraKey: process.env.ORRA_API_KEY
});
// Health check
app.get('/health', (req, res) => {
res.status(200).json({ status: 'healthy' });
});
async function startService() {
try {
// Register the echo service with Orra
await echoToolSvc.register({
description: 'An echo provider that echoes back the first input value it receives.',
schema
});
echoToolSvc.start(async (task) => {
console.log('Echoing input:', task.id);
const { message } = task?.input;
return { echo: `Echo: ${message}` };
});
} catch (error) {
console.error('Failed to start:', error);
process.exit(1);
}
}
// Start the Express server and the service
app.listen(port, () => {
console.log(`Server listening on port ${port}`);
startService().catch(console.error);
});
That's it! Orra provides:
- Service discovery
- Health monitoring
- Reliable task execution
- Error recovery