Create a New Action
curl --request POST \
--url https://api.trata.ai/v1/actions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"name": "get_delivery_date",
"parameters": false,
"endpoint": {
"url": "http://example.com/api/action",
"method": "POST",
"headers": "application/json",
"payload": "123456"
},
"description": "Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'",
"userWaitingText": "Please wait while we get the delivery date for your order",
"userSuccessText": "We have sent you an email with the delivery date",
"userErrorText": "We are unable to get the delivery date for your order"
}
EOFimport requests
url = "https://api.trata.ai/v1/actions"
payload = {
"name": "get_delivery_date",
"parameters": False,
"endpoint": {
"url": "http://example.com/api/action",
"method": "POST",
"headers": "application/json",
"payload": "123456"
},
"description": "Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'",
"userWaitingText": "Please wait while we get the delivery date for your order",
"userSuccessText": "We have sent you an email with the delivery date",
"userErrorText": "We are unable to get the delivery date for your order"
}
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({
name: 'get_delivery_date',
parameters: false,
endpoint: {
url: 'http://example.com/api/action',
method: 'POST',
headers: 'application/json',
payload: '123456'
},
description: 'Get the delivery date for a customer\'s order. Call this whenever you need to know the delivery date, for example when a customer asks \'Where is my package\'',
userWaitingText: 'Please wait while we get the delivery date for your order',
userSuccessText: 'We have sent you an email with the delivery date',
userErrorText: 'We are unable to get the delivery date for your order'
})
};
fetch('https://api.trata.ai/v1/actions', 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.trata.ai/v1/actions",
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([
'name' => 'get_delivery_date',
'parameters' => false,
'endpoint' => [
'url' => 'http://example.com/api/action',
'method' => 'POST',
'headers' => 'application/json',
'payload' => '123456'
],
'description' => 'Get the delivery date for a customer\'s order. Call this whenever you need to know the delivery date, for example when a customer asks \'Where is my package\'',
'userWaitingText' => 'Please wait while we get the delivery date for your order',
'userSuccessText' => 'We have sent you an email with the delivery date',
'userErrorText' => 'We are unable to get the delivery date for your order'
]),
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://api.trata.ai/v1/actions"
payload := strings.NewReader("{\n \"name\": \"get_delivery_date\",\n \"parameters\": false,\n \"endpoint\": {\n \"url\": \"http://example.com/api/action\",\n \"method\": \"POST\",\n \"headers\": \"application/json\",\n \"payload\": \"123456\"\n },\n \"description\": \"Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'\",\n \"userWaitingText\": \"Please wait while we get the delivery date for your order\",\n \"userSuccessText\": \"We have sent you an email with the delivery date\",\n \"userErrorText\": \"We are unable to get the delivery date for your order\"\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://api.trata.ai/v1/actions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"get_delivery_date\",\n \"parameters\": false,\n \"endpoint\": {\n \"url\": \"http://example.com/api/action\",\n \"method\": \"POST\",\n \"headers\": \"application/json\",\n \"payload\": \"123456\"\n },\n \"description\": \"Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'\",\n \"userWaitingText\": \"Please wait while we get the delivery date for your order\",\n \"userSuccessText\": \"We have sent you an email with the delivery date\",\n \"userErrorText\": \"We are unable to get the delivery date for your order\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trata.ai/v1/actions")
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 \"name\": \"get_delivery_date\",\n \"parameters\": false,\n \"endpoint\": {\n \"url\": \"http://example.com/api/action\",\n \"method\": \"POST\",\n \"headers\": \"application/json\",\n \"payload\": \"123456\"\n },\n \"description\": \"Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'\",\n \"userWaitingText\": \"Please wait while we get the delivery date for your order\",\n \"userSuccessText\": \"We have sent you an email with the delivery date\",\n \"userErrorText\": \"We are unable to get the delivery date for your order\"\n}"
response = http.request(request)
puts response.read_body{
"id": "act.1234567890",
"orgId": "org.1234567890",
"name": "Webhook on call completion.",
"description": "This action will be invoked when a call is completed. It will send a webhook to the specified url.",
"parameters": {},
"endpoint": {
"url": "https://webhook-endpoint.com",
"method": "POST"
},
"invocationTrigger": "webhook.conversation_en",
"userWaitingText": "Please wait...",
"userSuccessText": "Action completed successfully",
"userErrorText": "An error occurred",
"createdBy": "usr.1234567890",
"createdAt": "2024-12-06T19:23:38.616711",
"updatedBy": "usr.1234567890",
"updatedAt": "2024-12-06T19:23:38.616714"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Actions
Create a New Action
Create a New Action
POST
/
v1
/
actions
Create a New Action
curl --request POST \
--url https://api.trata.ai/v1/actions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"name": "get_delivery_date",
"parameters": false,
"endpoint": {
"url": "http://example.com/api/action",
"method": "POST",
"headers": "application/json",
"payload": "123456"
},
"description": "Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'",
"userWaitingText": "Please wait while we get the delivery date for your order",
"userSuccessText": "We have sent you an email with the delivery date",
"userErrorText": "We are unable to get the delivery date for your order"
}
EOFimport requests
url = "https://api.trata.ai/v1/actions"
payload = {
"name": "get_delivery_date",
"parameters": False,
"endpoint": {
"url": "http://example.com/api/action",
"method": "POST",
"headers": "application/json",
"payload": "123456"
},
"description": "Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'",
"userWaitingText": "Please wait while we get the delivery date for your order",
"userSuccessText": "We have sent you an email with the delivery date",
"userErrorText": "We are unable to get the delivery date for your order"
}
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({
name: 'get_delivery_date',
parameters: false,
endpoint: {
url: 'http://example.com/api/action',
method: 'POST',
headers: 'application/json',
payload: '123456'
},
description: 'Get the delivery date for a customer\'s order. Call this whenever you need to know the delivery date, for example when a customer asks \'Where is my package\'',
userWaitingText: 'Please wait while we get the delivery date for your order',
userSuccessText: 'We have sent you an email with the delivery date',
userErrorText: 'We are unable to get the delivery date for your order'
})
};
fetch('https://api.trata.ai/v1/actions', 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.trata.ai/v1/actions",
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([
'name' => 'get_delivery_date',
'parameters' => false,
'endpoint' => [
'url' => 'http://example.com/api/action',
'method' => 'POST',
'headers' => 'application/json',
'payload' => '123456'
],
'description' => 'Get the delivery date for a customer\'s order. Call this whenever you need to know the delivery date, for example when a customer asks \'Where is my package\'',
'userWaitingText' => 'Please wait while we get the delivery date for your order',
'userSuccessText' => 'We have sent you an email with the delivery date',
'userErrorText' => 'We are unable to get the delivery date for your order'
]),
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://api.trata.ai/v1/actions"
payload := strings.NewReader("{\n \"name\": \"get_delivery_date\",\n \"parameters\": false,\n \"endpoint\": {\n \"url\": \"http://example.com/api/action\",\n \"method\": \"POST\",\n \"headers\": \"application/json\",\n \"payload\": \"123456\"\n },\n \"description\": \"Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'\",\n \"userWaitingText\": \"Please wait while we get the delivery date for your order\",\n \"userSuccessText\": \"We have sent you an email with the delivery date\",\n \"userErrorText\": \"We are unable to get the delivery date for your order\"\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://api.trata.ai/v1/actions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"get_delivery_date\",\n \"parameters\": false,\n \"endpoint\": {\n \"url\": \"http://example.com/api/action\",\n \"method\": \"POST\",\n \"headers\": \"application/json\",\n \"payload\": \"123456\"\n },\n \"description\": \"Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'\",\n \"userWaitingText\": \"Please wait while we get the delivery date for your order\",\n \"userSuccessText\": \"We have sent you an email with the delivery date\",\n \"userErrorText\": \"We are unable to get the delivery date for your order\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trata.ai/v1/actions")
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 \"name\": \"get_delivery_date\",\n \"parameters\": false,\n \"endpoint\": {\n \"url\": \"http://example.com/api/action\",\n \"method\": \"POST\",\n \"headers\": \"application/json\",\n \"payload\": \"123456\"\n },\n \"description\": \"Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'\",\n \"userWaitingText\": \"Please wait while we get the delivery date for your order\",\n \"userSuccessText\": \"We have sent you an email with the delivery date\",\n \"userErrorText\": \"We are unable to get the delivery date for your order\"\n}"
response = http.request(request)
puts response.read_body{
"id": "act.1234567890",
"orgId": "org.1234567890",
"name": "Webhook on call completion.",
"description": "This action will be invoked when a call is completed. It will send a webhook to the specified url.",
"parameters": {},
"endpoint": {
"url": "https://webhook-endpoint.com",
"method": "POST"
},
"invocationTrigger": "webhook.conversation_en",
"userWaitingText": "Please wait...",
"userSuccessText": "Action completed successfully",
"userErrorText": "An error occurred",
"createdBy": "usr.1234567890",
"createdAt": "2024-12-06T19:23:38.616711",
"updatedBy": "usr.1234567890",
"updatedAt": "2024-12-06T19:23:38.616714"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Body
application/json
Description about the action and it should also contain when the action should be triggered
Required string length:
1 - 512Example:
"Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'"
Response
Action created successfully
Action entity to store the actions which can be performed by ai agents
