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

# Message Response Webhook Request Body

> This endpoint must be implemented on YOUR server (e.g., https://yourdomain.com/webhooks/on-response). Treble will call this webhook when a user responds to a question in the conversation. You must configure the URL of this webhook in the Treble admin panel.



## OpenAPI

````yaml open-api-files/treble-api-en.json POST /webhooks/on-response
openapi: 3.0.1
info:
  title: Treble Poll API
  description: Documentation for the poll deployment endpoint in Treble
  version: 1.0.0
servers:
  - url: https://main.treble.ai
    description: Main Treble server
  - url: https://yourdomain.com
    description: >-
      Example server for implementing webhooks. This represents YOUR server
      where you must implement the endpoints that Treble will call.
security: []
tags:
  - name: Webhooks
    description: >-
      Endpoints that Treble will call on your server. These are not real
      endpoints that you can call, but a representation of the webhooks that
      Treble will invoke in your system.
paths:
  /webhooks/on-response:
    post:
      tags:
        - Webhooks
      summary: Webhook - When a user responds to a question
      description: >-
        This endpoint must be implemented on YOUR server (e.g.,
        https://yourdomain.com/webhooks/on-response). Treble will call this
        webhook when a user responds to a question in the conversation. You must
        configure the URL of this webhook in the Treble admin panel.
      requestBody:
        description: Information of the response event
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponseEvent'
            example:
              country_code: '+57'
              cellphone: '3161234567'
              session_id: '1234'
              conversation_id: '5678'
              question:
                type: closed
                text: conversation-question-text
                answers:
                  - text: answer-text
              sent_at: '2019-01-01 00:00:00'
              responded_at: '2019-01-01 00:00:00'
              sent_text: text-sent-to-user
              actual_response: Yes I need it
              classified_answer:
                text: answer-text
              user_session_keys:
                - key: name
                  value: John
                  type: null
                - key: user_id
                  value: '12345'
                  type: null
                - key: loc
                  value: >-
                    {"latitude": 4.5935443, "longitude": -72.0345404, "address":
                    "Carrera 7 #100-06"}
                  type: location
      responses:
        '200':
          description: Response to update or add information to the session
          content:
            application/json:
              schema:
                type: object
                description: >-
                  JSON object with the new information that will be replaced or
                  added to the session for future use. The service must respond
                  in less than 10 seconds.
      servers:
        - url: https://yourdomain.com
          description: Your server where you must implement this webhook
components:
  schemas:
    ResponseEvent:
      type: object
      required:
        - country_code
        - cellphone
        - session_id
        - conversation_id
        - question
        - sent_at
        - responded_at
        - sent_text
        - actual_response
        - classified_answer
        - user_session_keys
      description: >-
        Event that is triggered when a user responds to a question in the
        conversation
      properties:
        country_code:
          type: string
          description: Country code of the user
        cellphone:
          type: string
          description: User's phone number without the country code
        session_id:
          type: string
          description: ID of the user's session
        conversation_id:
          type: string
          description: ID of the conversation
        question:
          $ref: '#/components/schemas/ClosedQuestion'
        sent_at:
          type: string
          format: date-time
          description: Date and time when the question was sent
        responded_at:
          type: string
          format: date-time
          description: Date and time when the user responded to the question
        sent_text:
          type: string
          description: Text sent to the user
        actual_response:
          type: string
          description: Literal response provided by the user
        classified_answer:
          $ref: '#/components/schemas/Answer'
          description: Classified answer based on the user's response
        user_session_keys:
          type: array
          description: >-
            User session keys collected during the conversation or provided
            during the deployment
          items:
            $ref: '#/components/schemas/ExtendedUserSessionKey'
    ClosedQuestion:
      type: object
      required:
        - type
        - text
        - answers
      properties:
        type:
          type: string
          description: Type of question
          example: closed
        text:
          type: string
          description: Text of the question
        answers:
          type: array
          description: Possible answers for the closed question
          items:
            type: object
            properties:
              text:
                type: string
                description: Text of the answer
    Answer:
      type: object
      required:
        - text
      properties:
        text:
          type: string
          description: Text of the answer
    ExtendedUserSessionKey:
      type: object
      required:
        - key
        - value
      properties:
        key:
          type: string
          description: Name of the variable
        value:
          type: string
          description: Value of the variable
        type:
          type: string
          nullable: true
          description: >-
            Type of the variable. Can be null or a specific type like
            'location'.

````