Skip to content

Commit b0eb10f

Browse files
author
Tom Softreck
committed
update
1 parent 83fcbf2 commit b0eb10f

32 files changed

Lines changed: 1196 additions & 192 deletions

.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SMTP Configuration
2+
SMTP_SERVER=smtp.gmail.com
3+
SMTP_PORT=587
4+
SMTP_USER=your-email@gmail.com
5+
SMTP_PASS=your-app-specific-password
6+
ALERT_EMAIL=recipient@example.com
7+
8+
# Note: For Gmail, you'll need to:
9+
# 1. Enable 2-factor authentication
10+
# 2. Create an App Password: https://myaccount.google.com/apppasswords
11+
# 3. Use the generated app password for SMTP_PASS

advanced_example.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Advanced Example with Multiple Routes
2+
routes:
3+
# Route 1: Simple timer with transform
4+
- name: "greeting_route"
5+
from: "timer:10s" # Run every 10 seconds
6+
7+
processors:
8+
- type: "transform"
9+
template: "Greeting from DialogChain at {{now().isoformat() if 'now' in globals() else 'current_time'}}!"
10+
11+
to: "log:info"
12+
13+
# Route 2: Message transformation
14+
- name: "transform_route"
15+
from: "timer:15s" # Run every 15 seconds
16+
17+
processors:
18+
- type: "transform"
19+
template: |
20+
{
21+
"message": "This is a test message",
22+
"status": "success",
23+
"count": 1
24+
}
25+
26+
- type: "transform"
27+
template: "Processed message: {{message}} (Status: {{status}}, Count: {{count}})"
28+
29+
to: "log:info"
30+
31+
# Route 3: Conditional logging
32+
- name: "conditional_route"
33+
from: "timer:20s" # Run every 20 seconds
34+
35+
processors:
36+
- type: "transform"
37+
template: "test_status=failed coverage=75"
38+
39+
# This filter will only pass through if condition is true
40+
- type: "filter"
41+
condition: "{{test_status}} == 'failed' or {{coverage}} < 80"
42+
43+
- type: "transform"
44+
template: "ALERT: Test {{test_status}} with {{coverage}}% coverage (below threshold)"
45+
46+
to: "log:warn"
47+
48+
# Environment variables (commented out as they're not needed for this example)
49+
# env_vars:
50+
# - VARIABLE_NAME

check_smtp.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Simple script to test SMTP connection using environment variables.
4+
"""
5+
import os
6+
import smtplib
7+
from email.mime.text import MIMEText
8+
from email.mime.multipart import MIMEMultipart
9+
from dotenv import load_dotenv
10+
11+
def check_smtp():
12+
# Load environment variables from .env file
13+
load_dotenv()
14+
15+
# Required environment variables
16+
required_vars = [
17+
'SMTP_SERVER',
18+
'SMTP_PORT',
19+
'SMTP_USER',
20+
'SMTP_PASS',
21+
'ALERT_EMAIL'
22+
]
23+
24+
# Check if all required variables are set
25+
missing_vars = [var for var in required_vars if not os.getenv(var)]
26+
if missing_vars:
27+
print(f"❌ Missing required environment variables: {', '.join(missing_vars)}")
28+
print("\nPlease add them to your .env file:")
29+
for var in missing_vars:
30+
print(f"{var}=your_value_here")
31+
return False
32+
33+
# Get SMTP settings
34+
smtp_server = os.getenv('SMTP_SERVER')
35+
smtp_port = int(os.getenv('SMTP_PORT', '587'))
36+
smtp_user = os.getenv('SMTP_USER')
37+
smtp_pass = os.getenv('SMTP_PASS')
38+
to_email = os.getenv('ALERT_EMAIL')
39+
40+
print(f"🔧 Testing SMTP connection to {smtp_server}:{smtp_port}")
41+
print(f"🔑 Using username: {smtp_user}")
42+
43+
try:
44+
# Create message
45+
msg = MIMEMultipart()
46+
msg['From'] = smtp_user
47+
msg['To'] = to_email
48+
msg['Subject'] = 'SMTP Test from DialogChain'
49+
50+
body = """
51+
This is a test email to verify SMTP configuration.
52+
53+
If you're reading this, the SMTP configuration is working correctly!
54+
"""
55+
msg.attach(MIMEText(body, 'plain'))
56+
57+
# Connect to server and send email
58+
with smtplib.SMTP(smtp_server, smtp_port) as server:
59+
server.starttls()
60+
print(f"🔒 Attempting to authenticate with {smtp_user}:{'*' * len(smtp_pass)}")
61+
server.login(smtp_user, smtp_pass)
62+
print("✅ Successfully authenticated with SMTP server")
63+
64+
print(f"📤 Sending test email to {to_email}...")
65+
server.send_message(msg)
66+
print("✅ Test email sent successfully!")
67+
return True
68+
69+
except Exception as e:
70+
print(f"❌ Error: {e}")
71+
return False
72+
73+
if __name__ == "__main__":
74+
check_smtp()

config.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Camera Processing Routes
2+
routes:
3+
- name: "front_door_camera"
4+
from: "rtsp://{{CAMERA_USER}}:{{CAMERA_PASS}}@{{CAMERA_IP}}/stream1"
5+
processors:
6+
- type: "external"
7+
command: "python -m ultralytics_processor"
8+
input_format: "frame_stream"
9+
output_format: "json"
10+
config:
11+
confidence_threshold: 0.6
12+
target_objects: ["person", "car"]
13+
14+
- type: "filter"
15+
condition: "{{confidence}} > 0.7"
16+
17+
- type: "transform"
18+
template: "Person detected at {{position}} ({{confidence}}%)"
19+
20+
to: "smtp://{{SMTP_SERVER}}:{{SMTP_PORT}}?user={{SMTP_USER}}&password={{SMTP_PASS}}&to={{ALERT_EMAIL}}"
21+
22+
env_vars:
23+
- CAMERA_USER
24+
- CAMERA_PASS
25+
- CAMERA_IP
26+
- SMTP_SERVER
27+
- SMTP_PORT
28+
- SMTP_USER
29+
- SMTP_PASS
30+
- ALERT_EMAIL

docs/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Core Classes
44

5-
### CamelRouterEngine
5+
### DialogChainEngine
66

77
Main routing engine that orchestrates the processing pipeline.
88

0 commit comments

Comments
 (0)