Chat with AskAI
curl --request POST \
--url https://myaskai.com/api/1.1/wf/ask-ai-chat \
--header 'Content-Type: application/json' \
--data '
{
"id": "<string>",
"api_key": "<string>",
"messages": [
{
"role": "<string>",
"content": "<string>"
}
]
}
'import requests
url = "https://myaskai.com/api/1.1/wf/ask-ai-chat"
payload = {
"id": "<string>",
"api_key": "<string>",
"messages": [
{
"role": "<string>",
"content": "<string>"
}
]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
id: '<string>',
api_key: '<string>',
messages: [{role: '<string>', content: '<string>'}]
})
};
fetch('https://myaskai.com/api/1.1/wf/ask-ai-chat', 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://myaskai.com/api/1.1/wf/ask-ai-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([
'id' => '<string>',
'api_key' => '<string>',
'messages' => [
[
'role' => '<string>',
'content' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"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://myaskai.com/api/1.1/wf/ask-ai-chat"
payload := strings.NewReader("{\n \"id\": \"<string>\",\n \"api_key\": \"<string>\",\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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://myaskai.com/api/1.1/wf/ask-ai-chat")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"<string>\",\n \"api_key\": \"<string>\",\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://myaskai.com/api/1.1/wf/ask-ai-chat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": \"<string>\",\n \"api_key\": \"<string>\",\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"answer": "<string>",
"references": [
{
"content": "<string>",
"link": "<string>",
"score": 123,
"title": "<string>"
}
]
}API Documentation
Chat API
POST
/
ask-ai-chat
Chat with AskAI
curl --request POST \
--url https://myaskai.com/api/1.1/wf/ask-ai-chat \
--header 'Content-Type: application/json' \
--data '
{
"id": "<string>",
"api_key": "<string>",
"messages": [
{
"role": "<string>",
"content": "<string>"
}
]
}
'import requests
url = "https://myaskai.com/api/1.1/wf/ask-ai-chat"
payload = {
"id": "<string>",
"api_key": "<string>",
"messages": [
{
"role": "<string>",
"content": "<string>"
}
]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
id: '<string>',
api_key: '<string>',
messages: [{role: '<string>', content: '<string>'}]
})
};
fetch('https://myaskai.com/api/1.1/wf/ask-ai-chat', 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://myaskai.com/api/1.1/wf/ask-ai-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([
'id' => '<string>',
'api_key' => '<string>',
'messages' => [
[
'role' => '<string>',
'content' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"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://myaskai.com/api/1.1/wf/ask-ai-chat"
payload := strings.NewReader("{\n \"id\": \"<string>\",\n \"api_key\": \"<string>\",\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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://myaskai.com/api/1.1/wf/ask-ai-chat")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"<string>\",\n \"api_key\": \"<string>\",\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://myaskai.com/api/1.1/wf/ask-ai-chat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": \"<string>\",\n \"api_key\": \"<string>\",\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"answer": "<string>",
"references": [
{
"content": "<string>",
"link": "<string>",
"score": 123,
"title": "<string>"
}
]
}Our Chat API allows a user to have a conversation with your AI agent via a simple API call.
The messages array should contain the conversation between the user and the AI agent. You can send the entire conversation within the API request.
Each message object has a role (user or assistant) and content.
In the example below you can see a short conversation between a user and an AI agent.
The message from the user has the role: user and all replies from the My AskAI have the role: assistant.
If your AI agent doesn’t know the answer, the API will also return an additional field to confirm an answer wasn’t found as well as 3 suggested questions the user can retry (these have a very high likelihood of being answered correctly):
"unknown_answer": "yes","suggestedQuestions": ["Example question", ...]You can also pass in
"insights": true to generate insights in your Dashboard from any API usage. When Insights is enabled in the API a conversation_id is also returned with each request. This can be included in subsequent API requests to keep the requests link to 1 conversation. However, you still need to always pass in the message history as the API is stateless.If human handover guidance is triggered the API response will include:
"human_handover": true
