For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • Configuration
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
        • addSection
        • addVerb
        • addVerbToSection
        • asRouter
        • extractSipUsername
        • getApp
        • getBasicAuthCredentials
        • getBuilder
        • getDocument
        • manualSetProxyUrl
        • onRequest
        • registerRoutingCallback
        • registerVerbHandler
        • renderDocument
        • renderSwml
        • resetDocument
        • run
        • serve
        • setOnRequestCallback
        • stop
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • ChatResource
      • Compat
      • Datasphere
      • Fabric
      • ImportedNumbersResource
      • Logs
      • LookupResource
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSubResource
      • Queues
      • Recordings
      • Registry
      • RestClient
      • RestError
      • Short Codes
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Returns
  • Example
AgentsSWMLService

asRouter

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

extractSipUsername

Next
Built with

Return the underlying Hono app for this service. This is a Python-compat alias for getApp() — use either name interchangeably. Pick asRouter() when porting code from the Python SDK that called as_router() for a FastAPI APIRouter.

Use this to mount the service into an existing Hono application rather than running a standalone server with run() or serve().

Use asRouter() for production deployments where you want to control the HTTP server lifecycle, or when hosting multiple services on the same Hono instance via AgentServer.

Returns

Hono — the configured Hono app with all routes registered (SWML document endpoint plus any routing-callback paths).

Example

1import { Hono } from 'hono';
2import { serve } from '@hono/node-server';
3import { SWMLService } from '@signalwire/sdk';
4
5const app = new Hono();
6
7const service = new SWMLService({ name: 'ivr', route: '/ivr' });
8service.addVerb('answer', {});
9service.addVerb('play', { url: 'https://example.com/welcome.mp3' });
10
11app.route('/ivr', service.asRouter());
12
13serve({ fetch: app.fetch, port: 3000 });