Send a Chat Message
This API allows you to send a chat message and get a response from the assistant.
A successful response will use up 1 request from your monthly limit.
Below is the full reference for the POST
request.
Endpoint
POST
https://www.navigable.ai/api/v1/chat
Headers
Key | Value | |
---|---|---|
X-Api-Key | <YOUR_API_KEY> | |
Content-Type | application/json | If using JSON in the request body |
Request Parameters
Request parameters can be sent as JSON in the request body, or can be urlencoded.
Key | Type | Required | Description |
---|---|---|---|
message | string | Yes | The chat message sent by your user. Must be a valid string. |
identifier | string | No | A unique identifier for your user. Must be a valid string. |
new | boolean | No | Indicates if this is a new chat session. Must be true or omitted. |
markdown | boolean | No | Enables markdown support. Must be true or omitted. |
currentPage | string | No | Specifies the current page. Must be a valid string. |
configuredActions | string[] | No | An array of configured actions. The LLM will recommend only one of these actions. Must be an array of strings. |
configuredFunctions | string[] | No | An array of configured functions. The LLM will automate only one of these actions. Must be an array of strings. |
functionCallId | string | No | The ID of the function call. Required if the LLM recommends a function call. |
Actions are named as follows:
- Pages:
Go to <page name>
- Actions:
<action name>
You can copy the actions map from the API keys page.
In case of a function call result, pass the functionCallId
in the request body. The function response must be passed in the message
field.
Response
On a successful request, the API will return a 200
status code along with the following JSON response:
{
"success": true,
"message": "SUCCESS",
"data": {
"assistantMessage": "response from LLM",
"action": "action recommended by the LLM | null",
"identifier": "unique id of the chat session, new id if not provided in the request",
"toolCalls": [] // Array of function calls
}
}
Key | Type | Description |
---|---|---|
success | boolean | Indicates if the request was successful. |
message | string | The status message. |
data.assistantMessage | string | The response from the LLM. |
data.action | string | null | The action recommended by the LLM. |
data.identifier | string | The unique identifier of the chat session. A new one will be provided if not specified in the request. |
data.toolCalls | toolCall[] | An array of function calls. Maximum of 1 function call will be returned. |
interface toolCall {
id: string;
type: "function";
function: {
name: string;
arguments: JSON; // JSON of arguments to be provided to the function call. key: argument name, value: argument value
};
}
Error Response - Unauthorized
On an unauthorized request, the API will return a 401
status code along with the following JSON response:
{
"success": false,
"message": "UNAUTHORIZED"
}
In case of this error, check your API key and ensure your request header has the correct X-Api-Key
value.
Error Response - Bad Request
On a bad request, the API will return a 400
status code along with the following JSON response:
{
"success": false,
"message": "BAD_REQUEST",
"errors": {
"<field>": "<error message>"
// ... other error fields
}
}
Parameter | Error Message |
---|---|
message | Property "message" must be a valid string. |
identifier | Property "identifier" must be a valid string. |
new | Property "new" must be true or omitted. |
markdown | Property "markdown" must be true or omitted. |
currentPage | Property "currentPage" must be a valid string. |
configuredActions | Please choose at least one valid action. Should be a list of actions configured in your website or app. |
configuredFunctions | Please choose at least one valid function slug. Should be a list of function slugs configured in your website or app. |
functionCallId | Invalid function call id. |
In case of this error, check your request parameters for any invalid values.
Error Response - Chat Limit Reached
On a chat limit reached, the API will return a 403
status code along with the following JSON response:
{
"success": false,
"message": "CHAT_LIMIT_REACHED"
}
In case of this error, top up your chat quota and try again.
Error Response - Internal Server Error
On an internal server error, the API will return a 500
status code along with the following JSON response:
{
"success": false,
"message": "UNEXPECTED_ERROR",
// In case the error is known
"error": "<error message>"
}
In case of this error, try again.
Example Requests
- cURL
- Node.js (Axios)
- Python
- Go
- Ruby
- PHP
- Java
- C#
curl -X POST https://www.navigable.ai/api/v1/chat \
-H "X-Api-Key: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"message": "Hello, World!",
"identifier": "12345",
"markdown": true
}'
const axios = require("axios");
const url = "https://www.navigable.ai/api/v1/chat";
const data = {
message: "Hello, World!",
identifier: "12345",
markdown: true,
};
axios
.post(url, data, {
headers: {
"X-Api-Key": "<YOUR_API_KEY>",
"Content-Type": "application/json",
},
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error("Error:", error);
});
import requests
url = 'https://www.navigable.ai/api/v1/chat'
headers = {
'X-Api-Key': '<YOUR_API_KEY>',
'Content-Type': 'application/json'
}
data = {
'message': 'Hello, World!',
'identifier': '12345',
'markdown': True
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://www.navigable.ai/api/v1/chat"
message := map[string]interface{}{
"message": "Hello, World!",
"identifier": "12345",
"markdown": true
}
jsonData, err := json.Marshal(message)
if err != nil {
fmt.Println("Error marshaling JSON:", err)
return
}
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("X-Api-Key", "<YOUR_API_KEY>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error making request:", err)
return
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
require 'net/http'
require 'json'
uri = URI('https://www.navigable.ai/api/v1/chat')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path, {
'X-Api-Key' => '<YOUR_API_KEY>',
'Content-Type' => 'application/json'
})
request.body = {
message: 'Hello, World!',
identifier: '12345',
markdown: true
}.to_json
response = http.request(request)
puts response.body
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.navigable.ai/api/v1/chat",
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" => "Hello, World!",
"identifier" => "12345",
"markdown" => true
]),
CURLOPT_HTTPHEADER => array(
"X-Api-Key: <YOUR_API_KEY>",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpPostExample {
public static void main(String[] args) {
try {
URL url = new URL("https://www.navigable.ai/api/v1/chat");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("X-Api-Key", "<YOUR_API_KEY>");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
String jsonInputString = "{\"message\": \"Hello, World!\", \"identifier\": \"12345\", \"markdown\": true}";
try (OutputStream os = conn.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
int code = conn.getResponseCode();
System.out.println("Response Code: " + code);
// You can also read the response from the server if needed
} catch (Exception e) {
e.printStackTrace();
}
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
private static readonly HttpClient client = new HttpClient();
static async Task Main()
{
var url = "https://www.navigable.ai/api/v1/chat";
var requestBody = new
{
message = "Hello, World!",
identifier = "12345",
markdown = true
};
var json = System.Text.Json.JsonSerializer.Serialize(requestBody);
var content = new StringContent(json, Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Add("X-Api-Key", "<YOUR_API_KEY>");
try
{
var response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ", e.Message);
}
}
}