SDKsServer-side
Ruby
Notiflows Ruby SDK for server-side integration
The Ruby SDK (notiflows) allows you to trigger notiflows, manage users, and interact with the Notiflows Admin API from your Ruby backend.
Installation
gem install notiflowsOr add to your Gemfile:
gem "notiflows"Quick Start
require "notiflows"
client = Notiflows::Client.new(
api_key: "pk_your_api_key",
secret: "sk_your_secret_key"
)
# Trigger a notiflow
client.notiflows.run("welcome-email", {
data: { name: "Jane" },
recipients: [{ external_id: "user_123" }]
})Configuration
client = Notiflows::Client.new(
api_key: "pk_your_api_key",
secret: "sk_your_secret_key"
)Both api_key and secret are required. Find them in your project's Settings > API Keys.
Triggering Notiflows
# Send to specific recipients
client.notiflows.run("order-shipped", {
data: { order_id: "order_789" },
recipients: [
{ external_id: "user_123" },
{ external_id: "user_456" }
]
})
# Send to all subscribers of a topic
client.notiflows.run("new-comment", {
topic: "post_123",
data: { commenter: "Jane" },
actor: { external_id: "user_456" }
})Managing Users
# Upsert user
client.users.upsert("user_123", { email: "jane@example.com", first_name: "Jane" })
# Get user
user = client.users.retrieve("user_123")
# List users
users = client.users.list(limit: 20)
# Delete user
client.users.delete("user_123")User Preferences
# Get preferences
prefs = client.users.preferences.retrieve("user_123")
# Update preferences
client.users.preferences.update("user_123", {
channel_types: { "email" => true, "sms" => false }
})Topic Subscriptions
# Subscribe
client.users.subscriptions.subscribe("user_123", { topic_name: "product-updates" })
# List subscriptions
subs = client.users.subscriptions.list("user_123")
# Unsubscribe
client.users.subscriptions.unsubscribe("product-updates", { user_external_id: "user_123" })Topics
# List topics
client.topics.list(limit: 10)
# Get topic
client.topics.retrieve("product-updates")
# Delete topic
client.topics.delete("product-updates")Notifications & Deliveries
# List notifications
client.notifications.list(limit: 10)
# Get notification
client.notifications.retrieve("notification_id")
# List deliveries
client.deliveries.list(limit: 10)
# Get delivery
client.deliveries.retrieve("delivery_id")