Chat Mode

Configure your agent for text-only conversations with chat mode

Chat mode allows your agents to act as chat agents, ie to have text-only conversations without audio input/output. This is useful for building chat interfaces, testing agents, or when audio is not required.

Overview

There are two main ways to enable chat mode:

  1. Agent Configuration: Configure your agent for text-only mode when creating it via the API
  2. Runtime Overrides: Use SDK overrides to enforce text-only conversations programmatically

This guide covers both approaches and how to implement chat mode across different SDKs.

Creating Text-Only Agents

You can configure an agent for text-only mode when creating it via the API. This sets the default behavior for all conversations with that agent.

1from elevenlabs import ConversationalConfig, ConversationConfig, ElevenLabs
2
3client = ElevenLabs(
4 api_key="YOUR_API_KEY",
5)
6
7# Create agent with text-only configuration
8agent = client.conversational_ai.agents.create(
9 name="My Chat Agent",
10 conversation_config=ConversationalConfig(
11 conversation=ConversationConfig(
12 text_only=True
13 )
14 ),
15)
16print(agent)

For complete API reference and all available configuration options, see the text only field in Create Agent API documentation.

JavaScript SDK

Text-Only Configuration

To use the JavaScript SDK in chat mode with text-only conversations, add the textOnly override to your conversation configuration:

1const conversation = await Conversation.startSession({
2 agentId: '<your-agent-id>',
3 overrides: {
4 conversation: {
5 textOnly: true,
6 },
7 },
8});

This configuration ensures that:

  • No audio input/output is used
  • All communication happens through text messages
  • The conversation operates in a chat-like interface mode

Python SDK

Text-Only Configuration

For the Python SDK, configure the conversation for text-only mode:

1from elevenlabs.client import ElevenLabs
2from elevenlabs.conversational_ai.conversation import Conversation, ConversationInitiationData
3
4elevenlabs = ElevenLabs(api_key=api_key)
5
6# Configure for text-only mode with proper structure
7conversation_override = {
8 "conversation": {
9 "text_only": True
10 }
11}
12
13config = ConversationInitiationData(
14 conversation_config_override=conversation_override
15)
16
17conversation = Conversation(
18 elevenlabs,
19 agent_id,
20 requires_auth=bool(api_key),
21 config=config,
22 # Important: Ensure agent_response callback is set
23 callback_agent_response=lambda response: print(f"Agent: {response}"),
24 callback_user_transcript=lambda transcript: print(f"User: {transcript}"),
25)
26
27conversation.start_session()

Important Notes

Critical: When using chat mode, you must ensure the agent_response event/callback is activated and properly configured. Without this, the agent’s text responses will not be sent or displayed to the user.

Security Overrides: When using runtime overrides (not agent-level configuration), you must enable the conversation overrides in your agent’s security settings. Navigate to your agent’s Security tab and enable the appropriate overrides. For more details, see the Overrides documentation.

Key Requirements

  1. Agent Response Event: Always configure the agent_response callback or event handler to receive and display the agent’s text messages.

  2. Agent Configuration: If your agent is specifically set to chat mode in the agent settings, it will automatically use text-only conversations without requiring the override.

  3. No Audio Interface: When using text-only mode, you don’t need to configure audio interfaces or request microphone permissions.

Example: Handling Agent Responses

1const conversation = await Conversation.startSession({
2 agentId: '<your-agent-id>',
3 overrides: {
4 conversation: {
5 textOnly: true,
6 },
7 },
8 // Critical: Handle agent responses
9 onMessage: (message) => {
10 if (message.type === 'agent_response') {
11 console.log('Agent:', message.text);
12 // Display in your UI
13 displayAgentMessage(message.text);
14 }
15 },
16});

Sending Text Messages

In chat mode, you’ll need to send user messages programmatically instead of through audio:

1// Send a text message to the agent
2conversation.sendUserMessage({
3 text: 'Hello, how can you help me today?',
4});

Use Cases

Chat mode is ideal for:

  • Chat Interfaces: Building traditional chat UIs without voice
  • Testing: Testing agent logic without audio dependencies
  • Accessibility: Providing text-based alternatives for users
  • Silent Environments: When audio input/output is not appropriate
  • Integration Testing: Automated testing of agent conversations

Troubleshooting

Agent Not Responding

If the agent’s responses are not appearing:

  1. Verify the agent_response callback is properly configured
  2. Check that the agent is configured for chat mode or the textOnly override is set
  3. Ensure the WebSocket connection is established successfully

Next Steps