---
updatedAt: 2026-08-06T09:23:13.000Z
agentTools:
  projectIndex: https://developers.alcmeon.com/llms.txt
---

# Ask for an AI generated answer to send to a social network user (V2)

V2 webhook to implement to send an AI generated answer to a social network user. This version supports custom exits and enhanced variable handling. This webhook can be protected by checking the api key with the value you defined in the bot configuration in Alcméon. The JWT token is valid for 60 seconds and allows only 1 API call.


# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "AI Webhooks",
    "version": "1.0"
  },
  "x-readme": {
    "explorer-enabled": false
  },
  "components": {
    "schemas": {
      "HTTPError": {
        "properties": {
          "detail": {
            "type": "object"
          },
          "message": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "RateLimitResponseError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Rate limit reached"
          },
          "details": {
            "type": "string",
            "description": "A string showing the time when the rate limit will be reset. Example: {'rate_limited_until': '2024-01-22T13:05:41Z'}\n"
          }
        }
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "apiKey"
      }
    }
  },
  "paths": {
    "/ai-v2-bot": {
      "post": {
        "tags": [
          "Invoke AI Bot V2"
        ],
        "summary": "Ask for an AI generated answer to send to a social network user (V2)",
        "description": "V2 webhook to implement to send an AI generated answer to a social network user. This version supports custom exits and enhanced variable handling. This webhook can be protected by checking the api key with the value you defined in the bot configuration in Alcméon. The JWT token is valid for 60 seconds and allows only 1 API call.\n",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "jwt",
                  "query",
                  "session",
                  "exits"
                ],
                "properties": {
                  "jwt": {
                    "type": "object",
                    "description": "JWT token object to authenticate the callback and send the AI-generated answer back to Alcméon",
                    "required": [
                      "token",
                      "exp",
                      "remaining_api_calls"
                    ],
                    "properties": {
                      "token": {
                        "type": "string",
                        "description": "The JWT token string to use in the X-JWT header when calling back the /ai/v2/answer endpoint. Valid for 60 seconds."
                      },
                      "exp": {
                        "type": "integer",
                        "description": "Token expiration timestamp (Unix timestamp)"
                      },
                      "remaining_api_calls": {
                        "type": "integer",
                        "description": "Number of remaining API calls allowed with this token (currently always 1)"
                      }
                    }
                  },
                  "query": {
                    "type": "string",
                    "description": "The user's message content that the AI should respond to"
                  },
                  "context": {
                    "type": "string",
                    "nullable": true,
                    "description": "Optional additional context that can be set via bot variables (variable name 'message_context') to provide extra information to the AI"
                  },
                  "session": {
                    "type": "object",
                    "required": [
                      "id"
                    ],
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Correlation identifier for the AI agent to scope the conversation and maintain context across multiple messages (variable name 'session_id')"
                      }
                    }
                  },
                  "social_media_user": {
                    "type": "object",
                    "nullable": true,
                    "description": "Information about the social media user who sent the message",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "The external user identifier in the social network (e.g., Twitter user ID, Facebook user ID)"
                      },
                      "name": {
                        "type": "string",
                        "nullable": true,
                        "description": "The display name of the user on the social network"
                      }
                    }
                  },
                  "social_media_account": {
                    "type": "object",
                    "nullable": true,
                    "description": "Information about the social media channel/account where the conversation is happening",
                    "properties": {
                      "id": {
                        "type": "integer",
                        "description": "The site/channel identifier in Alcméon"
                      },
                      "type": {
                        "type": "string",
                        "description": "The social media platform type (e.g., 'twitter', 'facebook', 'instagram', 'whatsapp')"
                      },
                      "max_message_content_length": {
                        "type": "integer",
                        "description": "Maximum character length allowed for a single message on this channel (varies by platform)"
                      },
                      "supported_message_types": {
                        "type": "array",
                        "description": "List of message content types supported by this channel. Currently only 'text' is supported.",
                        "items": {
                          "type": "string",
                          "enum": [
                            "text"
                          ]
                        }
                      },
                      "supported_attachment_types": {
                        "type": "array",
                        "description": "List of attachment types supported by this channel (e.g., images, files). Currently empty - may be extended in the future.",
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "exits": {
                    "type": "array",
                    "description": "List of available exits that the AI can choose from to determine the next step in the bot scenario",
                    "items": {
                      "type": "object",
                      "required": [
                        "code",
                        "description",
                        "is_custom"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "description": "The exit code identifier (e.g., 'endDiscussion', 'continueDiscussion', 'escalateToHuman', 'error', or custom codes)"
                        },
                        "description": {
                          "type": "string",
                          "description": "Human-readable description of what this exit represents"
                        },
                        "is_custom": {
                          "type": "boolean",
                          "description": "True if this is a custom exit defined in the AI Agent configuration, false for standard exits"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Request acknowledged successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "Acknowledged"
                      ],
                      "description": "Indicates the request was received and is being processed"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid input or authentication error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimitResponseError"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    }
  }
}
```