curl --request POST \
--url https://api.lehar.ai/ca/api/v0/agent/{agent_id}/whatsapp/test-reply \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data @- <<EOF
{
"message": "Sure, I'm based in Pune.",
"conversation": [
{
"direction": "outbound",
"text": "Hi! Is now a good time to chat about the offer?"
},
{
"direction": "inbound",
"text": "Yes, go ahead."
},
{
"direction": "outbound",
"text": "Great - which city are you based in?"
}
],
"memory": {
"collected_fields": {}
},
"variables": {
"customer_name": "Asha"
}
}
EOFimport requests
url = "https://api.lehar.ai/ca/api/v0/agent/{agent_id}/whatsapp/test-reply"
payload = {
"message": "Sure, I'm based in Pune.",
"conversation": [
{
"direction": "outbound",
"text": "Hi! Is now a good time to chat about the offer?"
},
{
"direction": "inbound",
"text": "Yes, go ahead."
},
{
"direction": "outbound",
"text": "Great - which city are you based in?"
}
],
"memory": { "collected_fields": {} },
"variables": { "customer_name": "Asha" }
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
message: 'Sure, I\'m based in Pune.',
conversation: [
{direction: 'outbound', text: 'Hi! Is now a good time to chat about the offer?'},
{direction: 'inbound', text: 'Yes, go ahead.'},
{direction: 'outbound', text: 'Great - which city are you based in?'}
],
memory: {collected_fields: {}},
variables: {customer_name: 'Asha'}
})
};
fetch('https://api.lehar.ai/ca/api/v0/agent/{agent_id}/whatsapp/test-reply', 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://api.lehar.ai/ca/api/v0/agent/{agent_id}/whatsapp/test-reply",
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([
'message' => 'Sure, I\'m based in Pune.',
'conversation' => [
[
'direction' => 'outbound',
'text' => 'Hi! Is now a good time to chat about the offer?'
],
[
'direction' => 'inbound',
'text' => 'Yes, go ahead.'
],
[
'direction' => 'outbound',
'text' => 'Great - which city are you based in?'
]
],
'memory' => [
'collected_fields' => [
]
],
'variables' => [
'customer_name' => 'Asha'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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://api.lehar.ai/ca/api/v0/agent/{agent_id}/whatsapp/test-reply"
payload := strings.NewReader("{\n \"message\": \"Sure, I'm based in Pune.\",\n \"conversation\": [\n {\n \"direction\": \"outbound\",\n \"text\": \"Hi! Is now a good time to chat about the offer?\"\n },\n {\n \"direction\": \"inbound\",\n \"text\": \"Yes, go ahead.\"\n },\n {\n \"direction\": \"outbound\",\n \"text\": \"Great - which city are you based in?\"\n }\n ],\n \"memory\": {\n \"collected_fields\": {}\n },\n \"variables\": {\n \"customer_name\": \"Asha\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
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://api.lehar.ai/ca/api/v0/agent/{agent_id}/whatsapp/test-reply")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"Sure, I'm based in Pune.\",\n \"conversation\": [\n {\n \"direction\": \"outbound\",\n \"text\": \"Hi! Is now a good time to chat about the offer?\"\n },\n {\n \"direction\": \"inbound\",\n \"text\": \"Yes, go ahead.\"\n },\n {\n \"direction\": \"outbound\",\n \"text\": \"Great - which city are you based in?\"\n }\n ],\n \"memory\": {\n \"collected_fields\": {}\n },\n \"variables\": {\n \"customer_name\": \"Asha\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lehar.ai/ca/api/v0/agent/{agent_id}/whatsapp/test-reply")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"message\": \"Sure, I'm based in Pune.\",\n \"conversation\": [\n {\n \"direction\": \"outbound\",\n \"text\": \"Hi! Is now a good time to chat about the offer?\"\n },\n {\n \"direction\": \"inbound\",\n \"text\": \"Yes, go ahead.\"\n },\n {\n \"direction\": \"outbound\",\n \"text\": \"Great - which city are you based in?\"\n }\n ],\n \"memory\": {\n \"collected_fields\": {}\n },\n \"variables\": {\n \"customer_name\": \"Asha\"\n }\n}"
response = http.request(request)
puts response.read_body{
"reply_text": "Thanks, Asha! Noted - Pune. Are you looking to buy within the next 3 months?",
"decision": "reply",
"reason": "Collected the customer's city; still need their buying timeline.",
"memory": {
"collected_fields": {
"city": "Pune"
}
},
"collected_fields": {
"city": "Pune"
},
"qualification_status": "pending"
}{
"error": {
"code": "invalid_request",
"message": "message is required"
}
}{
"error": {
"code": "unauthorized",
"message": "Authentication required"
}
}{
"error": {
"code": "forbidden",
"message": "Scope 'sessions:write' is required"
}
}{
"error": {
"code": "not_found",
"message": "Agent 'agent_7f3a1c9e' not found"
}
}{
"error": {
"code": "internal_error",
"message": "An unexpected error occurred"
}
}Generate a WhatsApp test reply
Runs the production WhatsApp reply engine against a caller-supplied transcript for an in-dashboard test chat. Stateless and text-only: nothing is persisted, no message is sent via TrustSignal, and voice escalation is disabled. The agent must be a WhatsApp-channel agent. Scope sessions:write.
curl --request POST \
--url https://api.lehar.ai/ca/api/v0/agent/{agent_id}/whatsapp/test-reply \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data @- <<EOF
{
"message": "Sure, I'm based in Pune.",
"conversation": [
{
"direction": "outbound",
"text": "Hi! Is now a good time to chat about the offer?"
},
{
"direction": "inbound",
"text": "Yes, go ahead."
},
{
"direction": "outbound",
"text": "Great - which city are you based in?"
}
],
"memory": {
"collected_fields": {}
},
"variables": {
"customer_name": "Asha"
}
}
EOFimport requests
url = "https://api.lehar.ai/ca/api/v0/agent/{agent_id}/whatsapp/test-reply"
payload = {
"message": "Sure, I'm based in Pune.",
"conversation": [
{
"direction": "outbound",
"text": "Hi! Is now a good time to chat about the offer?"
},
{
"direction": "inbound",
"text": "Yes, go ahead."
},
{
"direction": "outbound",
"text": "Great - which city are you based in?"
}
],
"memory": { "collected_fields": {} },
"variables": { "customer_name": "Asha" }
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
message: 'Sure, I\'m based in Pune.',
conversation: [
{direction: 'outbound', text: 'Hi! Is now a good time to chat about the offer?'},
{direction: 'inbound', text: 'Yes, go ahead.'},
{direction: 'outbound', text: 'Great - which city are you based in?'}
],
memory: {collected_fields: {}},
variables: {customer_name: 'Asha'}
})
};
fetch('https://api.lehar.ai/ca/api/v0/agent/{agent_id}/whatsapp/test-reply', 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://api.lehar.ai/ca/api/v0/agent/{agent_id}/whatsapp/test-reply",
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([
'message' => 'Sure, I\'m based in Pune.',
'conversation' => [
[
'direction' => 'outbound',
'text' => 'Hi! Is now a good time to chat about the offer?'
],
[
'direction' => 'inbound',
'text' => 'Yes, go ahead.'
],
[
'direction' => 'outbound',
'text' => 'Great - which city are you based in?'
]
],
'memory' => [
'collected_fields' => [
]
],
'variables' => [
'customer_name' => 'Asha'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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://api.lehar.ai/ca/api/v0/agent/{agent_id}/whatsapp/test-reply"
payload := strings.NewReader("{\n \"message\": \"Sure, I'm based in Pune.\",\n \"conversation\": [\n {\n \"direction\": \"outbound\",\n \"text\": \"Hi! Is now a good time to chat about the offer?\"\n },\n {\n \"direction\": \"inbound\",\n \"text\": \"Yes, go ahead.\"\n },\n {\n \"direction\": \"outbound\",\n \"text\": \"Great - which city are you based in?\"\n }\n ],\n \"memory\": {\n \"collected_fields\": {}\n },\n \"variables\": {\n \"customer_name\": \"Asha\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
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://api.lehar.ai/ca/api/v0/agent/{agent_id}/whatsapp/test-reply")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"Sure, I'm based in Pune.\",\n \"conversation\": [\n {\n \"direction\": \"outbound\",\n \"text\": \"Hi! Is now a good time to chat about the offer?\"\n },\n {\n \"direction\": \"inbound\",\n \"text\": \"Yes, go ahead.\"\n },\n {\n \"direction\": \"outbound\",\n \"text\": \"Great - which city are you based in?\"\n }\n ],\n \"memory\": {\n \"collected_fields\": {}\n },\n \"variables\": {\n \"customer_name\": \"Asha\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lehar.ai/ca/api/v0/agent/{agent_id}/whatsapp/test-reply")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"message\": \"Sure, I'm based in Pune.\",\n \"conversation\": [\n {\n \"direction\": \"outbound\",\n \"text\": \"Hi! Is now a good time to chat about the offer?\"\n },\n {\n \"direction\": \"inbound\",\n \"text\": \"Yes, go ahead.\"\n },\n {\n \"direction\": \"outbound\",\n \"text\": \"Great - which city are you based in?\"\n }\n ],\n \"memory\": {\n \"collected_fields\": {}\n },\n \"variables\": {\n \"customer_name\": \"Asha\"\n }\n}"
response = http.request(request)
puts response.read_body{
"reply_text": "Thanks, Asha! Noted - Pune. Are you looking to buy within the next 3 months?",
"decision": "reply",
"reason": "Collected the customer's city; still need their buying timeline.",
"memory": {
"collected_fields": {
"city": "Pune"
}
},
"collected_fields": {
"city": "Pune"
},
"qualification_status": "pending"
}{
"error": {
"code": "invalid_request",
"message": "message is required"
}
}{
"error": {
"code": "unauthorized",
"message": "Authentication required"
}
}{
"error": {
"code": "forbidden",
"message": "Scope 'sessions:write' is required"
}
}{
"error": {
"code": "not_found",
"message": "Agent 'agent_7f3a1c9e' not found"
}
}{
"error": {
"code": "internal_error",
"message": "An unexpected error occurred"
}
}Authorizations
Path Parameters
Identifier of the WhatsApp agent to test.
Body
The latest inbound customer message to reply to. Required and must be non-empty.
Prior transcript replayed each turn (the endpoint is stateless). Defaults to an empty list.
Show child attributes
Show child attributes
Prior qualification memory to carry forward (e.g. previously collected fields). Optional.
Prompt template variables merged into the agent's WhatsApp prompt. Optional.
Response
The engine's reply and updated qualification state for this turn.

