Agentes & Chat
Agent - Query with Routing
POST
/
agents
/
{id}
/
query-with-routing
Chat con routing automático de agente
curl --request POST \
--url https://app.braviloai.com/api/agents/{id}/query-with-routing \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"conversationId": "<string>",
"streaming": true,
"channel": "dashboard",
"machineId": "<string>",
"fromUrl": "<string>"
}
'import requests
url = "https://app.braviloai.com/api/agents/{id}/query-with-routing"
payload = {
"query": "<string>",
"conversationId": "<string>",
"streaming": True,
"channel": "dashboard",
"machineId": "<string>",
"fromUrl": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
conversationId: '<string>',
streaming: true,
channel: 'dashboard',
machineId: '<string>',
fromUrl: '<string>'
})
};
fetch('https://app.braviloai.com/api/agents/{id}/query-with-routing', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.braviloai.com/api/agents/{id}/query-with-routing",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => '<string>',
'conversationId' => '<string>',
'streaming' => true,
'channel' => 'dashboard',
'machineId' => '<string>',
'fromUrl' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.braviloai.com/api/agents/{id}/query-with-routing"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"conversationId\": \"<string>\",\n \"streaming\": true,\n \"channel\": \"dashboard\",\n \"machineId\": \"<string>\",\n \"fromUrl\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.braviloai.com/api/agents/{id}/query-with-routing")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"conversationId\": \"<string>\",\n \"streaming\": true,\n \"channel\": \"dashboard\",\n \"machineId\": \"<string>\",\n \"fromUrl\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.braviloai.com/api/agents/{id}/query-with-routing")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"conversationId\": \"<string>\",\n \"streaming\": true,\n \"channel\": \"dashboard\",\n \"machineId\": \"<string>\",\n \"fromUrl\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyEnvía un mensaje a un agente con routing automático. Si hay triggers configurados, Bravilo detecta el agente correcto según el contexto y redirige la conversación.
Streaming
Cuandostreaming está habilitado, el endpoint devuelve un stream text/event-stream con eventos SSE:
import { fetchEventSource } from '@microsoft/fetch-event-source';
const ctrl = new AbortController();
await fetchEventSource(`https://app.braviloai.com/api/agents/${agentId}/query-with-routing`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
signal: ctrl.signal,
body: JSON.stringify({
query: 'Hola, quiero saber el estado de mi pedido #1234',
streaming: true,
conversationId,
}),
onmessage: (event) => {
if (event.event === 'routing') {
console.log('Routing:', JSON.parse(event.data));
} else if (event.event === 'answer') {
console.log('Chunk:', event.data);
} else if (event.data === '[DONE]') {
ctrl.abort();
},
});
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
ID del agente
Body
application/json
Response
Respuesta del agente o stream SSE
⌘I
Chat con routing automático de agente
curl --request POST \
--url https://app.braviloai.com/api/agents/{id}/query-with-routing \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"conversationId": "<string>",
"streaming": true,
"channel": "dashboard",
"machineId": "<string>",
"fromUrl": "<string>"
}
'import requests
url = "https://app.braviloai.com/api/agents/{id}/query-with-routing"
payload = {
"query": "<string>",
"conversationId": "<string>",
"streaming": True,
"channel": "dashboard",
"machineId": "<string>",
"fromUrl": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
conversationId: '<string>',
streaming: true,
channel: 'dashboard',
machineId: '<string>',
fromUrl: '<string>'
})
};
fetch('https://app.braviloai.com/api/agents/{id}/query-with-routing', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.braviloai.com/api/agents/{id}/query-with-routing",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => '<string>',
'conversationId' => '<string>',
'streaming' => true,
'channel' => 'dashboard',
'machineId' => '<string>',
'fromUrl' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.braviloai.com/api/agents/{id}/query-with-routing"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"conversationId\": \"<string>\",\n \"streaming\": true,\n \"channel\": \"dashboard\",\n \"machineId\": \"<string>\",\n \"fromUrl\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.braviloai.com/api/agents/{id}/query-with-routing")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"conversationId\": \"<string>\",\n \"streaming\": true,\n \"channel\": \"dashboard\",\n \"machineId\": \"<string>\",\n \"fromUrl\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.braviloai.com/api/agents/{id}/query-with-routing")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"conversationId\": \"<string>\",\n \"streaming\": true,\n \"channel\": \"dashboard\",\n \"machineId\": \"<string>\",\n \"fromUrl\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body
