Articles

  • Getting Started
  • Advantar AI
  • Use Cases
  • Functionalities
  • Tools
  • API
  • Frequent Questions
  • Terms of Service

Process Message

Process Message

Sends a message to be processed by a specific agent and returns the response.

  • URL:
    /process/api_process_message
  • Method: POST
  • Headers:
    • Content-Type: application/json
    • X-API-Key: YOUR_API_KEY_HERE
  • Body:
    • agent: string (required)
    • new_message: string (required)
    • conversation_id: string (optional, defaults to "API_Chat")

Example Request

import requests
import json

BASE_URL = "https://advantar.ai/process"
API_KEY = "YOUR_API_KEY_HERE"

headers = {
    "Content-Type": "application/json",
    "X-API-Key": API_KEY
}

data = {
    "agent": "Agent1",
    "new_message": "What's the weather like today?",
    "conversation_id": "weather_chat"
}

response = requests.post(
    f"{BASE_URL}/process/api_process_message",
    headers=headers,
    json=data,
    stream=True
)

for line in response.iter_lines():
    if line:
        decoded_line = line.decode('utf-8')
        if decoded_line.startswith("data: "):
            event_data = json.loads(decoded_line[6:])
            print("Received event:", event_data)
            if event_data.get("role") == "assistant":
                print("Final response:", event_data.get("content"))
                break

Example Response

The response is streamed as Server-Sent Events (SSE). Each event is a JSON object with the following structure:

{
  "role": "tool",
  "content": "Intermediate response content"
}

The final response will have the "role" set to "assistant":

{
  "role": "assistant",
  "content": "Based on the current weather data, it's sunny with a high of 75°F (24°C) today."
}

Subtopics