> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # Get AI agent GET https://%7BYour_Space_Name%7D.signalwire.com/api/fabric/resources/ai_agents/{id} Retrieves one custom AI Agent from your SignalWire project. Use it to review an agent that is configured directly in SignalWire; use [List AI agents](/docs/apis/rest/ai-agents/ai-agents-custom/list-ai-agents) to find agents, or [Get Dialogflow agent](/docs/apis/rest/ai-agents/ai-agents-dialogflow/get-dialogflow-agent) for a linked Dialogflow resource. #### Permissions The API token used to authenticate must have the following scope(s) enabled to make a successful request: _Voice_, _Messaging_, _Fax_, or _Video_. [Learn more about API scopes](/docs/platform/your-signalwire-api-space). Reference: https://signalwire.com/docs/apis/rest/ai-agents/ai-agents-custom/get-ai-agent ## Authentication - `Authorization` header (basic auth, required) — SignalWire Basic Authentication using Project ID and API Token. The client sends HTTP requests with the Authorization header containing the word Basic followed by a space and a base64-encoded string of project_id:token. The project ID will be used as the username and the API token as the password. Example: ``` Authorization: Basic base64(project_id:token) ``` ## Request ### Path parameters - `id` (string, required) — Unique ID of an AI Agent. ## Response ### 200 The request has succeeded. - `id` (string, required) — Unique ID of the AIAgent. - `project_id` (string, required) — Unique ID of the Project. - `display_name` (string, required) — Display name of the AIAgent Fabric Resource - `type` (enum, required) — Type of the Fabric Resource - Allowed values: `ai_agent` - `created_at` (datetime, required) — Date and time when the resource was created. - `updated_at` (datetime, required) — Date and time when the resource was updated. - `ai_agent` (AIAgent, required) — AIAgent data. ## Errors ### 401 Unauthorized Error Access is unauthorized. - `error` (enum, required) - Allowed values: `Unauthorized` ### 404 Not Found Error The server cannot find the requested resource. - `error` (enum, required) - Allowed values: `Not Found` ### 500 Internal Server Error An internal server error occurred. - `error` (enum, required) - Allowed values: `Internal Server Error` ## Types ### AIAgent Creates an AI agent that conducts voice conversations using automatic speech recognition (ASR), large language models (LLMs), and text-to-speech (TTS) synthesis. The agent processes caller speech in real-time, generates contextually appropriate responses, and can execute custom functions to interact with external systems through SignalWire AI Gateway (SWAIG). See the [SWML `ai` method reference](/docs/swml/reference/calling/ai) for the complete configuration contract. - `prompt` (AiAgentPrompt, required) — Defines the AI agent's personality, goals, behaviors, and instructions for handling conversations. The prompt establishes how the agent should interact with callers, what information it should gather, and how it should respond to various scenarios. It is recommended to write prompts using markdown formatting. See [`ai.prompt` in the SWML reference](/docs/swml/reference/calling/ai#aiprompt). - `agent_id` (string, required) — Unique ID of an AI Agent. - `name` (string, required) — Name of the AI Agent. - `hints` (list of string, optional) — Hints help the AI agent understand certain words or phrases better. Words that can commonly be misinterpreted can be added to the hints to help the AI speak more accurately. See [`ai.hints` in the SWML reference](/docs/swml/reference/calling/ai#aihints). - `languages` (list of AiAgentLanguagesItems, optional) — An array of JSON objects defining supported languages in the conversation. Mutually exclusive with `multilingual`: if both are set, `multilingual` is used and this array is ignored. See [`ai.languages` in the SWML reference](/docs/swml/reference/calling/ai#ailanguages). - `params` (AiAgentParams, optional) — A JSON object containing parameters as key-value pairs. See [`ai.params` in the SWML reference](/docs/swml/reference/calling/ai#aiparams). - `post_prompt` (AiAgentPostPrompt, optional) — The final set of instructions and configuration settings to send to the agent. See [`ai.post_prompt` in the SWML reference](/docs/swml/reference/calling/ai#aipost_prompt). - `pronounce` (list of AiAgentPronounceItems, optional) — An array of JSON objects to clarify the AI's pronunciation of words or expressions. See [`ai.pronounce` in the SWML reference](/docs/swml/reference/calling/ai#aipronounce). - `SWAIG` (AiAgentSwaig, optional) — An array of JSON objects to create user-defined functions/endpoints that can be executed during the dialogue. See [`ai.SWAIG` in the SWML reference](/docs/swml/reference/calling/ai#aiswaig). ### AiAgentPrompt Defines the AI agent's personality, goals, behaviors, and instructions for handling conversations. The prompt establishes how the agent should interact with callers, what information it should gather, and how it should respond to various scenarios. It is recommended to write prompts using markdown formatting. See [`ai.prompt` in the SWML reference](/docs/swml/reference/calling/ai#aiprompt). ### AiAgentLanguagesItems ### AiAgentParams A JSON object containing parameters as key-value pairs. See [`ai.params` in the SWML reference](/docs/swml/reference/calling/ai#aiparams). ### AiAgentPostPrompt The final set of instructions and configuration settings to send to the agent. See [`ai.post_prompt` in the SWML reference](/docs/swml/reference/calling/ai#aipost_prompt). ### AiAgentPronounceItems ### AiAgentSwaig An array of JSON objects to create user-defined functions/endpoints that can be executed during the dialogue. See [`ai.SWAIG` in the SWML reference](/docs/swml/reference/calling/ai#aiswaig). ## Examples **Response** ```json { "id": "993ed018-9e79-4e50-b97b-984bd5534095", "project_id": "1313fe58-5e14-4c11-bbe7-6fdfa11fe780", "display_name": "Support Assistant", "type": "ai_agent", "created_at": "2024-05-06T12:20:00Z", "updated_at": "2024-05-06T12:25:00Z", "ai_agent": { "prompt": { "text": "You are a helpful customer support assistant." }, "agent_id": "a87db7ed-8ebe-42e4-829f-8ba5a4152f54", "name": "Support Assistant" } } ``` **SDK Code** ```python AI agent import requests url = "https://{your_space_name}.signalwire.com/api/fabric/resources/ai_agents/id" response = requests.get(url, auth=("", "")) print(response.json()) ``` ```javascript AI agent const url = 'https://{your_space_name}.signalwire.com/api/fabric/resources/ai_agents/id'; const credentials = btoa(":"); const options = {method: 'GET', headers: {Authorization: `Basic ${credentials}`}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go AI agent package main import ( "fmt" "net/http" "io" ) func main() { url := "https://{your_space_name}.signalwire.com/api/fabric/resources/ai_agents/id" req, _ := http.NewRequest("GET", url, nil) req.SetBasicAuth("", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby AI agent require 'uri' require 'net/http' url = URI("https://{your_space_name}.signalwire.com/api/fabric/resources/ai_agents/id") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request.basic_auth("", "") response = http.request(request) puts response.read_body ``` ```java AI agent import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://{your_space_name}.signalwire.com/api/fabric/resources/ai_agents/id") .basicAuth("", "") .asString(); ``` ```php AI agent request('GET', 'https://{your_space_name}.signalwire.com/api/fabric/resources/ai_agents/id', [ 'headers' => [ ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` ```csharp AI agent using RestSharp; using RestSharp.Authenticators; var client = new RestClient("https://{your_space_name}.signalwire.com/api/fabric/resources/ai_agents/id"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); ``` ```swift AI agent import Foundation let credentials = Data(":".utf8).base64EncodedString() let headers = ["Authorization": "Basic \(credentials)"] let request = NSMutableURLRequest(url: NSURL(string: "https://{your_space_name}.signalwire.com/api/fabric/resources/ai_agents/id")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```