# Agents An agent runs one published scenario on one number (or a number pool) with a fixed number of lines; it answers every inbound call to that number at once and dials out only when an automation gives it a segment. ## The agent list **Operate → Agents** shows each agent as a card (or a table with **List**): status, scenario, phone number, automations and lines. The **Archived** tab keeps agents you archived. ![Agents](https://docs.aiva.apifonica.com/_astro/99a97eac9972c546d5f6ca65e7e5d489.xWrBG3Vh_24sGiu.webp) ## Create an agent Click **+ New agent**, or use **Create agent** in a scenario’s **⋯** menu to start with that scenario filled in. | Field | What to set | | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | | Scenario | What the agent says. Only published scenarios can run; the form shows *published · Ready to run* and an **Open in builder** link | | Number | Where calls go out from and where inbound calls land. **Free** lists unused numbers; **All** also shows numbers in use or inactive (greyed out) | | Lines | Simultaneous calls this agent holds, set with − and +. The hint shows how many lines other agents hold | | Name | Taken from the scenario; change it if you like | The panel on the right summarises the agent and holds the rest of the defaults: - **Calls go out**: calling hours for outbound calls, by default every day 08:00–19:59 in the account time zone. **Edit** sets the days, start and end hour, a template (**Every day**, **Weekdays**, **Weekends**) and the time zone. - **Starts with**: tick **Call recording** (stored with the transcript) if needed. Voicemail detection is set on Start scenario; the agent’s **Voicemail** option no longer changes anything. - SMS and result webhooks are added on the agent page after it is created. The button at the bottom counts the steps left until the required fields are filled, then creates the agent. ![New agent form](https://docs.aiva.apifonica.com/_astro/dab09d027098b8a91d735a9932c3f40a.DjarTvY8_TEqVO.webp) ![Choosing a number: Free and All](https://docs.aiva.apifonica.com/_astro/6395267ef3acc29737f7c868ab8a3cbf.C_2z7D0U_1v3fWo.webp) ![Calling hours](https://docs.aiva.apifonica.com/_astro/296d8cd4ab9a9e8aff84bbfa4240faea.Cvx5_uJu_ZRMbmW.webp) ## Inbound calls As soon as the agent is active, every call to its number runs the scenario its routes pick (see **Routing** below), from the **Inbound** output of the scenario’s Start scenario. An agent with no routes plays its main scenario. No automation is needed. The agent’s lines apply to inbound calls too: when every line is busy, the call is refused. Calling hours apply only to outbound calls; an active agent answers at any hour. ## The agent page Click an agent to open its page. The banner tells you its state, for example *Live. Answering on +34 910 03 47 94. Outbound starts when you pick a segment to call.* - **Scenario**: the scenario it runs and **Open in builder**. - **Incoming calls**: the number, its state (*Answering*) and **View conversations**. - **Calling schedule**: the hours and time zone, with **Edit schedule**. - **Lines**: lines in use out of the total, with **Edit lines**. - **Outgoing calls**: running automations. **Call a segment** opens the form for a new automation on this agent (choose Now there to start calling at once); once the automation starts, it places real calls to every contact in the segment, so check the segment first; see [Automations](https://docs.aiva.apifonica.com/guides/deploy/automations/). - **Activity**: calls and minutes for the agent; test calls are not counted. ![Agent page](https://docs.aiva.apifonica.com/_astro/8643555c5aa66f3a10cf548dcf790191.g880R9IZ_ZFlTl9.webp) ## Routing Routing lets one agent play a different scenario for each call. Before the bot says a word, the agent checks its routes from top to bottom and plays the scenario of the first route whose condition holds; **Otherwise** always comes last and plays the agent’s main scenario. Routes apply to inbound calls, to calls placed through the API and to calls from automations. Use routing to split one large scenario into small ones that are easier to change, test and publish one at a time. For example, a support line with three routes: | Route | Condition | Plays | | -------------------------- | ------------------------------------------- | --------------------------------- | | Callback (outbound) | `call.direction` is `outbound` | Telecom – Callback | | Repeat caller (escalation) | `contact.complaint_status` is `in progress` | Telecom – Escalation | | Otherwise | every other call | Telecom inbound with contact data | ![Routing card on the agent page: two routes and Otherwise](https://docs.aiva.apifonica.com/_astro/d9a4628165ea0976ecf0776ee1e15cee.Z8gz8jj0_1b37NI.webp) ### Add a route 1. On the agent page, in **Routing**, click **+ Add route**. The new route goes above **Otherwise**. 2. Type a **Name**. 3. Build the **Condition**. **Visual** builds it with **+ Add condition** (a single **Condition** or a **Group in brackets**); **AQL** takes it as text, for example `contact.complaint_status = "in progress"`. In AQL, **Tab** takes a suggestion. 4. Pick the scenario in **Choose a scenario**. The picker shows **All**, **Published** and **Drafts**. 5. Click **Add route**. **⋯** on a route opens its actions. ![New route form: name, condition in Visual mode, scenario](https://docs.aiva.apifonica.com/_astro/a64c6d00725fadcf87899a92e15af3f1.D0evHfMb_Z2nsA4x.webp) ### What a condition can use | Field | What it holds | | -------------------------------------------- | ---------------------------------------------------------------------------------- | | `call.direction` | `inbound` or `outbound` | | `call.number` | The other party’s number | | `call.country_code` | The country of that number | | `now`, `now.date`, `now.time`, `now.weekday` | The date and time of the call | | `segment` | A segment the contact is in | | `contact.` | Any data field the account’s contacts hold, for example `contact.complaint_status` | Operators: `=`, `!=`, `<`, `<=`, `>`, `>=`, `IN (…)` and `NOT IN (…)`, joined with `AND` and `OR` and grouped in brackets. Times take durations such as `now - 2h` (`ms`, `s`, `m`, `h`, `d`). ### Good to know - A route can point at a scenario that has no published version yet. Live calls pass over such a route; a test call placed through the agent with the API (`is_test` and `prefer_draft`) can use it, so you hear a new branch before it goes live. - A test call from the builder plays the open scenario directly and skips routing. To check routing, call the agent’s number from your phone. See Test and debug. - Each call records the route it took (`routing_sid` and `routing_plan` in the API). - A scenario or segment that a route uses cannot be deleted. Renaming a contact data field rewrites the conditions that read it; removing such a field is refused. ## Edit an agent **Edit agent** opens all settings on one page; **Save** and **Cancel** are at the top right. | Section | Settings | | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | General | Name, **Gateway** (**Number** or **Number pool**), number, scenario, time zone | | Schedule | **Restrict calling hours** and one or more schedules (days, hours, template); **Add schedule** for more windows | | Lines | Number of lines and **Limit policies**: a named share of lines reserved for automations. Without policies, every automation on the agent competes for all its lines | | [Automations](https://docs.aiva.apifonica.com/guides/deploy/automations/) | The automations on this agent; click one to edit it | | Results | **Send communication results**: when a call completes, its result is POSTed to each **Target URL** you add. See [Result webhooks](https://docs.aiva.apifonica.com/guides/monitor/result-webhooks/) | | SMS | **Send SMS**: the **SMS provider**, the sender type (an alphanumeric name or a number) and the sender. See [SMS sending](https://docs.aiva.apifonica.com/guides/deploy/sms-sending/) | | Advanced | **Active** (initial status), the **Call recording** option, and **Test mode** for testing and debugging. The **Voicemail** option no longer changes anything: voicemail detection is set on Start scenario | ![Edit agent: General](https://docs.aiva.apifonica.com/_astro/fac944a9b42da35eb835c01b228b40fc.HQjoKugh_1VqSpd.webp) ![Edit agent: Lines and limit policies](https://docs.aiva.apifonica.com/_astro/8c88d71dada1f1abc718448cbba274b2.BRMtb6JV_Z3Yer6.webp) ![Edit agent: Results webhooks](https://docs.aiva.apifonica.com/_astro/c2d6df280f4f58868cd05d8a6e209386.DFzex4jD_1kB9iv.webp) ![Edit agent: SMS sender](https://docs.aiva.apifonica.com/_astro/0a68aed48afed9efaef58d5ab9918761.DfmbNKbp_qYaDt.webp) ![Edit agent: Advanced](https://docs.aiva.apifonica.com/_astro/b64d11c38a2805ccb1a903c3b602c708.BFYu_wgL_28OTvW.webp) ## Disable, archive, delete | Action | Effect | Undo | | ------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------- | | Disable | Pauses dialling; keeps the number and settings | Turn it back on: **Agent actions → Enable** | | Archive | Archives its automations and frees the number; a new agent on that number starts without routes | Cannot be undone | | Delete | Removes the agent; only possible after archiving | Cannot be undone | All three are in the agent’s **⋯** menu. A number carries at most one agent (a number pool can be shared): archive an old agent to free its number, or see [Phone numbers](https://docs.aiva.apifonica.com/guides/deploy/phone-numbers/).