Skip to content

Connect Ayla Networks to ChatGPT: Manage Devices and Automate Scenes

Learn how to connect Ayla Networks to chatgpt using Truto. Step-by-step guide to tool calling, API quirks, and autonomous workflows.

Riya Sethi Riya Sethi · · 11 min read
Connect Ayla Networks to ChatGPT: Manage Devices and Automate Scenes

If you need to connect Ayla Networks to ChatGPT to automate smart home workflows, provision IoT devices, or manage fleet-wide OTA updates, you need a Model Context Protocol (MCP) server. This server acts as the translation layer between ChatGPT's function-calling capabilities and the highly specialized, hierarchical REST APIs of the Ayla IoT platform. You can either spend weeks building and maintaining this custom middleware, or you can use a managed integration layer to dynamically generate a secure, authenticated MCP server URL.

If your team uses Claude, check out our guide on connecting Ayla Networks to Claude or explore our broader architectural overview on connecting Ayla Networks to AI Agents.

Giving a Large Language Model (LLM) read and write access to an enterprise IoT platform is a massive engineering challenge. You have to handle complex Device Serial Number (DSN) routing, deep property-to-datapoint data models, and strict role-based access controls across OEMs and dealers. Every time a new device template or property is added to your Ayla environment, your custom server code must be updated and redeployed.

This guide breaks down exactly how to use Truto to generate a secure, managed MCP server for Ayla Networks, connect it natively to ChatGPT, and execute complex device workflows using natural language.

Stop writing boilerplate API integration code. Let Truto generate secure, managed MCP servers for your AI agents in seconds. :::

The Engineering Reality of the Ayla Networks API

Building a custom MCP server is essentially building a self-hosted integration layer. While the open MCP standard provides a predictable way for models to discover and invoke tools, implementing it against Ayla Networks' hardware-focused API is exceptionally painful.

If you decide to build a custom Ayla Networks ChatGPT integration in-house, you own the entire API lifecycle. Here are the specific integration challenges that break standard CRUD assumptions when working with Ayla:

The Property-Datapoint Abstraction

Unlike a typical SaaS platform where you might POST /lights/1/turn_on, Ayla Networks relies on a strict digital twin abstraction. Devices do not have "actions." Instead, devices have Properties (e.g., power_state, temperature_target), and you act upon them by creating a Datapoint on that specific property. If an LLM needs to turn on a thermostat, your MCP server must first look up the exact DSN, query the available properties to find the internal naming convention for the power state, and then execute a payload to create a new datapoint. Hardcoding this logic is brittle; your MCP server must dynamically expose Ayla's documentation schemas as JSON-RPC tools so the LLM can navigate the abstraction itself.

Hierarchical DSN Routing

Virtually every actionable endpoint in the Ayla Networks API requires a Device Serial Number (DSN). Devices are tied to Templates, which are tied to OEMs, which might be managed by Dealers. If a user asks ChatGPT to "update the firmware on the warehouse sensors," the LLM must understand how to list devices, filter them by metadata or location, extract the specific DSN arrays, and map them to an ICC (IoT Command Center) Job. If your MCP tools do not strictly define these required parameters, ChatGPT will hallucinate DSN formats.

Rate Limits and Asynchronous Hardware Reality

Hardware does not respond as fast as software. When you dispatch a command to an edge device, the API might acknowledge the request immediately, but the hardware state change is asynchronous. Furthermore, when querying large fleets, you will hit Ayla's rate limits.

A critical architectural note: Truto does not retry, throttle, or apply automatic backoff on rate limit errors. When the upstream Ayla Networks API returns an HTTP 429 Too Many Requests, Truto passes that error directly back to the caller. Truto normalizes the upstream rate limit information into standardized headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset) per the IETF specification. The caller (your LLM agent framework or client) is entirely responsible for reading these headers and implementing its own retry or backoff logic.

How to Create the Ayla Networks MCP Server

Rather than building a Node.js or Python server from scratch to handle these quirks, you can use Truto to dynamically derive an Ayla Networks MCP server based on the integration's underlying schema documentation.

You can generate this server via the Truto UI or programmatically via the API.

Method 1: Creating the Server via the Truto UI

If you are manually setting up a workspace for your internal team, the UI is the fastest path.

  1. Log into your Truto dashboard and navigate to your Integrated Accounts.
  2. Click on your active Ayla Networks connection.
  3. Navigate to the MCP Servers tab.
  4. Click Create MCP Server.
  5. Select your configuration. You can optionally filter which tools this server exposes (e.g., limiting the server to only read methods or specifically checking the devices and datapoints tags).
  6. Copy the generated MCP Server URL (e.g., https://api.truto.one/mcp/a1b2c3d4...). Treat this URL like a production secret.

Method 2: Creating the Server via the API

If you are building a product where you need to programmatically spin up ChatGPT-compatible endpoints for your own end-users, you can use the Truto API.

Make an authenticated POST request to the /integrated-account/:id/mcp endpoint:

curl -X POST https://api.truto.one/integrated-account/<YOUR_INTEGRATED_ACCOUNT_ID>/mcp \
  -H "Authorization: Bearer $TRUTO_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "ChatGPT Fleet Manager",
    "config": {
      "methods": ["read", "write", "custom"],
      "tags": ["devices", "collections", "datapoints"]
    },
    "expires_at": "2026-12-31T23:59:59Z"
  }'

The API provisions the server and returns a response containing the secure url. This URL contains a hashed token that routes the JSON-RPC traffic directly to that specific Ayla Networks tenant.

How to Connect the MCP Server to ChatGPT

Once you have your Truto MCP URL, you need to register it with your ChatGPT environment. You can do this through the ChatGPT interface (if your plan supports it) or via a local configuration file for programmatic usage.

Method A: Via the ChatGPT UI

If you are on a ChatGPT Pro, Plus, Business, Enterprise, or Education plan, you can add custom connectors directly in the web application.

  1. Open ChatGPT and navigate to Settings -> Apps -> Advanced settings.
  2. Toggle Developer mode on (custom MCP connectors are hidden behind this flag).
  3. Under the MCP servers / Custom connectors section, click to add a new server.
  4. Enter a descriptive name (e.g., "Ayla IoT Environment").
  5. Paste your Truto MCP Server URL into the configuration field.
  6. Save the configuration. ChatGPT will immediately perform a handshake, call the tools/list protocol method, and register the available Ayla Networks tools.

Method B: Via Manual Config File (CLI)

If you are orchestrating an AI agent locally or running a custom desktop client that utilizes the @modelcontextprotocol/server-sse transport, you can map the URL directly in your MCP configuration JSON.

Create or update your mcp_config.json file:

{
  "mcpServers": {
    "ayla_networks_fleet": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-sse",
        "--url",
        "https://api.truto.one/mcp/<YOUR_SECURE_TOKEN>"
      ]
    }
  }
}

When your LLM framework boots up, it will connect to the SSE endpoint and dynamically load the Ayla schemas.

Ayla Networks Hero Tools for AI Agents

Truto automatically generates a comprehensive suite of tools based on Ayla's endpoint documentation. Rather than giving the LLM raw API access, it provides strictly typed JSON schemas that instruct the model on exactly what arguments are required.

Here are the highest-leverage operations your agent can perform.

list_all_ayla_networks_devices

This is the foundational tool for any Ayla workflow. Before the LLM can command a device, it needs to locate it and extract its DSN. This tool returns the full roster of devices associated with the authenticated account, including connection status and MAC addresses.

Contextual usage notes: The model will frequently use this tool first to map human-readable device models (e.g., "the HVAC units") to their required DSN strings.

"Fetch a list of all devices currently connected to our Ayla account. Give me a breakdown of which ones have a status of 'offline' and include their serial numbers."

list_all_ayla_networks_properties

Because Ayla relies on the digital twin abstraction, the LLM must interrogate a device to see what capabilities it has. This tool accepts a DSN and returns all the properties available for that specific hardware, including whether those properties are read-only or read-write.

Contextual usage notes: If a user asks to change the temperature, the LLM will call this tool to discover if the specific parameter is named target_temp, temp_setpoint, or cooling_target.

"Look up the properties for the device with DSN 'AC123456789'. I need to know the exact property name used for setting the fan speed."

ayla_networks_datapoints_create_by_dsn

This is how state changes happen in Ayla. You do not update the device directly; you append a new datapoint to a specific property on that device. This tool accepts the DSN, the property name, and the new value payload.

Contextual usage notes: The LLM will construct the payload based on the data types it learned from the properties list.

"Turn off the main lobby display. Send a new datapoint with the value '0' to the 'power_state' property for DSN 'DISP-999-001'."

create_a_ayla_networks_collection

Collections in Ayla Networks encompass both Groups (static sets of devices) and Scenes (pre-configured states for multiple devices). This tool allows the LLM to orchestrate complex smart environments by bundling devices together.

Contextual usage notes: When creating a scene, the LLM must pass an array of devices and their desired target states.

"Create a new Ayla collection called 'Night Lockdown'. It should be a Scene type that targets all the exterior lighting devices and sets their brightness properties to 20%."

ayla_networks_collections_activate_countdown

A powerful automation tool that activates an existing scene after a specified delay. This bypasses the need for the LLM to stay awake and manually trigger the scene later.

Contextual usage notes: Requires the collection_id generated from the previous tool.

"Activate the 'Night Lockdown' scene, but put it on a 45-minute countdown timer so the warehouse crew has time to leave before the lights dim."

create_a_ayla_networks_rule

Rules move logic from the client layer into the Ayla Cloud. This tool allows the LLM to define logical expressions (e.g., evaluating datapoints or connection states) and map them to actions.

Contextual usage notes: The LLM constructs the logical expression. This is heavily utilized when setting up autonomous behaviors.

"Create a new rule that monitors the temperature properties of the server room HVACs. If any temperature datapoint exceeds 78 degrees, it should trigger the emergency cooling action."

ayla_networks_icc_jobs_retry_selected_devices

Fleet management often involves dealing with failed Over-The-Air (OTA) updates. This tool interacts with the IoT Command Center (ICC) to isolate specific devices that failed a job and issues a retry command.

Contextual usage notes: The LLM will usually query the job status first, identify the failing DSNs, and then pass that array into this tool.

"Check the status of ICC Job ID 4005. Take all the devices that failed the firmware update and queue them for a retry."

For the complete tool inventory, including full schemas for OEM and dealer management, endpoint webhooks, and device templates, check out the Ayla Networks integration page.

Workflows in Action

When you connect Ayla Networks to ChatGPT via a properly configured MCP server, the LLM can autonomously chain these tools together to solve complex IoT challenges. Here are three real-world examples of how an AI agent navigates the Ayla architecture.

1. Provisioning a New Smart Home Scene

Creating a cohesive environment across multiple devices requires querying available assets, determining their capabilities, and bundling them into an actionable collection.

"Find all the smart bulbs in the conference room. Create a scene called 'Presentation Mode' that turns them on and sets their color temperature to 3000K. Then activate that scene immediately."

Execution Steps:

  1. The agent calls list_all_ayla_networks_devices and filters the returned JSON for models matching smart bulbs and custom location tags matching "conference room".
  2. It extracts the DSN for each matching bulb.
  3. It calls list_all_ayla_networks_properties on one of the bulbs to confirm the exact property names for power and color temperature (e.g., pwr_state, color_temp_k).
  4. It calls create_a_ayla_networks_collection with type: "SCENE" and a payload defining the desired datapoints for the targeted DSNs.
  5. It receives the collection_uuid and immediately calls ayla_networks_collections_post_datapoints (or simply activates it) to execute the scene.

Output: The LLM replies confirming the scene was created, listing the specific devices included, and verifying the execution command was sent to the Ayla cloud.

sequenceDiagram
  participant Agent as ChatGPT (Client)
  participant MCP as Truto MCP Server
  participant Ayla as Ayla Networks API
  
  Agent->>MCP: Call list_all_ayla_networks_devices
  MCP->>Ayla: GET /apiv1/devices
  Ayla-->>MCP: [Device Array]
  MCP-->>Agent: DSNs returned
  Agent->>MCP: Call create_a_ayla_networks_collection
  MCP->>Ayla: POST /apiv1/collections
  Ayla-->>MCP: 201 Created (collection_uuid)
  MCP-->>Agent: Scene UUID

2. Diagnosing and Resolving Device Disconnects

When managing a fleet, identifying offline devices and diagnosing their history is a tedious manual task. An AI agent can pull the forensic data instantly.

"Pull a list of all devices that are currently offline. For any device that has been offline for more than 24 hours, retrieve its connection history for the past week to see if it was flapping before it died."

Execution Steps:

  1. The agent calls list_all_ayla_networks_devices.
  2. It parses the resulting JSON, filtering for status: "Offline" and comparing the connected_at timestamp against the current time.
  3. For every device exceeding the 24-hour threshold, it iterates over the DSNs and calls ayla_networks_devices_get_connection_history, passing parameters to sort by event_time.
  4. It aggregates the paginated historical data, looking for rapid connect/disconnect patterns (flapping).

Output: The user receives a synthesized diagnostic report identifying which devices are offline, how long they have been down, and a summary of their network stability prior to the failure.

3. Rapid Hardware Replacement and Re-Registration

When an IoT device breaks, replacing it requires registering the new MAC/DSN and migrating the old location metadata.

"We replaced a faulty thermostat at the Chicago facility. The old DSN was THERM-OLD-99. The new device payload I have is for DSN THERM-NEW-11. Register the new device, update its location to match the old one, and delete the old device record."

Execution Steps:

  1. The agent calls get_single_ayla_networks_device_by_id using the old DSN to retrieve its custom metadata, tags, and location data.
  2. It calls create_a_ayla_networks_device, passing the new device payload (including the new DSN) in the request body.
  3. It calls ayla_networks_devices_update_location on the new DSN, injecting the location data scraped in Step 1.
  4. (Assuming the agent is equipped with a deletion tool via custom methods) It invokes the deletion of the old DSN record to clean up the fleet registry.

Output: The LLM confirms the successful swap, providing the new device ID and verifying the location inheritance.

Security and Access Control

Giving an AI model access to a live, production IoT fleet requires strict governance. Truto's MCP architecture provides several layers of access control built directly into the server URL:

  • Method Filtering: You can configure the config.methods array during server creation to explicitly deny destructive actions. Passing ["read"] ensures the LLM can only execute get and list operations, making it impossible for the agent to accidentally create rules or alter device states.
  • Tag Filtering: Ayla Networks has a massive API surface. By configuring config.tags (e.g., ["devices", "datapoints"]), you restrict the MCP server to exposing only tools related to those specific domains. The LLM won't even know tools for dealers or SSO management exist.
  • Time-to-Live Expiration: The expires_at field allows you to create temporary MCP servers. Once the timestamp is reached, the server is automatically destroyed. This is ideal for granting a contractor or temporary AI agent access to the fleet for a specific debugging session.
  • Secondary Authentication: Enabling require_api_token_auth: true ensures that possessing the MCP URL is not enough to execute a tool. The client framework must also pass a valid Truto API token in the Authorization header, preventing lateral movement if the URL is leaked in internal logs.

Orchestrating the Physical World

Connecting Ayla Networks to ChatGPT bridges the gap between conversational AI and the physical world. Instead of forcing your IT admins and deployment engineers to memorize complex JSON payloads to interact with device properties and templates, they can simply state their intent.

By leveraging an auto-generated MCP server, you offload the massive technical debt of maintaining schema mappings, DSN routing logic, and integration boilerplate. Your agents always have an accurate, up-to-date map of your Ayla API surface, allowing you to focus on building autonomous IoT workflows rather than babysitting API middleware.

More from our Blog