← All Plugins/platform.telnyxHybrid (Python + Go)
AI-Agent-First Documentation
Raw .md/SKILL.md
Prompt your Agent: "Set up valstorm-plugin-telnyx on our Open Valstorm workspace using platform.telnyx and verify its routes and AI tools."

valstorm-plugin-telnyx — Hybrid Telnyx Telephony, Messaging & Voice AI Plugin (NF-476)

Hybrid (Python + Go) Telnyx carrier integration for Open Valstorm, mounted at platform.telnyx (VALSTORM_PLUGINS=telnyx or *).

Provides full-stack enterprise telephony on Open Valstorm's provider-agnostic schemas (phone_number, sms_thread, sms_message, sms_participant, phone_application, call, call_recording):

  • Programmable Messaging (1-on-1 SMS & Group MMS): Deterministic tconv_<sha1> thread fingerprinting, automatic CRM contact matching, VFS MMS media attachments, and 10DLC campaign assignment.
  • Call Control v2 & Custom Python Function IVR: Outbound & inbound calling, answer, bridge, transfer, speak, gather_using_speak, playback_start, record_start, and hangup.
  • High-Throughput Go Webhook Engine (plugins/valstorm-plugin-telnyx/go): Processes telnyx:webhook_event tasks for call state transitions, inbound/outbound SMS/MMS, S3 call recording & voicemail persistence, and Deepgram Nova-2 speaker-diarized transcription.
  • US Local & Toll-Free Number Porting Wizard: Portability checks, draft porting orders, LOA PDF generation, bill/CSR uploads, FOC windows, and FastPort activation.
  • Telnyx Voice AI Assistants: Assistant provisioning, phone number binding, outbound AI test calls, and turn-by-turn transcript extraction.

🤖 Agent-Assisted Quick Setup (Let the Valstorm Agent Set It Up)

You only need your Telnyx API v2 Key (KEY019...) from the Telnyx Mission Control Portal. Your Valstorm AI Agent can use that single key to automatically discover your Call Control Application, Messaging Profile, and active Phone Numbers, configure your tenant webhook URLs, save the encrypted credentials in platform.credentials, sync your phone_number (phnu_) records, register $O(1)$ webhook routing, and verify live connectivity.

1. Quick Human Prerequisite (60 Seconds in Telnyx Mission Control)

  1. Sign in to portal.telnyx.com.
  2. Go to Account Settings -> Keys & Credentials -> API Keys and click Create API Key (copy the KEY... string).
  3. (Optional) Switch to the Public Key tab and copy your Base64 Ed25519 Public Key for webhook signature verification.

2. Copy-Paste Prompt for Your Valstorm Agent

Drop this prompt into Valstorm Chat:

"Set up valstorm-plugin-telnyx using my Telnyx API Key <PASTE_TELNYX_API_KEY> (optional Public Key: <PUBLIC_KEY>). Follow plugins/valstorm-plugin-telnyx/README.md to save the encrypted credentials via platform.credentials.save('telnyx', ...), auto-discover my Messaging Profile, Call Control App, and Phone Numbers, sync them into phone_number records with $O(1)$ webhook routing, and run telnyx_verify_connection."

3. Agent Execution Runbook (Instructions for the AI Agent)

When a user asks you to set up valstorm-plugin-telnyx, execute this sequence autonomously:

  1. Validate & Save Encrypted Telnyx Credentials:
  • Call await platform.telnyx.save_credentials(api_key=..., public_key=..., validate_live=True) (or POST /v1/telnyx/admin/credentials).
  1. Discover & Sync Account Inventory (Dry-Run -> Execute):
  • Call await platform.telnyx.get_account_overview() (telnyx_get_account_overview) to inspect existing Messaging Profiles, Call Control Applications, and Phone Numbers on the Telnyx account.
  • Call await platform.telnyx.sync_phone_numbers() to upsert phone_number (phnu_) records and register every E.164 phone number and connection_id in external_account_routing (provider="telnyx").
  1. Configure Tenant Webhook URL:
  • Configure the Call Control Application and Messaging Profile webhook_url to point to https://<YOUR_API_DOMAIN>/v1/webhooks/telnyx/<ORG_ID>.
  1. Verify Live Connection:
  • Call telnyx_verify_connection and report the account balance, active phone numbers, messaging profile, and webhook routing status back to the user.

🛠️ End-to-End DIY Setup Guide (Manual)

Step 1: Create a Telnyx API v2 Key & Ed25519 Public Key

  1. Log in to portal.telnyx.com.
  2. Navigate to Account Settings -> Keys & Credentials:
  • Copy your API v2 Key (KEY...).
  • Copy your Public Key (Base64 Ed25519 key used to verify telnyx-signature-ed25519 headers).

Step 2: Configure a Messaging Profile & Call Control Application

  1. Messaging -> Programmable Messaging -> Messaging Profiles:
  • Create or select a Messaging Profile and set the Webhook URL to:

https://api.yourdomain.com/v1/webhooks/telnyx/<YOUR_ORG_ID>

  1. Voice -> Programmable Voice -> Call Control Applications:
  • Create or select a Call Control Application and set the Webhook URL to:

https://api.yourdomain.com/v1/webhooks/telnyx/<YOUR_ORG_ID>

Step 3: Save Encrypted Credentials in Open Valstorm

python
await platform.credentials.save(
    "telnyx",
    {
        "api_key": "KEY0192837465...",
        "public_key": "YOUR_ED25519_PUBLIC_KEY",
        "connection_id": "YOUR_CALL_CONTROL_APP_ID",
        "messaging_profile_id": "YOUR_MESSAGING_PROFILE_ID",
        "default_from_number": "+18335832008",
    },
)

Python & Go Usage Examples

Python (platform.telnyx)

python
# 1. Send 1-on-1 SMS or Multi-Party Group MMS (auto-creates `sms_thread` & `sms_message`)
msg = await platform.telnyx.send_sms(
    to_phone="+18605551234",
    from_number="+18335832008",
    message="Hi from Open Valstorm!",
)

# 2. Initiate an Outbound Call (auto-creates `call` record)
call = await platform.telnyx.initiate_call(
    to_phone="+18605551234",
    from_phone="+18335832008",
)

# 3. Search & Order a New Phone Number
available = await platform.telnyx.search_available_numbers(area_code="860", limit=5)
ordered = await platform.telnyx.order_phone_number(phone_number=available[0]["phone_number"])

# 4. Check US Local & Toll-Free Portability
portability = await platform.telnyx.check_portability(["+18605551234", "+18335832008"])

REST API Endpoints (/v1/telnyx/* & /v1/webhooks/telnyx/{org_id})

MethodEndpointDescription
GET/v1/telnyx/setup-guideInteractive Telnyx Mission Control setup guide
POST/v1/telnyx/verifyVerifies Telnyx API Key, balance, and active phone inventory
POST/v1/telnyx/messageSends 1-on-1 SMS or Group MMS & logs sms_message (sms_)
POST/v1/telnyx/conversationCreates or resolves deterministic sms_thread (smst_)
POST/v1/telnyx/callInitiates outbound Call Control v2 call & logs call (call_)
POST/v1/telnyx/calls/{call_control_id}/{action}Executes Call Control action (answer, hangup, bridge, transfer, speak, gather, record_start)
GET/v1/telnyx/admin/overviewReturns Telnyx account balance, numbers, profiles, and apps
POST/v1/telnyx/admin/credentialsValidates and saves encrypted Telnyx API & Public keys
GET/v1/telnyx/admin/numbers/searchSearches available US/Toll-Free phone numbers
POST/v1/telnyx/admin/numbers/orderOrders a phone number and creates phone_number (phnu_)
POST/v1/telnyx/admin/porting/portability-checkChecks US Local & Toll-Free number portability
GET/POST/v1/telnyx/admin/porting/ordersLists or creates Telnyx number porting orders
GET/POST/v1/telnyx/admin/ai-assistantsLists or upserts Telnyx Voice AI Assistants
POST/v1/webhooks/telnyx/{org_id}High-throughput webhook ingress -> enqueues telnyx:webhook_event to Go worker

Running Tests (Python & Go)

bash
# Run Python unit & route integration tests
cd apps/open-api
.venv/bin/pytest tests/test_plugin_telnyx.py -v

# Run Go worker Call Control, SMS/MMS, & Deepgram transcription race tests
cd ../../plugins/valstorm-plugin-telnyx/go
go test -race -v ./...