AI Agent Function

Prev Next

Function

Function JSON Format

Function is represented as simple flat JSON objects with the following keys:

Name Type Description
id guid Id of the function.
aiAgentId guid Id of the AI agent.
name string Name of the function.
description string Description of the function.
isGlobal bool If disabled, this function will not be called by AI Agent directly. But it can be used in Topics and can be called by AI Agent if the Topic is triggered.
usedInTopics integer Number of topics using this function.
inputParameters Function Input Parameter Array Input parameters for the function.
apiRequest Function API Request API request configuration.
responseMetas Function Response To Variable Array Response to variable mappings.

Function Input Parameter JSON Format

Name Type Description
id guid Id of the parameter.
functionId guid Id of the function.
name string A short name to describe what this parameter means.
type enum Allowed values are String, Integer, Float, Boolean.
description string A detailed description explaining the meaning of this parameter.
isRequired bool Whether this parameter is required.

Function API Request JSON Format

Name Type Description
functionId guid Id of the function.
httpMethod enum Allowed values are GET, POST, PUT, DELETE.
url string API Endpoint. Can use input parameters and dynamic info.
isAuthorizationRequired bool Whether authorization is required.
authorizationCredentialId guid Authorization Credential Id.
httpHeaders Function API Request Header Array HTTP Headers.
requestBody string JSON Body. Can use input parameters and dynamic info.

Function API Request Header JSON Format

Name Type Description
id guid Id of the header.
apiRequestId guid Id of the API request.
key string Header Name.
value string Header Value.
order integer Order of the header.

Function Response To Variable JSON Format

Name Type Description
id guid Id of the response mapping.
functionId guid Id of the function.
responseKey string The JSON key name.
description string Describe the meaning of this key, so that LLM can better understand it.
variableName string Save the value to a bot variable to use later.
order integer Order of the mapping.

Get the list of Functions

GET aiagent/functions

Parameters:

Name Type in Required Description
siteId integer query yes Site Id.
aiAgentId guid query yes Filter functions by AI agent ID.
name string query no Filter functions by exact name match.
keywords string query no Search for functions containing these keywords.
pageSize integer query no Number of functions to return per page.
pageIndex integer query no Page number to retrieve. Default is 1.

Response:

An array of Function

Example

Sample Request:

curl https://api11.comm100.io/aiagent/functions?siteId=10000&aiAgentId=ec9f351e-d7d7-45fc-81aa-2fdd9e706f17 \
    -X GET
    -H 'Authorization Bearer {access_token}'

Response:
HTTP/1.1 200 OK

[
    {
        "id": "5f92bcfe-f223-4ea1-72a2-08dd5afb6d4d",
        "aiAgentId": "ec9f351e-d7d7-45fc-81aa-2fdd9e706f17",
        "name": "callback",
        "description": "",
        "isGlobal": true,
        "usedInTopics": 0,
        "inputParameters": [],
        "apiRequest": {
            "functionId": "5f92bcfe-f223-4ea1-72a2-08dd5afb6d4d",
            "httpMethod": "get",
            "url": "https://en.wikipedia.org/wiki/Main_Page",
            "isAuthorizationRequired": false,
            "authorizationCredentialId": "00000000-0000-0000-0000-000000000000",
            "requestBody": "",
            "httpHeaders": []
        },
        "responseMetas": []
    }
]

Get a single Function

GET aiagent/functions/{id}

Parameters:

Name Type in Required Description
siteId integer query yes Site Id.
id guid path yes ID of the function to retrieve.

Response:

Function

Example

Sample Request:

curl https://api11.comm100.io/aiagent/functions/5f92bcfe-f223-4ea1-72a2-08dd5afb6d4d?siteId=10000 \ 
    -X GET \
    -H 'Authorization Bearer {access_token}'

Response:
HTTP/1.1 200 OK

{
    "id": "5f92bcfe-f223-4ea1-72a2-08dd5afb6d4d",
    "aiAgentId": "ec9f351e-d7d7-45fc-81aa-2fdd9e706f17",
    "name": "callback",
    "description": "",
    "isGlobal": true,
    "usedInTopics": 0,
    "inputParameters": [],
    "apiRequest": {
        "functionId": "5f92bcfe-f223-4ea1-72a2-08dd5afb6d4d",
        "httpMethod": "get",
        "url": "https://en.wikipedia.org/wiki/Main_Page",
        "isAuthorizationRequired": false,
        "authorizationCredentialId": "00000000-0000-0000-0000-000000000000",
        "requestBody": "",
        "httpHeaders": []
    },
    "responseMetas": []
}

Create a new Function

POST aiagent/functions

Parameters:

Name Type in Required Description
aiAgentId guid body yes ID of the AI agent to which this function belongs.
name string body yes Name of the function. Must be unique within an AI agent.
description string body no Detailed description of what the function does.
isGlobal bool body yes If true, this function can be called directly by AI Agent. If false, it can only be used in Topics.
inputParameters Function Input Parameter Array body yes List of parameters required by the function.
apiRequest Function API Request body yes API configuration for the function.
responseMetas Function Response To Variable Array body yes Mappings for the function's response fields to variables.

Response:

Function

Example

Sample Request:

curl https://api11.comm100.io/aiagent/functions \ 
    -X POST \ 
    -H 'Authorization: Bearer {access_token}' \
    -H 'Content-Type: application/json' \
    -D '{"aiAgentId":"ec9f351e-d7d7-45fc-81aa-2fdd9e706f17","name":"callback","description":"","isGlobal":true,"inputParameters":[],"apiRequest":{"httpMethod":"get","url":"https://en.wikipedia.org/wiki/Main_Page","isAuthorizationRequired":false,"authorizationCredentialId":"00000000-0000-0000-0000-000000000000","requestBody":"","httpHeaders":[]},"responseMetas":[]}'

Response:
HTTP/1.1 200 OK

{
    "id": "5f92bcfe-f223-4ea1-72a2-08dd5afb6d4d",
    "aiAgentId": "ec9f351e-d7d7-45fc-81aa-2fdd9e706f17",
    "name": "callback",
    "description": "",
    "isGlobal": true,
    "usedInTopics": 0,
    "inputParameters": [],
    "apiRequest": {
        "functionId": "5f92bcfe-f223-4ea1-72a2-08dd5afb6d4d",
        "httpMethod": "get",
        "url": "https://en.wikipedia.org/wiki/Main_Page",
        "isAuthorizationRequired": false,
        "authorizationCredentialId": "00000000-0000-0000-0000-000000000000",
        "requestBody": "",
        "httpHeaders": []
    },
    "responseMetas": []
}

Update the Function

PUT aiagent/functions/{id}

Parameters:

Name Type in Required Description
siteId integer query yes Site Id.
id guid path yes ID of the function to update.
name string body no Updated name for the function. Must be unique within the AI agent.
description string body no Updated description of what the function does.
isGlobal bool body no Updated visibility setting for the function.
inputParameters Function Input Parameter Array body no Updated list of parameters required by the function.
apiRequest Function API Request body no Updated API configuration for the function.
responseMetas Function Response To Variable Array body no Updated mappings for the function's response fields to variables.

Response:

Function

Example

Sample Request:

curl https://api11.comm100.io/aiagent/functions/5f92bcfe-f223-4ea1-72a2-08dd5afb6d4d?siteId=10000 \ 
    -X PUT \
    -H 'Authorization Bearer {access_token}' \
    -H 'Content-Type: application/json' \
    -D '{"description":"Updated description of the function."}'

Response:
HTTP/1.1 200 OK

{
    "id": "5f92bcfe-f223-4ea1-72a2-08dd5afb6d4d",
    "aiAgentId": "ec9f351e-d7d7-45fc-81aa-2fdd9e706f17",
    "name": "callback",
    "description": "Updated description of the function.",
    "isGlobal": true,
    "usedInTopics": 0,
    "inputParameters": [],
    "apiRequest": {
        "functionId": "5f92bcfe-f223-4ea1-72a2-08dd5afb6d4d",
        "httpMethod": "get",
        "url": "https://en.wikipedia.org/wiki/Main_Page",
        "isAuthorizationRequired": false,
        "authorizationCredentialId": "00000000-0000-0000-0000-000000000000",
        "requestBody": "",
        "httpHeaders": []
    },
    "responseMetas": []
}

Delete the Function

DELETE aiagent/functions/{id}

Parameters:

Name Type in Required Description
siteId integer query yes Site Id.
id guid path yes ID of the function to delete.

Response:

No Content

Example

Sample Request:

curl https://api11.comm100.io/aiagent/functions/5f92bcfe-f223-4ea1-72a2-08dd5afb6d4d?siteId=10000 \ 
    -X DELETE
    -H 'Authorization Bearer {access_token}'

Response:
HTTP/1.1 204 No Content

Copyright © 2022 Comm100 Network Corporation. All Rights Reserved.