Skip to main content

functions.web_hook_url

The function specific URL that the user defines to which to send status callbacks and reports.

NameTypeDefaultDescription
web_hook_urlOptionalstring-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:

NameTypeDescription
content_typestringType of content. The value will be text/swaig.
app_namestringName of the application that originated the request.
functionstringName of the function that was invoked.
meta_dataobjectA JSON object containing any user metadata, as a key-value map.
SWMLVarsobjectA collection of variables related to SWML.
purposestringThe purpose of the function being invoked. The value will be the functions.purpose value you provided in the SWAIG Function parameters.
argument_descstring | objectThe description of the argument being passed. This value comes from the argument you provided in the SWAIG Function parameters.
argumentobjectThe argument the AI agent is providing to the function. The object contains the three following fields.
argument.parsedobjectIf a JSON object is detected within the argument, it is parsed and provided here.
argument.rawstringThe raw argument provided by the AI agent.
argument.substitutedstringThe argument provided by the AI agent, excluding any JSON.
versionstringVersion 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