functions.web_hook_url
The function specific URL that the user defines to which to send status callbacks and reports.
Name | Type | Default | Description |
---|---|---|---|
web_hook_url Optional | string | - | The URL to send status callbacks and reports to. Authentication can also be set in the url in the format of username:password@url . See Callback Parameters for details on the request body. |
Callback Request for web_hook_url
SignalWire will make a request to the web_hook_url
of a SWAIG function with the following parameters:
Name | Type | Description |
---|---|---|
content_type | string | Type of content. The value will be text/swaig . |
app_name | string | Name of the application that originated the request. |
function | string | Name of the function that was invoked. |
meta_data | object | A JSON object containing any user metadata, as a key-value map. |
SWMLVars | object | A collection of variables related to SWML. |
purpose | string | The purpose of the function being invoked. The value will be the functions.purpose value you provided in the SWAIG Function parameters. |
argument_desc | string | object | The description of the argument being passed. This value comes from the argument you provided in the SWAIG Function parameters. |
argument | object | The argument the AI agent is providing to the function. The object contains the three following fields. |
argument.parsed | object | If a JSON object is detected within the argument, it is parsed and provided here. |
argument.raw | string | The raw argument provided by the AI agent. |
argument.substituted | string | The argument provided by the AI agent, excluding any JSON. |
version | string | Version number. |
Webhook Request Example
Below is a json example of the callback request that is sent to the web_hook_url
:
{
"app_name": "swml app",
"function": "get_weather",
"version": "2.0",
"content_type": "text/swaig",
"content_disposition": "SWAIG Function",
"channel_active": true,
"caller_id_name": "[CALLER_ID]",
"caller_id_num": "[CALLER_NUMBER]",
"project_id": "[PROJECT_ID]",
"space_id": "[SPACE_ID]",
"call_id": "[CALL_ID]",
"ai_session_id": "[AI_SESSION_ID]",
"purpose": "To determine what the current weather is in a provided location.",
"meta_data_token": "[TOKEN]",
"meta_data": {},
"argument": {
"parsed": [
{
"location": "[USER_INPUT]"
}
],
"raw": "{\n \"location\": \"[USER_INPUT]\"\n}",
"substituted": ""
},
"argument_desc": {
"properties": {
"location": {
"type": "string",
"description": "The location to get the weather for"
}
},
"type": "object"
}
}
Responding to Webhook Requests
The response should be in JSON format, the primary key that the AI will look for is the
response
key. The value associated with this key will be the content or instruction that the AI will process.
{
"response": "The weather in [CITY] is [WEATHER]."
}
Variables
- ai_result: (out)
success
|failed
- return_value: (out)
success
|failed