This directory contains example configurations for DialogChain, demonstrating various features and integration patterns. Each example is designed to showcase different capabilities of the DialogChain system.
- Getting Started
- Basic Examples
- File Processing
- Network & API
- Advanced Features
- Running Examples
- Contributing
- Python 3.8+
- DialogChain installed (see main README)
- Any additional dependencies for specific examples
Most examples can be run using the dialogchain
CLI:
# Run a specific example
dialogchain serve examples/simple_timer.yaml
# Run with debug logging
DIALOGCHAIN_LOG_LEVEL=debug dialogchain serve examples/simple_timer.yaml
- File:
hello_world.yaml
- Description: Minimal example to verify your setup
- Features: Basic pipeline, logging
- Run:
dialogchain serve examples/hello_world.yaml
- File:
simple_timer.yaml
- Description: Logs structured JSON data at regular intervals
- Features: Timers, structured logging
- Run:
dialogchain serve examples/simple_timer.yaml
- File:
simple_logging_example.yaml
- Description: Demonstrates different log levels and outputs
- Features: Logging configuration, log levels
- Run:
dialogchain serve examples/simple_logging_example.yaml
- File:
file_watcher_example.yaml
- Description: Monitors a file for changes and processes its contents
- Features: File system monitoring, content processing
- Prerequisites: Create an
input/
directory - Run:
dialogchain serve examples/file_watcher_example.yaml
- File:
json_processor_example.yaml
- Description: Processes and transforms JSON data
- Features: JSON parsing, data transformation
- Run:
dialogchain serve examples/json_processor_example.yaml
- File:
http_handler.yaml
- Description: Sets up an HTTP endpoint
- Features: HTTP server, request handling
- Run:
dialogchain serve examples/http_handler.yaml
- Test:
curl http://localhost:8080/hello
- File:
mqtt_pubsub_example.yaml
- Description: Implements MQTT publisher and subscriber
- Features: MQTT integration, message brokering
- Prerequisites: MQTT broker (e.g., Mosquitto)
- Run:
dialogchain serve examples/mqtt_pubsub_example.yaml
- File:
grpc_routes.yaml
- Description: gRPC service implementation
- Features: gRPC server, protocol buffers
- Run:
dialogchain serve examples/grpc_routes.yaml
- File:
camera_routes.yaml
- Description: Captures and processes video streams
- Features: OpenCV integration, video processing
- Prerequisites: OpenCV, camera access
- Run:
dialogchain serve examples/camera_routes.yaml
- File:
iot_routes.yaml
- Description: Controls IoT devices
- Features: Device management, state handling
- Run:
dialogchain serve examples/iot_routes.yaml
# Build the container
docker build -t dialogchain-examples .
# Run an example
docker run -it --rm -v $(pwd):/app dialogchain-examples dialogchain serve examples/hello_world.yaml
Set environment variables for debugging:
# Enable debug logging
DIALOGCHAIN_LOG_LEVEL=debug dialogchain serve examples/your_example.yaml
# Enable development mode (auto-reload on changes)
DIALOGCHAIN_DEV=1 dialogchain serve examples/your_example.yaml
We welcome contributions to our examples! Please see the main Contributing Guide for details.
- Fork the repository
- Create a new branch for your example
- Add your example with appropriate documentation
- Submit a pull request
These examples are part of the DialogChain project and are licensed under the Apache 2.0 License.
-
complex_example.yaml
- Combines multiple routes and processors
- Demonstrates advanced routing and transformation
-
structured_timer_example.yaml
- Generates and processes structured sensor data
- Shows conditional processing and data enrichment
-
camera_routes.yaml
- Video processing pipeline example
- Demonstrates handling binary data streams
-
iot_routes.yaml
- IoT device communication patterns
- Shows device management and data collection
- Python 3.8+
- Docker (for MQTT and other containerized services)
- Required Python packages (install with
pip install -r requirements.txt
in the project root)
# Run a specific example
python -m src.dialogchain.cli run --config examples/example_name.yaml
# Run with verbose output
python -m src.dialogchain.cli run --config examples/example_name.yaml -v
Some examples require additional services like MQTT brokers. Use the provided docker-compose file:
# Start required services
docker-compose -f docker-compose.test.yml up -d
# Run your example
python -m src.dialogchain.cli run --config examples/example_name.yaml
When creating new examples:
- Follow the existing naming conventions
- Include clear comments in the YAML files
- Document any external dependencies
- Update this README with a brief description of the new example
- Ensure all required services are running for integration examples
- Check file permissions for file watcher examples
- Use the
-v
flag for verbose logging when debugging - For MQTT issues, verify the broker is accessible and the topic permissions are correct