Skip to main content
POST
/
ai-agents
/
agent-builder
/
frontend-actions
Create Frontend Action
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"
}
'
{
  "_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

apikey
string
header
required

API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).

Body

application/json
name
string
required

Display name of the frontend action

Example:

"Open Product Modal"

description
string
required

Description of what the frontend action does

Example:

"Opens a modal displaying product details for the specified product ID"

triggerFunction
string
required

The function name that the frontend will execute (used as unique identifier)

Example:

"showProductModal"

parameters
object[]

Array of parameters for the frontend action

icon
string

Icon URL for the frontend action

Example:

"https://example.com/icon.png"

Response

Frontend action created successfully

_id
string
Example:

"myapp_onUserClick"

appId
string
Example:

"my-app-id"

name
string
Example:

"User Click Action"

description
string
Example:

"Triggered when a user clicks a button"

triggerFunction
string
Example:

"onUserClick"

icon
string
Example:

"https://example.com/icon.png"

parameters
object[]
tool
object
createdAt
number
Example:

1700000000000

updatedAt
number
Example:

1700000000000