examples

DialogChain Examples

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.

📋 Table of Contents

🚀 Getting Started

Prerequisites

Running 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

🧩 Basic Examples

Hello World

Simple Timer

Logging Example

📂 File Processing

File Watcher

JSON Processor

🌐 Network & API Integrations

HTTP Server

MQTT Pub/Sub

gRPC Service

🚀 Advanced Features

Camera Integration

IoT Device Control

🛠️ Running Examples

Using Docker

# 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

Debugging

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

🤝 Contributing

We welcome contributions to our examples! Please see the main Contributing Guide for details.

  1. Fork the repository
  2. Create a new branch for your example
  3. Add your example with appropriate documentation
  4. Submit a pull request

📄 License

These examples are part of the DialogChain project and are licensed under the Apache 2.0 License.

Advanced Examples

  1. complex_example.yaml
    • Combines multiple routes and processors
    • Demonstrates advanced routing and transformation
  2. structured_timer_example.yaml
    • Generates and processes structured sensor data
    • Shows conditional processing and data enrichment
  3. camera_routes.yaml
    • Video processing pipeline example
    • Demonstrates handling binary data streams
  4. iot_routes.yaml
    • IoT device communication patterns
    • Shows device management and data collection

Running Examples

Prerequisites

Basic Usage

# 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

Running with Docker

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

Development

When creating new examples:

  1. Follow the existing naming conventions
  2. Include clear comments in the YAML files
  3. Document any external dependencies
  4. Update this README with a brief description of the new example

Troubleshooting