Skip to main content
POST
https://dashboard.laburen.com
/
api
/
agents
/
{id}
/
query-agent
curl --location --request POST 'https://dashboard.laburen.com/api/agents/cm68elcks00a0y7qaeljq2qin/query-agent' \
--header 'Authorization: Bearer <API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "visitorId": "{{$json.contacts[0].wa_id}}",
    "query": "{{ $('Combino mensaje con cada fletero').last().json.mensaje}}",
    "streaming": false,
    "channel": "whatsapp",
    "channelExternalId": "cmepre3cg0194pmyckdoynlud_cmi4us1tn03ekn1lr7vf230e9_{{ $json.contacts[0].wa_id }}"
}'
{
  "messageId": "clxxxxxxxxxxxxxxxxx",
  "conversationId": "clxxxxxxxxxxxxxxxxx",
  "visitorId": "visitor-abc123",
  "status": "UNRESOLVED"
}
Key Features:
  • Add agent messages to existing or new conversations
  • Support for external channel integrations (WhatsApp, Chatwoot, CRM)
  • Automatic contact creation and association
This endpoint is different from the Query endpoint, which sends user messages and receives AI responses. This endpoint is for adding agent messages to the conversation history.

Path

id
string
required
The ID of the agent (CUID format).

Body

Required

query
string
required
The agent message text to add to the conversation history.

Optional - Basic Configuration

streaming
boolean
default:"false"
If true, responds with Server-Sent Events in real-time.
conversationId
string
ID of the conversation to add the message to. Auto-generated if not provided.
For Chatwoot/CRM integrations: The conversationId format is essential to ensure messages are placed in the correct conversation. Use the format crmchatsappai_{accountId}_{customerId} to match existing conversations. Without the correct format, messages may be added to the wrong conversation thread.
visitorId
string
Unique ID of the visitor/user. Auto-generated if not provided.
channel
string
default:"api"
Source channel for the message. Valid values: api, dashboard, website, form, whatsapp, telegram, slack, meta, crisp, zapier, mail, mercadolibre, agent_builder, chatwoot, crmchatsappai.
channelExternalId
string
External channel identifier for integration with third-party systems. Format varies by integration:
  • WhatsApp: {organizationId}_{agentId}_{telephoneNumber}
Used to link messages from external platforms to conversations in Laburen.
For WhatsApp Embedding: The channelExternalId is essential to ensure messages are placed in the correct conversation. Without it, messages may be added to the wrong conversation thread.
isDraft
boolean
default:"false"
If true, creates a draft message. Requires authentication.
contactId
string
ID of an existing contact to associate with the conversation.

Optional - Contact

contact
object
Contact data to create or associate with the conversation. If a contact with matching email, phone number, or userId exists, it will be used. Otherwise, a new contact will be created.

Optional - Metadata

metadata
object
Additional metadata for the message.

Response (without streaming)

messageId
string
ID of the created message.
conversationId
string
ID of the conversation (save this to continue adding messages to the same conversation).
visitorId
string
ID of the visitor/user.
status
string
Conversation status (e.g., UNRESOLVED, RESOLVED).

Error Responses

Status CodeTypeDescription
401UNAUTHORIZEDMissing or invalid authentication when isDraft is true, or when required for the operation.
404NOT_FOUNDAgent with the specified ID does not exist.
curl --location --request POST 'https://dashboard.laburen.com/api/agents/cm68elcks00a0y7qaeljq2qin/query-agent' \
--header 'Authorization: Bearer <API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "visitorId": "{{$json.contacts[0].wa_id}}",
    "query": "{{ $('Combino mensaje con cada fletero').last().json.mensaje}}",
    "streaming": false,
    "channel": "whatsapp",
    "channelExternalId": "cmepre3cg0194pmyckdoynlud_cmi4us1tn03ekn1lr7vf230e9_{{ $json.contacts[0].wa_id }}"
}'
{
  "messageId": "clxxxxxxxxxxxxxxxxx",
  "conversationId": "clxxxxxxxxxxxxxxxxx",
  "visitorId": "visitor-abc123",
  "status": "UNRESOLVED"
}

Integration Examples

WhatsApp Embedding Integration

When integrating with WhatsApp via our app
{
  "visitorId": "{{$json.contacts[0].wa_id}}",
  "query": "{{ $('Combino mensaje con cada fletero').last().json.mensaje}}",
  "streaming": false,
  "channel": "whatsapp",
  "channelExternalId": "{organizationId}_{agentId}_{{$json.contacts[0].wa_id}}"
}
The channelExternalId format: {organizationId}_{agentId}_{telephoneNumber}
Critical: The channelExternalId is essential for WhatsApp Embedding integration. Without it, messages will not be placed in the correct conversation thread. Always include this field with the exact format {organizationId}_{agentId}_{telephoneNumber} when using WhatsApp channel.

Chatwoot

For our chatwoot or external ones:
{
  "visitorId": "crmchatsappai_{accountId}_{customerId}",
  "query": "Your message text here",
  "conversationId": "crmchatsappai_{accountId}_{customerId}",
  "streaming": false,
  "channel": "api"
}
Critical: The conversationId format is essential for Chatwoot/CRM integrations. Use the exact format crmchatsappai_{accountId}_{customerId} to match existing conversations. Without the correct format, messages will not be placed in the correct conversation thread.