SWAIG.functions
An array of JSON objects to define functions that can be executed during the interaction with the AI.
Name | Type | Default | Description |
---|---|---|---|
functions Optional | object[] | - | An array of JSON objects that accept the functions Parameters . |
functions Parameters
Parameter | Type | Default | Description |
---|---|---|---|
description Required | string | - | A description of the context and purpose of the function, to explain to the agent when to use it. |
function Required | string | - | A unique name for the function. For example, "get_weather". |
active Optional | boolean | true | Whether the function is active. |
data_map Optional | object | - | An object containing properties to process or validate the input, perform actions based on the input, or connect to external APIs or services in a serverless fashion. |
parameters Optional | object | - | A JSON object that defines the expected user input parameters and their validation rules for the function. |
fillers Optional | object | - | A JSON object defining the fillers that should be played when calling a swaig function . This helps the AI break silence between responses. The filler is played asynchronously during the function call. |
meta_data Optional | object | - | A powerful and flexible environmental variable which can accept arbitrary data that is set initially in the SWML script or from the SWML set_meta_data action. This data can be referenced locally to the function. All contained information can be accessed and expanded within the prompt - for example, by using a template string. |
meta_data_token Optional | string | Set by SignalWire | Scoping token for meta_data . If not supplied, metadata will be scoped to function's web_hook_url . |
wait_file Optional | string | - | A file to play while the function is running. wait_file_loops can specify the amount of times that files should continously play. |
wait_file_loops Optional | string | integer | - | The amount of times that wait_file should continuously play/loop. |
web_hook_url Optional | string | - | Function-specific URL to send status callbacks and reports to. Takes precedence over a default setting. Authentication can also be set in the url in the format of username:password@url . See Callback Parameters for details on the request body. |
purpose | string | - | Deprecated. Use description instead. |
argument | object | - | Deprecated. Use parameters instead. |
Examples
Using SWAIG Functions
- YAML
- JSON
version: 1.0.0
sections:
main:
- ai:
post_prompt_url: "https://example.com/my-api"
prompt:
text: |
You are a helpful assistant that can provide information to users about a destination.
You can use the appropriate function to get the phone number, address,
or weather information.
post_prompt:
text: "Summarize the conversation."
SWAIG:
includes:
- functions:
- get_phone_number
- get_address
url: https://example.com/functions
user: me
pass: secret
defaults:
web_hook_url: https://example.com/my-webhook
web_hook_auth_user: me
web_hook_auth_pass: secret
functions:
- function: get_weather
description: To determine what the current weather is in a provided location.
parameters:
properties:
location:
type: string
description: The name of the city to find the weather from.
type: object
{
"version": "1.0.0",
"sections": {
"main": [
{
"ai": {
"post_prompt_url": "https://example.com/my-api",
"prompt": {
"text": "You are a helpful assistant that can provide information to users about a destination.\nYou can use the appropriate function to get the phone number, address,\nor weather information.\n"
},
"post_prompt": {
"text": "Summarize the conversation."
},
"SWAIG": {
"includes": [
{
"functions": [
"get_phone_number",
"get_address"
],
"url": "https://example.com/functions",
"user": "me",
"pass": "secret"
}
],
"defaults": {
"web_hook_url": "https://example.com/my-webhook",
"web_hook_auth_user": "me",
"web_hook_auth_pass": "secret"
},
"functions": [
{
"function": "get_weather",
"description": "To determine what the current weather is in a provided location.",
"parameters": {
"properties": {
"location": {
"type": "string",
"description": "The name of the city to find the weather from."
}
},
"type": "object"
}
}
]
}
}
}
]
}
}