zeroclaw-labs/zeroclaw · error · anyhow::Error

Failed to start AI conversation: {}

Error message

Failed to start AI conversation: {}

What it means

start_ai_conversation POSTs system_prompt and model to Telnyx /v2/calls/{call_control_id}/actions/ai_conversation (voice "alloy", speed 1.0). Non-2xx embeds Telnyx's error body. It fails for stale or unknown call ids, model identifiers Telnyx does not support for AI conversations, or connections/accounts where the AI conversation feature is not enabled.

Source

Thrown at crates/zeroclaw-channels/src/clawdtalk.rs:192

            },
        };

        let response = self
            .client
            .post(format!(
                "{}/calls/{}/actions/ai_conversation",
                Self::TELNYX_API_URL,
                call_control_id
            ))
            .header("Authorization", format!("Bearer {}", self.api_key))
            .header("Content-Type", "application/json")
            .json(&request)
            .send()
            .await?;

        if !response.status().is_success() {
            let error = response.text().await?;
            anyhow::bail!("Failed to start AI conversation: {}", error);
        }

        Ok(())
    }
}

/// Active call session
#[derive(Debug, Clone)]
pub struct CallSession {
    pub call_control_id: String,
    pub call_leg_id: String,
    pub call_session_id: String,
}

/// Telnyx call initiation request
#[derive(Debug, Serialize)]
struct CallRequest {
    connection_id: String,

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Read the embedded Telnyx body — it distinguishes unknown call (404) from invalid model (422)
  2. Run it immediately on an answered leg (after call.answered), never after a fixed delay on an unverified leg
  3. Use a model identifier from Telnyx's AI conversation docs for your account tier
  4. Verify the Call Control application behind connection_id has AI conversation enabled
Defensive patterns

Strategy: try-catch

Try / catch

if let Err(e) = channel.start_ai_conversation(&session.call_control_id, prompt, model).await {
    // inspect the embedded Telnyx body: unknown call vs invalid model vs feature-disabled
    let _ = channel.hangup(&session.call_control_id).await;
}

Prevention

When it happens

Trigger: Invoking it on a leg that already ended (same timing hazard as speak — it must run on an answered call); model string not valid for Telnyx AI conversations; connection_id bound to a Call Control application without AI enabled; api_key lacking the AI scope; prompt exceeding Telnyx limits.

Common situations: Model names copied from OpenAI docs that Telnyx does not expose; sandbox accounts without AI minutes; invoking after voicemail detection ended the leg.

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/e6b84fc37787cdb9. Report an issue: GitHub.