> ## 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.

# Condition Node Webhook Request Body

> This endpoint must be implemented on YOUR server (e.g., https://yourdomain.com/webhooks/on-condition). Treble will call this webhook when a conditional node is evaluated in the conversation. You must configure the URL of this webhook in the Treble admin panel.

You can also configure the response webhook for each path that exits from a condition node.

<img src="https://mintcdn.com/trebleai/9CTpLCIjWruVB-9s/images/condition-api-1.png?fit=max&auto=format&n=9CTpLCIjWruVB-9s&q=85&s=e7d70bee3b08a181f6d2f4d3245ca6d8" alt="Configure condition node webhook" width="2326" height="1344" data-path="images/condition-api-1.png" />

If you do this, the HTTP request body that is sent to the endpoint configured in Treble will add the following field to the request body:

```json theme={null}
{
    "condition": {
	    "operator": "EQ",
        "value": "18"
    }
}
```

The condition is an object with an `operator` property to show which action was used in the condition and a `value` for the condition action to be evaluated:

* Equal: EQ
* Different: DIFF
* Greater than: GT
* Less than: LT
* Greater than or equal to: GTEQ
* Less than or equal to: LTEQ
* Contains: CONT
* Does not contain: NCONT
* Default path: DEFAULT

The response can also have new variables for the session that can be updated or created for later use in the session. That is, you can add them in the webhook response as part of the `user_session_keys`.


## OpenAPI

````yaml open-api-files/treble-api-en.json POST /webhooks/on-condition
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-condition:
    post:
      tags:
        - Webhooks
      summary: Webhook - When a conditional node is evaluated
      description: >-
        This endpoint must be implemented on YOUR server (e.g.,
        https://yourdomain.com/webhooks/on-condition). Treble will call this
        webhook when a conditional node is evaluated in the conversation. You
        must configure the URL of this webhook in the Treble admin panel.
      requestBody:
        description: Information of the condition evaluation event
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConditionEvent'
            example:
              country_code: '+57'
              cellphone: '3161234567'
              session_id: abcsderfwer3252432423-1324325235
              conversation_id: 1234
              variable:
                name: age
                value: '18'
              condition:
                operator: EQ
                value: '18'
              user_session_keys:
                - key: age
                  value: '18'
                  type: null
                - key: user_id
                  value: '12345'
                  type: null
      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:
    ConditionEvent:
      type: object
      required:
        - country_code
        - cellphone
        - session_id
        - conversation_id
        - variable
        - condition
        - user_session_keys
      description: >-
        Event that is triggered when a conditional node is evaluated 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: integer
          description: ID of the conversation
        variable:
          $ref: '#/components/schemas/Variable'
          description: Variable that is evaluated in the condition
        condition:
          $ref: '#/components/schemas/Condition'
          description: Condition that is evaluated
        user_session_keys:
          type: array
          description: >-
            User session keys collected during the conversation or provided
            during the deployment
          items:
            $ref: '#/components/schemas/ExtendedUserSessionKey'
    Variable:
      type: object
      required:
        - name
        - value
      properties:
        name:
          type: string
          description: Name of the variable that is evaluated in the condition
        value:
          type: string
          description: Current value of the variable
    Condition:
      type: object
      required:
        - operator
        - value
      properties:
        operator:
          type: string
          description: >-
            Operator used to evaluate the condition (e.g.: 'EQ' for equal, 'GT'
            for greater than, etc.)
          enum:
            - EQ
            - GT
            - LT
            - GTE
            - LTE
            - NEQ
        value:
          type: string
          description: Value against which the variable is compared
    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'.

````