curl --request POST \
--url https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/frontend-actions \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"name": "Open Product Modal",
"description": "Opens a modal displaying product details for the specified product ID",
"triggerFunction": "showProductModal",
"parameters": [
{
"key": "productId",
"type": "string",
"description": "The ID of the product to display",
"required": true
}
],
"icon": "https://example.com/icon.png"
}
'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/frontend-actions"
payload = {
"name": "Open Product Modal",
"description": "Opens a modal displaying product details for the specified product ID",
"triggerFunction": "showProductModal",
"parameters": [
{
"key": "productId",
"type": "string",
"description": "The ID of the product to display",
"required": True
}
],
"icon": "https://example.com/icon.png"
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Open Product Modal',
description: 'Opens a modal displaying product details for the specified product ID',
triggerFunction: 'showProductModal',
parameters: [
{
key: 'productId',
type: 'string',
description: 'The ID of the product to display',
required: true
}
],
icon: 'https://example.com/icon.png'
})
};
fetch('https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/frontend-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://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/frontend-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' => 'Open Product Modal',
'description' => 'Opens a modal displaying product details for the specified product ID',
'triggerFunction' => 'showProductModal',
'parameters' => [
[
'key' => 'productId',
'type' => 'string',
'description' => 'The ID of the product to display',
'required' => true
]
],
'icon' => 'https://example.com/icon.png'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$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://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/frontend-actions"
payload := strings.NewReader("{\n \"name\": \"Open Product Modal\",\n \"description\": \"Opens a modal displaying product details for the specified product ID\",\n \"triggerFunction\": \"showProductModal\",\n \"parameters\": [\n {\n \"key\": \"productId\",\n \"type\": \"string\",\n \"description\": \"The ID of the product to display\",\n \"required\": true\n }\n ],\n \"icon\": \"https://example.com/icon.png\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<api-key>")
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://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/frontend-actions")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Open Product Modal\",\n \"description\": \"Opens a modal displaying product details for the specified product ID\",\n \"triggerFunction\": \"showProductModal\",\n \"parameters\": [\n {\n \"key\": \"productId\",\n \"type\": \"string\",\n \"description\": \"The ID of the product to display\",\n \"required\": true\n }\n ],\n \"icon\": \"https://example.com/icon.png\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/frontend-actions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Open Product Modal\",\n \"description\": \"Opens a modal displaying product details for the specified product ID\",\n \"triggerFunction\": \"showProductModal\",\n \"parameters\": [\n {\n \"key\": \"productId\",\n \"type\": \"string\",\n \"description\": \"The ID of the product to display\",\n \"required\": true\n }\n ],\n \"icon\": \"https://example.com/icon.png\"\n}"
response = http.request(request)
puts response.read_body{
"_id": "myapp_onUserClick",
"appId": "my-app-id",
"name": "User Click Action",
"description": "Triggered when a user clicks a button",
"triggerFunction": "onUserClick",
"icon": "https://example.com/icon.png",
"parameters": [
{
"key": "userId",
"type": "string",
"description": "The user identifier",
"required": true
}
],
"tool": {
"name": "onUserClick",
"description": "Triggered when a user clicks a button",
"parameters": {
"type": "object",
"properties": {},
"required": []
}
},
"createdAt": 1700000000000,
"updatedAt": 1700000000000
}Create Frontend Action
Creates a new frontend action for the application. Use this endpoint to define a client-side UI operation that agents can trigger during conversations. Uniqueness: The trigger function must be un
curl --request POST \
--url https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/frontend-actions \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"name": "Open Product Modal",
"description": "Opens a modal displaying product details for the specified product ID",
"triggerFunction": "showProductModal",
"parameters": [
{
"key": "productId",
"type": "string",
"description": "The ID of the product to display",
"required": true
}
],
"icon": "https://example.com/icon.png"
}
'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/frontend-actions"
payload = {
"name": "Open Product Modal",
"description": "Opens a modal displaying product details for the specified product ID",
"triggerFunction": "showProductModal",
"parameters": [
{
"key": "productId",
"type": "string",
"description": "The ID of the product to display",
"required": True
}
],
"icon": "https://example.com/icon.png"
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Open Product Modal',
description: 'Opens a modal displaying product details for the specified product ID',
triggerFunction: 'showProductModal',
parameters: [
{
key: 'productId',
type: 'string',
description: 'The ID of the product to display',
required: true
}
],
icon: 'https://example.com/icon.png'
})
};
fetch('https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/frontend-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://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/frontend-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' => 'Open Product Modal',
'description' => 'Opens a modal displaying product details for the specified product ID',
'triggerFunction' => 'showProductModal',
'parameters' => [
[
'key' => 'productId',
'type' => 'string',
'description' => 'The ID of the product to display',
'required' => true
]
],
'icon' => 'https://example.com/icon.png'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$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://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/frontend-actions"
payload := strings.NewReader("{\n \"name\": \"Open Product Modal\",\n \"description\": \"Opens a modal displaying product details for the specified product ID\",\n \"triggerFunction\": \"showProductModal\",\n \"parameters\": [\n {\n \"key\": \"productId\",\n \"type\": \"string\",\n \"description\": \"The ID of the product to display\",\n \"required\": true\n }\n ],\n \"icon\": \"https://example.com/icon.png\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<api-key>")
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://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/frontend-actions")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Open Product Modal\",\n \"description\": \"Opens a modal displaying product details for the specified product ID\",\n \"triggerFunction\": \"showProductModal\",\n \"parameters\": [\n {\n \"key\": \"productId\",\n \"type\": \"string\",\n \"description\": \"The ID of the product to display\",\n \"required\": true\n }\n ],\n \"icon\": \"https://example.com/icon.png\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/frontend-actions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Open Product Modal\",\n \"description\": \"Opens a modal displaying product details for the specified product ID\",\n \"triggerFunction\": \"showProductModal\",\n \"parameters\": [\n {\n \"key\": \"productId\",\n \"type\": \"string\",\n \"description\": \"The ID of the product to display\",\n \"required\": true\n }\n ],\n \"icon\": \"https://example.com/icon.png\"\n}"
response = http.request(request)
puts response.read_body{
"_id": "myapp_onUserClick",
"appId": "my-app-id",
"name": "User Click Action",
"description": "Triggered when a user clicks a button",
"triggerFunction": "onUserClick",
"icon": "https://example.com/icon.png",
"parameters": [
{
"key": "userId",
"type": "string",
"description": "The user identifier",
"required": true
}
],
"tool": {
"name": "onUserClick",
"description": "Triggered when a user clicks a button",
"parameters": {
"type": "object",
"properties": {},
"required": []
}
},
"createdAt": 1700000000000,
"updatedAt": 1700000000000
}Authorizations
API Key (i.e. Rest API Key from the Dashboard).
Body
Display name of the frontend action
"Open Product Modal"
Description of what the frontend action does
"Opens a modal displaying product details for the specified product ID"
The function name that the frontend will execute (used as unique identifier)
"showProductModal"
Array of parameters for the frontend action
Show child attributes
Show child attributes
Icon URL for the frontend action
"https://example.com/icon.png"
Response
Frontend action created successfully
"myapp_onUserClick"
"my-app-id"
"User Click Action"
"Triggered when a user clicks a button"
"onUserClick"
"https://example.com/icon.png"
Show child attributes
Show child attributes
Show child attributes
Show child attributes
1700000000000
1700000000000
Was this page helpful?