Integrations•3 min read

Telnyx Agent Onboarding Protocol

This SOP describes how a Valstorm AI Agent handles the command:

"Here is my Telnyx API key: KEY..., please integrate my account."


šŸŽÆ Protocol Overview

When a user provides their Telnyx API key, the agent executes an automated 6-step pipeline to provision resources, sync numbers, configure Voice AI, and enable messaging without requiring manual portal configuration from the user.

User provides API Key │ ā–¼ 1. Validate & Store Key in auth_credential (AES-encrypted) │ ā–¼ 2. Create/Verify Valstorm Messaging Profile (v2 Webhooks) │ ā–¼ 3. Create/Verify Call Control & WebRTC Application │ ā–¼ 4. Discover & Bind Active Phone Numbers │ ā–¼ 5. Provision or Link Default Voice AI Assistant │ ā–¼ 6. Sync to twilio_phone Registry & Report Summary Table

šŸ“‹ Step-by-Step Execution Plan

Step 1: Validate & Encrypt Credentials

  1. Test the key with GET https://api.telnyx.com/v2/balance to confirm authentication and retrieve current account balance.
  2. Check or create an encrypted record in auth_credential:
    JSON
    { "name": "Telnyx - API Key", "provider": "telnyx", "data": { "api_key": "<TELNYX_API_KEY>", "public_key": "<TELNYX_PUBLIC_KEY>" } }
    (Ensure sensitive data is encrypted using encrypt_data() before saving).

Step 2: Provision the Valstorm Messaging Profile

  1. Call GET https://api.telnyx.com/v2/messaging_profiles to check if a profile named Valstorm Messaging Profile already exists.
  2. If not found, call POST https://api.telnyx.com/v2/messaging_profiles:
    JSON
    { "name": "Valstorm Messaging Profile", "enabled": true, "webhook_api_version": "2", "webhook_url": "https://api.valstorm.com/v1/telnyx/{org_id}/webhooks", "webhook_failover_url": "", "mms_fall_back_to_sms": true }
  3. Record messaging_profile_id.

Step 3: Provision Call Control Application

  1. Call GET https://api.telnyx.com/v2/call_control_applications to check for an existing application named Valstorm Voice & Call Control.
  2. If not found, call POST https://api.telnyx.com/v2/call_control_applications:
    JSON
    { "application_name": "Valstorm Voice & Call Control", "webhook_event_url": "https://api.valstorm.com/v1/telnyx/{org_id}/webhooks", "webhook_api_version": "2", "active": true }
  3. Record connection_id.

Step 4: Discover & Bind Phone Numbers

  1. Call GET https://api.telnyx.com/v2/phone_numbers to fetch all active numbers.
  2. For each number:
    • Assign to Messaging Profile: PATCH https://api.telnyx.com/v2/phone_numbers/{phone_number_id}/messaging with {"messaging_profile_id": messaging_profile_id}.
    • Assign to Voice Connection: PATCH https://api.telnyx.com/v2/phone_numbers/{phone_number_id} with {"connection_id": connection_id}.
    • Upsert into Valstorm twilio_phone table:
      JSON
      { "id": "twph_telnyx_<number>", "name": "Telnyx Line - <formatted_number>", "phone_number": "+1XXXXXXXXXX", "provider": "telnyx", "active": true, "telnyx_number_id": "<phone_number_id>", "connection_id": "<connection_id>", "messaging_profile_id": "<messaging_profile_id>", "ai_assistant_enabled": true, "ring_timeout_seconds": 15 }

Step 5: Configure Edge Voice AI Assistant

  1. Check GET https://api.telnyx.com/v2/ai/assistants for an existing assistant.
  2. If none exists, call POST https://api.telnyx.com/v2/ai/assistants:
    • Model: Qwen/Qwen3-235B-A22B or meta-llama/Meta-Llama-3.1-70B-Instruct
    • Transcription: deepgram/flux
    • Voice: Telnyx Ultra
    • Features: ["telephony"]
    • Noise Suppression: krisp
    • Tool Integration: Connect calendar booking webhook or Valstorm MCP server.

Step 6: Confirmation Response to User

The agent presents a structured summary table to the user:

MARKDOWN
āœ… **Telnyx Account Integrated Successfully!** * **Account Balance:** $5.47 USD * **Messaging Profile:** Valstorm Messaging Profile (`4001a145-...`) * **Voice Application:** Valstorm Voice & Call Control (`30720465-...`) * **Voice AI Assistant:** Active (`assistant-acecc482-...`) ### Synced Phone Numbers (Ready for Calling & Texting): | Phone Number | Type | Provider | Voice AI | Status | | :--- | :--- | :--- | :--- | :--- | | **+1 (959) 929-0740** | Local (CT) | Telnyx | Enabled (15s timeout) | Active | | **+1 (959) 251-2553** | Local (CT) | Telnyx | Enabled (15s timeout) | Active | | **+1 (929) 488-1938** | Local (NY) | Telnyx | Enabled (15s timeout) | Active | | **+1 (833) 583-2008** | Toll-Free | Telnyx | Enabled (15s timeout) | Active | You can now select these numbers in **Valstorm Desktop** or **ValPhone Mobile** to make calls, send Group MMS messages, and receive automated lead intake calls.