# Ask before an outbound contact; with Niadra out of reach the purpose decides (marketing waits)
decision = conversation.check("proposal_followup", purpose="marketing", channel="whatsapp")
if decision.decision == "allow":
gateway.send(message, token=decision.contact_token)
conversation.declare.contact_made(decision, purpose="marketing", channel="whatsapp")// Ask before an outbound contact; with Niadra out of reach the purpose decides (marketing waits)
const decision = await convo.check("proposal_followup", { purpose: "marketing", channel: "whatsapp" });
if (decision.decision === "allow") {
await gateway.send(message, { token: decision.contact_token });
convo.declare.contactMade(decision, { purpose: "marketing", channel: "whatsapp" });
}curl --request POST \
--url https://{space}.{region}.api.niadra.com/v1/coordination/check \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent": "<string>",
"intent": "<string>",
"purpose": "<string>",
"channel": "<string>",
"destination_hash": "<string>",
"effect_key": "<string>",
"effect_kind": "delivery",
"gateway_id": "<string>",
"object": {
"id": "<string>",
"namespace": "<string>",
"type": "<string>"
},
"subject": {
"value": "<string>",
"scope": "<string>"
},
"task": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
agent: '<string>',
intent: '<string>',
purpose: '<string>',
channel: '<string>',
destination_hash: '<string>',
effect_key: '<string>',
effect_kind: 'delivery',
gateway_id: '<string>',
object: {id: '<string>', namespace: '<string>', type: '<string>'},
subject: {value: '<string>', scope: '<string>'},
task: '<string>'
})
};
fetch('https://{space}.{region}.api.niadra.com/v1/coordination/check', 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/coordination/check",
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([
'agent' => '<string>',
'intent' => '<string>',
'purpose' => '<string>',
'channel' => '<string>',
'destination_hash' => '<string>',
'effect_key' => '<string>',
'effect_kind' => 'delivery',
'gateway_id' => '<string>',
'object' => [
'id' => '<string>',
'namespace' => '<string>',
'type' => '<string>'
],
'subject' => [
'value' => '<string>',
'scope' => '<string>'
],
'task' => '<string>'
]),
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/coordination/check"
payload := strings.NewReader("{\n \"agent\": \"<string>\",\n \"intent\": \"<string>\",\n \"purpose\": \"<string>\",\n \"channel\": \"<string>\",\n \"destination_hash\": \"<string>\",\n \"effect_key\": \"<string>\",\n \"effect_kind\": \"delivery\",\n \"gateway_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\": \"<string>\"\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/coordination/check")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent\": \"<string>\",\n \"intent\": \"<string>\",\n \"purpose\": \"<string>\",\n \"channel\": \"<string>\",\n \"destination_hash\": \"<string>\",\n \"effect_key\": \"<string>\",\n \"effect_kind\": \"delivery\",\n \"gateway_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\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/v1/coordination/check")
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 \"agent\": \"<string>\",\n \"intent\": \"<string>\",\n \"purpose\": \"<string>\",\n \"channel\": \"<string>\",\n \"destination_hash\": \"<string>\",\n \"effect_key\": \"<string>\",\n \"effect_kind\": \"delivery\",\n \"gateway_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\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"decision": "allow",
"decision_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"valid_for_s": 1,
"channel": {
"free_form_until": "2023-11-07T05:31:56Z",
"quiet_until": "2023-11-07T05:31:56Z",
"template_required": false
},
"commitments_active": [
{
"id": "<string>",
"type": "<string>",
"valid_until": "2023-11-07T05:31:56Z"
}
],
"contact_budget": {},
"contact_token": "<string>",
"effect": {
"state": "none",
"attempt": 123
},
"holder": "<string>",
"locks": [
{
"holder": "<string>",
"kind": "<string>",
"until": "2023-11-07T05:31:56Z",
"task": "<string>"
}
],
"owner": {
"epoch": 123,
"holder": "<string>",
"kind": "owner",
"level": "<string>",
"since": "2023-11-07T05:31:56Z",
"source": "<string>",
"valid_until": "2023-11-07T05:31:56Z",
"via": "declaration"
},
"promises_open": [
{
"id": "<string>",
"owner": "<string>",
"due": "2023-11-07T05:31:56Z"
}
],
"reasons": [
"<string>"
],
"suppressions": [
"<string>"
]
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Perguntar antes de agir
A decisão de coordenação para uma intenção: allow, defer, deny ou handoff_to, com quem detém o cliente, o estado do efeito, o canal, o orçamento de contato e, quando a finalidade pede, o token de contato. Escopo coordinate; funcionalidade coordination.
# Ask before an outbound contact; with Niadra out of reach the purpose decides (marketing waits)
decision = conversation.check("proposal_followup", purpose="marketing", channel="whatsapp")
if decision.decision == "allow":
gateway.send(message, token=decision.contact_token)
conversation.declare.contact_made(decision, purpose="marketing", channel="whatsapp")// Ask before an outbound contact; with Niadra out of reach the purpose decides (marketing waits)
const decision = await convo.check("proposal_followup", { purpose: "marketing", channel: "whatsapp" });
if (decision.decision === "allow") {
await gateway.send(message, { token: decision.contact_token });
convo.declare.contactMade(decision, { purpose: "marketing", channel: "whatsapp" });
}curl --request POST \
--url https://{space}.{region}.api.niadra.com/v1/coordination/check \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent": "<string>",
"intent": "<string>",
"purpose": "<string>",
"channel": "<string>",
"destination_hash": "<string>",
"effect_key": "<string>",
"effect_kind": "delivery",
"gateway_id": "<string>",
"object": {
"id": "<string>",
"namespace": "<string>",
"type": "<string>"
},
"subject": {
"value": "<string>",
"scope": "<string>"
},
"task": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
agent: '<string>',
intent: '<string>',
purpose: '<string>',
channel: '<string>',
destination_hash: '<string>',
effect_key: '<string>',
effect_kind: 'delivery',
gateway_id: '<string>',
object: {id: '<string>', namespace: '<string>', type: '<string>'},
subject: {value: '<string>', scope: '<string>'},
task: '<string>'
})
};
fetch('https://{space}.{region}.api.niadra.com/v1/coordination/check', 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/coordination/check",
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([
'agent' => '<string>',
'intent' => '<string>',
'purpose' => '<string>',
'channel' => '<string>',
'destination_hash' => '<string>',
'effect_key' => '<string>',
'effect_kind' => 'delivery',
'gateway_id' => '<string>',
'object' => [
'id' => '<string>',
'namespace' => '<string>',
'type' => '<string>'
],
'subject' => [
'value' => '<string>',
'scope' => '<string>'
],
'task' => '<string>'
]),
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/coordination/check"
payload := strings.NewReader("{\n \"agent\": \"<string>\",\n \"intent\": \"<string>\",\n \"purpose\": \"<string>\",\n \"channel\": \"<string>\",\n \"destination_hash\": \"<string>\",\n \"effect_key\": \"<string>\",\n \"effect_kind\": \"delivery\",\n \"gateway_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\": \"<string>\"\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/coordination/check")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent\": \"<string>\",\n \"intent\": \"<string>\",\n \"purpose\": \"<string>\",\n \"channel\": \"<string>\",\n \"destination_hash\": \"<string>\",\n \"effect_key\": \"<string>\",\n \"effect_kind\": \"delivery\",\n \"gateway_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\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/v1/coordination/check")
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 \"agent\": \"<string>\",\n \"intent\": \"<string>\",\n \"purpose\": \"<string>\",\n \"channel\": \"<string>\",\n \"destination_hash\": \"<string>\",\n \"effect_key\": \"<string>\",\n \"effect_kind\": \"delivery\",\n \"gateway_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\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"decision": "allow",
"decision_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"valid_for_s": 1,
"channel": {
"free_form_until": "2023-11-07T05:31:56Z",
"quiet_until": "2023-11-07T05:31:56Z",
"template_required": false
},
"commitments_active": [
{
"id": "<string>",
"type": "<string>",
"valid_until": "2023-11-07T05:31:56Z"
}
],
"contact_budget": {},
"contact_token": "<string>",
"effect": {
"state": "none",
"attempt": 123
},
"holder": "<string>",
"locks": [
{
"holder": "<string>",
"kind": "<string>",
"until": "2023-11-07T05:31:56Z",
"task": "<string>"
}
],
"owner": {
"epoch": 123,
"holder": "<string>",
"kind": "owner",
"level": "<string>",
"since": "2023-11-07T05:31:56Z",
"source": "<string>",
"valid_until": "2023-11-07T05:31:56Z",
"via": "declaration"
},
"promises_open": [
{
"id": "<string>",
"owner": "<string>",
"due": "2023-11-07T05:31:56Z"
}
],
"reasons": [
"<string>"
],
"suppressions": [
"<string>"
]
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Autorizações
nia_sk_...
Corpo
O que um agente está prestes a fazer. Sem cliente não há orçamento, supressão nem detentor a consultar: uma pergunta assim só trata da chave do efeito.
1 - 256inbound, outbound ^[a-z][a-z0-9_]{0,39}$^[a-z][a-z0-9_]{0,39}$^[a-z][a-z0-9_]{0,39}$O rcpt do token, calculado por quem tem a chave do gateway, quando o destino não é o handle do cliente.
^[A-Za-z0-9_-]{43}$A chave do fato de negócio; reservada atomicamente quando nada a segura.
1 - 512delivery, document, notice, filing, paid_call, external_action ^[a-z][a-z0-9_]{0,39}$Um 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
^[a-z][a-z0-9_]{0,39}$Resposta
A decisão, válida por valid_for_s segundos; quem age depois disso pergunta de novo.
A decisão de coordenação. reasons são códigos (a especificação de coordenação, 4); holder é para quem transferir com handoff_to. contact_token vem só com um contato de saída permitido de uma finalidade que precisa de um.
allow, defer, deny, handoff_to x >= 0Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
1024^nct1\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]{86}$none quer dizer que nada segurava a chave e esta pergunta a reservou: quem chama age e depois declara.
Show child attributes
Show child attributes
1 - 256Show child attributes
Show child attributes
Quem detém o cliente ou o objeto agora: a reivindicação válida mais restritiva, de onde veio e até quando. epoch protege uma liberação.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
1 - 256^[a-z][a-z0-9_]{0,39}$
