Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
752 changes: 400 additions & 352 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ imap = "2"
native-tls = "0.2"
mailparse = "0.15"

# MQTT
rumqttc = "0.24"

# Testing
tokio-test = "0.4"
tempfile = "3"
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,40 @@ Connect your agents to every platform your users are on.
**Social:** LINE, Viber, Facebook Messenger, Mastodon, Bluesky, Reddit, LinkedIn, Twitch
**Community:** IRC, XMPP, Guilded, Revolt, Keybase, Discourse, Gitter
**Privacy:** Threema, Nostr, Mumble, Nextcloud Talk, Rocket.Chat, Ntfy, Gotify
**IoT/Edge:** MQTT
**Workplace:** Pumble, Flock, Twist, DingTalk, Zalo, Webhooks

Each adapter supports per-channel model overrides, DM/group policies, rate limiting, and output formatting.

### MQTT Configuration

MQTT is ideal for IoT devices, edge computing, and low-bandwidth environments. Configure it in `~/.openfang/config.toml`:

```toml
[channels.mqtt]
broker_url = "tcp://broker.hivemq.com:1883" # or "ssl://..." for TLS
client_id = "" # empty = auto-generate
subscribe_topic = "openfang/inbox"
publish_topic_prefix = "openfang/reply"
default_agent = "assistant"
qos = 1 # 0=at most once, 1=at least once, 2=exactly once
use_tls = false
keep_alive_secs = 60

# Optional authentication
username_env = "MQTT_USERNAME"
password_env = "MQTT_PASSWORD"
```

Test with any MQTT client:
```bash
# Send a message
mosquitto_pub -h broker.hivemq.com -t "openfang/inbox" -m "What's the weather?"

# Subscribe to replies
mosquitto_sub -h broker.hivemq.com -t "openfang/reply/#"
```

---

## 27 LLM Providers — 123+ Models
Expand Down
17 changes: 16 additions & 1 deletion crates/openfang-api/src/channel_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use openfang_channels::gitter::GitterAdapter;
use openfang_channels::gotify::GotifyAdapter;
use openfang_channels::linkedin::LinkedInAdapter;
use openfang_channels::mumble::MumbleAdapter;
use openfang_channels::mqtt::MqttAdapter;
use openfang_channels::ntfy::NtfyAdapter;
use openfang_channels::webhook::WebhookAdapter;
use openfang_kernel::OpenFangKernel;
Expand Down Expand Up @@ -733,6 +734,7 @@ impl ChannelBridgeHandle for KernelBridgeAdapter {
"gotify" => channels.gotify.as_ref().map(|c| c.overrides.clone()),
"webhook" => channels.webhook.as_ref().map(|c| c.overrides.clone()),
"linkedin" => channels.linkedin.as_ref().map(|c| c.overrides.clone()),
"mqtt" => channels.mqtt.as_ref().map(|c| c.overrides.clone()),
_ => None,
}
}
Expand Down Expand Up @@ -1008,7 +1010,8 @@ pub async fn start_channel_bridge_with_config(
|| config.ntfy.is_some()
|| config.gotify.is_some()
|| config.webhook.is_some()
|| config.linkedin.is_some();
|| config.linkedin.is_some()
|| config.mqtt.is_some();

if !has_any {
return (None, Vec::new());
Expand Down Expand Up @@ -1518,6 +1521,18 @@ pub async fn start_channel_bridge_with_config(
}
}

// MQTT
if let Some(ref mqtt_config) = config.mqtt {
if !mqtt_config.broker_url.is_empty() && !mqtt_config.subscribe_topic.is_empty() {
let adapter = Arc::new(MqttAdapter::from_config(mqtt_config.clone()));
adapters.push((adapter, mqtt_config.default_agent.clone()));
info!(
"MQTT adapter configured: {} -> {}",
mqtt_config.broker_url, mqtt_config.subscribe_topic
);
}
}

if adapters.is_empty() {
return (None, Vec::new());
}
Expand Down
3 changes: 3 additions & 0 deletions crates/openfang-channels/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ imap = { workspace = true }
native-tls = { workspace = true }
mailparse = { workspace = true }

# MQTT support
rumqttc = { workspace = true }

[dev-dependencies]
tokio-test = { workspace = true }
1 change: 1 addition & 0 deletions crates/openfang-channels/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ pub mod gitter;
pub mod gotify;
pub mod linkedin;
pub mod mumble;
pub mod mqtt;
pub mod ntfy;
pub mod webhook;
Loading