Skip to main content
A configuration-based agent is a class the user never sees. It extends Agent from the Agent Runtime SDK and drives the Agent Harness SDK. This chapter opens it in the order the CLI builds it. This page is the code deploy generates. Configuration follows each field of agent.json into that code. The Harness is where those fields are plugged in, once per activation. Request Handling follows each inbound request to its handler. Turn Taking is the loop itself, from the admitted message to the delivered reply. Every piece named here can be overridden by the user, and Extending the Managed Agent describes how. create writes no code; Project Layout shows the files. The class comes into being at deploy, which generates .telnyx/index.ts from agent.json, with instructions.md inlined so that the deployed function reads no files. For support-agent the file is this, with the spec abbreviated:
Three lines carry the agent.
  • export class SupportAgent extends defineManagedAgent(spec) {} is the agent. defineManagedAgent(spec) is the managed harness bound to this spec, and SupportAgent is the actor type the platform runs, one instance per conversation.
  • mountAgents is the function’s fetch. It serves every conversation at /agents/support-agent/<conversation>.
  • channelRoutes is the fallback for everything else the function receives, which is the webhooks. With web set, the options also carry web, and the fallback serves the chat page at /web and the embed script at /web/embed.js before the webhook routes.
mountAgents(map, { fallback }) is mountAgents().
  • map is the whole routing table. Its one entry serves the actor namespace env.SUPPORT_AGENT under the mount name support-agent.
  • fallback receives every request whose path is outside /agents.
Beside it, deploy writes telnyx.toml, the manifest that names the actor type and its binding, telnyx-env.d.ts with the types, and a package.json. It then links @telnyx/acp and @telnyx/edge-runtime into .telnyx/node_modules, in synth/vendor.ts, so that the bundle built on this machine resolves them. With a phone number, or a Call Control application among the channels, the base is defineManagedVoiceAgent(spec) instead; export writes the same class into src/agent.ts for the user to own, and counts a TeXML application as answering calls too. The module names on the pages that follow, managed/agent.ts and the rest, are files of the @telnyx/acp package.