curl --request POST \
--url https://{space}.{region}.api.niadra.com/v1/context/prefetch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"about": {
"value": "<string>",
"scope": "<string>"
},
"conversation_id": "<string>",
"object": {
"id": "<string>",
"namespace": "<string>",
"type": "<string>"
},
"subject": {
"value": "<string>",
"scope": "<string>"
},
"task_id": "<string>",
"verification": "V0",
"view": "voice"
}
'import requests
url = "https://{space}.{region}.api.niadra.com/v1/context/prefetch"
payload = {
"query": "<string>",
"about": {
"value": "<string>",
"scope": "<string>"
},
"conversation_id": "<string>",
"object": {
"id": "<string>",
"namespace": "<string>",
"type": "<string>"
},
"subject": {
"value": "<string>",
"scope": "<string>"
},
"task_id": "<string>",
"verification": "V0",
"view": "voice"
}
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>',
about: {value: '<string>', scope: '<string>'},
conversation_id: '<string>',
object: {id: '<string>', namespace: '<string>', type: '<string>'},
subject: {value: '<string>', scope: '<string>'},
task_id: '<string>',
verification: 'V0',
view: 'voice'
})
};
fetch('https://{space}.{region}.api.niadra.com/v1/context/prefetch', 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://{space}.{region}.api.niadra.com/v1/context/prefetch",
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>',
'about' => [
'value' => '<string>',
'scope' => '<string>'
],
'conversation_id' => '<string>',
'object' => [
'id' => '<string>',
'namespace' => '<string>',
'type' => '<string>'
],
'subject' => [
'value' => '<string>',
'scope' => '<string>'
],
'task_id' => '<string>',
'verification' => 'V0',
'view' => 'voice'
]),
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://{space}.{region}.api.niadra.com/v1/context/prefetch"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"about\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"conversation_id\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task_id\": \"<string>\",\n \"verification\": \"V0\",\n \"view\": \"voice\"\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://{space}.{region}.api.niadra.com/v1/context/prefetch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"about\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"conversation_id\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task_id\": \"<string>\",\n \"verification\": \"V0\",\n \"view\": \"voice\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/v1/context/prefetch")
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 \"about\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"conversation_id\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task_id\": \"<string>\",\n \"verification\": \"V0\",\n \"view\": \"voice\"\n}"
response = http.request(request)
puts response.read_body{
"queued": true
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Preparar a leitura de um turno
Memória v2: a transcrição parcial enquanto o cliente fala; a leitura com a mesma pergunta responde do trabalho já feito. 202 na hora, sem comprovante.
curl --request POST \
--url https://{space}.{region}.api.niadra.com/v1/context/prefetch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"about": {
"value": "<string>",
"scope": "<string>"
},
"conversation_id": "<string>",
"object": {
"id": "<string>",
"namespace": "<string>",
"type": "<string>"
},
"subject": {
"value": "<string>",
"scope": "<string>"
},
"task_id": "<string>",
"verification": "V0",
"view": "voice"
}
'import requests
url = "https://{space}.{region}.api.niadra.com/v1/context/prefetch"
payload = {
"query": "<string>",
"about": {
"value": "<string>",
"scope": "<string>"
},
"conversation_id": "<string>",
"object": {
"id": "<string>",
"namespace": "<string>",
"type": "<string>"
},
"subject": {
"value": "<string>",
"scope": "<string>"
},
"task_id": "<string>",
"verification": "V0",
"view": "voice"
}
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>',
about: {value: '<string>', scope: '<string>'},
conversation_id: '<string>',
object: {id: '<string>', namespace: '<string>', type: '<string>'},
subject: {value: '<string>', scope: '<string>'},
task_id: '<string>',
verification: 'V0',
view: 'voice'
})
};
fetch('https://{space}.{region}.api.niadra.com/v1/context/prefetch', 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://{space}.{region}.api.niadra.com/v1/context/prefetch",
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>',
'about' => [
'value' => '<string>',
'scope' => '<string>'
],
'conversation_id' => '<string>',
'object' => [
'id' => '<string>',
'namespace' => '<string>',
'type' => '<string>'
],
'subject' => [
'value' => '<string>',
'scope' => '<string>'
],
'task_id' => '<string>',
'verification' => 'V0',
'view' => 'voice'
]),
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://{space}.{region}.api.niadra.com/v1/context/prefetch"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"about\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"conversation_id\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task_id\": \"<string>\",\n \"verification\": \"V0\",\n \"view\": \"voice\"\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://{space}.{region}.api.niadra.com/v1/context/prefetch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"about\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"conversation_id\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task_id\": \"<string>\",\n \"verification\": \"V0\",\n \"view\": \"voice\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/v1/context/prefetch")
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 \"about\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"conversation_id\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task_id\": \"<string>\",\n \"verification\": \"V0\",\n \"view\": \"voice\"\n}"
response = http.request(request)
puts response.read_body{
"queued": true
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Autorizações
nia_sk_...
Corpo
POST /v1/context/prefetch: o turno do cliente até aqui, enviado enquanto ele ainda fala, para a leitura que responde o turno achar o trabalho feito (memória v2). O mesmo alvo, view e nível dessa leitura.
A transcrição parcial. A leitura com esta mesma query é servida do prefetch; uma transcrição mais longa ainda acha a memória do cliente já aberta.
1 - 2000A conta ou o parceiro em nome de quem a pessoa age.
Show child attributes
Show child attributes
1 - 512Um objeto de negócio num sistema de registro.
Show child attributes
Show child attributes
Um identificador de um sujeito num canal ou sistema: um telefone, um e-mail, um id do CRM.
Show child attributes
Show child attributes
1 - 512Nível de verificação da sessão. V0 autodeclarado, V1 plausível pelo canal, V2 atestado pelo canal, V3 desafiado (OTP ou login), V4 conferido com um sistema de registro ou por um atendente. no_customer vale para tarefas sem cliente presente e só é aceito de fontes de agente interno.
V0, V1, V2, V3, V4, no_customer ^(voice|chat|brief|full|custom|account|partner|task:[a-z0-9_]{1,40})$Resposta
Resposta de sucesso.
Falso quando não há o que preparar: o espaço não tem a memória v2 ligada, ou o servidor está no limite de prefetches. A leitura responde igual nos dois casos.

