APIs & Integrations

Integration Examples

End-to-end walkthroughs connecting Optra to common enterprise systems.

These examples walk through complete integration scenarios — from authentication through to handling real-time data in your own systems.

ServiceNow — Auto-create Incidents from Alerts

When an Optra rule triggers (e.g. a device goes offline), automatically create a ServiceNow incident:

  1. Create an Optra webhook subscribed to the rule.triggered event.
  2. Point the webhook URL at a lightweight middleware or serverless function.
  3. The function maps the Optra payload to the ServiceNow Incidents API and POSTs the incident.
// Middleware (Node.js / Express)
app.post('/optra-webhook', (req, res) => {
  const { event, device } = req.body;
  if (event === 'rule.triggered') {
    await serviceNow.incidents.create({
      short_description: `Optra alert: ${device.name}`,
      category: 'Hardware',
      cmdb_ci: device.serial,
    });
  }
  res.sendStatus(200);
});

Azure Event Hubs — Stream Telemetry

Forward all telemetry to Azure Event Hubs for downstream analytics pipelines:

  1. Create an Optra webhook subscribed to telemetry.threshold.
  2. In your handler, publish the payload to an Event Hub using the Azure SDK.
  3. Consume events downstream with Azure Stream Analytics or Databricks.
from azure.eventhub import EventHubProducerClient, EventData
import json

producer = EventHubProducerClient.from_connection_string(
    os.environ["EVENT_HUB_CONN_STR"],
    eventhub_name="optra-telemetry"
)

def handle_webhook(payload):
    batch = producer.create_batch()
    batch.add(EventData(json.dumps(payload)))
    producer.send_batch(batch)

Salesforce — Sync Device Fleet as Assets

Keep Salesforce Asset records up to date with the Optra device registry:

  1. On a schedule (or via device.registered webhook), fetch new devices from GET /devices.
  2. Upsert a Salesforce Asset record using the device serial as the external ID.
  3. Update the Asset Status field based on device.status changes.

Slack — Send Alert Notifications

Post a Slack message to a channel whenever a critical rule fires:

// Using Slack's Incoming Webhooks
async function notify(device, rule) {
  await fetch(process.env.SLACK_WEBHOOK_URL, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      text: `⚠️ *${rule.name}* triggered on *${device.name}* (${device.serial})`,
    }),
  });
}