> ## Documentation Index
> Fetch the complete documentation index at: https://docs.poly.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Respond to a chat

> Sends a user message to an existing conversation and returns the agent's response.

## Custom parameters

The respond endpoint supports additional parameters for advanced use cases:

<ParamField body="integration_attributes" type="object">
  Custom metadata to pass to the conversation. This data is accessible in functions through `conv.integration_attributes`.

  **Example**:

  ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
  {
    "integration_attributes": {
      "page_url": "https://example.com/checkout",
      "cart_value": "99.99"
    }
  }
  ```
</ParamField>

<ParamField body="asr_lang_code" type="string">
  Language code for speech recognition (e.g., `"en-US"`, `"es-ES"`).
</ParamField>

<ParamField body="tts_lang_code" type="string">
  Language code for text-to-speech (e.g., `"en-US"`, `"es-ES"`).
</ParamField>

## Custom parameters

<ParamField body="metadata" type="object">
  Custom metadata for this specific message. Accessible in functions during this turn.

  **Example**:

  ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
  {
    "metadata": {
      "user_action": "clicked_button",
      "button_id": "confirm_booking"
    }
  }
  ```
</ParamField>

<ParamField body="asr_lang_code" type="string">
  Language code for speech recognition (e.g., `"en-US"`, `"es-ES"`).
</ParamField>

<ParamField body="tts_lang_code" type="string">
  Language code for text-to-speech (e.g., `"en-US"`, `"es-ES"`).
</ParamField>


## OpenAPI

````yaml POST /{version}/{account_id}/{project_id}/chat/respond
openapi: 3.0.0
info:
  title: Chat API
  description: API endpoints for chat functionality.
  version: 1.0.0
servers:
  - url: https://api.us-1.platform.polyai.app
    description: Hostname for US-1 region
  - url: https://api.uk-1.platform.polyai.app
    description: Hostname for UK-1 region
  - url: https://api.euw-1.platform.polyai.app
    description: Hostname for EUW-1 region
security:
  - ApiKeyAuth: []
  - TokenAuth: []
paths:
  /{version}/{account_id}/{project_id}/chat/respond:
    post:
      summary: Send a message to an existing chat conversation
      description: >-
        Sends a user message to an existing conversation and returns the agent's
        response.
      operationId: chatRespond
      parameters:
        - $ref: '#/components/parameters/ApiKeyHeader'
        - $ref: '#/components/parameters/TokenHeader'
        - name: version
          in: path
          description: API version
          required: true
          schema:
            type: string
          example: v1
        - name: account_id
          in: path
          description: Account ID
          required: true
          schema:
            type: string
          example: ACCOUNT-xxxxxxxx
        - name: project_id
          in: path
          description: Project ID
          required: true
          schema:
            type: string
          example: PROJECT-xxxxxxxx
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RespondChatRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RespondChatResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - ApiKeyAuth: []
        - TokenAuth: []
components:
  parameters:
    ApiKeyHeader:
      name: X-API-KEY
      in: header
      description: Your PolyAI API key.
      required: true
      schema:
        type: string
    TokenHeader:
      name: X-TOKEN
      in: header
      description: Agent authentication token (connector).
      required: true
      schema:
        type: string
  schemas:
    RespondChatRequest:
      type: object
      properties:
        conversation_id:
          type: string
          description: ID of the conversation to respond to
          example: CONV-1234567890
        message:
          type: string
          description: Message to send to the agent
          example: Hello again
      required:
        - conversation_id
    RespondChatResponse:
      type: object
      properties:
        conversation_id:
          type: string
          description: ID of the conversation
          example: CONV-1234567890
        response:
          type: string
          description: Response message from the agent
          example: Transferring you to an agent.
        end_conversation:
          type: boolean
          description: Whether the conversation should be ended
          example: true
        handoff:
          type: object
          description: Information about handoff if applicable
          properties:
            destination:
              type: string
              description: Destination for the handoff
              example: live_agent_queue
            reason:
              type: string
              description: Reason for the handoff
              example: billing_question
      required:
        - conversation_id
        - response
        - end_conversation
    Error:
      type: object
      properties:
        error_message:
          type: string
          description: Reason for error
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: You must request an API Key to use PolyAI APIs.
    TokenAuth:
      type: apiKey
      in: header
      name: X-TOKEN
      description: Authentication token provisioned in Agent Studio.

````