# SWAIG.functions An array of JSON objects to define functions that can be executed during the interaction with the AI. The functions are defined in ## Parameters | Parameter | Type | Description | |:|:--|:| | function Required | string | A unique name for the function. For example, get_weather. | | purpose Required | string | A description of the context and purpose of the function, to explain to the agent when to use it. | | [argument](./argument/index.mdx) Required | object | A JSON object defining the input that should be passed to the function. The fields of this object are the following two parameters. | | active Optional | boolean | Whether the function is active. Default is true. | | 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](./ai_swaig.data_map/data_map.output.mdx#actions). 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.
Default is not set. | | meta_data_token Optional | string | Scoping token for meta_data. If not supplied, metadata will be scoped to functions web_hook_url. Default is set by SignalWire. | | [data_map](./ai_swaig.data_map/index.mdx)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. | | web_hook_url Optional | string | Function-specific URL to send status callbacks and reports to. Takes precedence over a default setting. Default is not set. See [Callback Parameters](./functions.web_hook_url.mdx) for details on the request body. | | web_hook_auth_user Optional | string | Function-specific auth username for web_hook_url endpoint. Takes precedence over a default setting. Default is not set. | | web_hook_auth_pass Optional | string | Function-specific auth password for web_hook_url endpoint. Takes precedence over a default setting. Default is not set. | | 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. Default is not set. | | wait_file_loops Optional | string \| number | The amount of times that wait_file should continuously play/loop. Default is not set. | ## **Examples** {#examples} ### Using SWAIG Functions yaml andJson 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 purpose: To determine what the current weather is in a provided location. argument: properties: location: type: string type: object