> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slng.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Place calls from an agent

> Create an outbound connection so an agent can dial out and transfer callers to a person.

An outbound connection gives an agent a caller ID and a route to the phone
network. Without one, [call dispatch](/guides/agents/telephony/dispatch-calls)
fails and the Transfer Call tool has no carrier route. For how connections work
and where they live, see
[Connect a phone number](/guides/agents/telephony/overview).

You can share an outbound connection across multiple agents in the same region.
Create separate connections when agents need different caller ID pools or
carrier routes.

## Prerequisites

Before you begin:

* A SIP trunk with your carrier, and at least one number on it to use as a
  caller ID, in E.164 format (`+15551234567`).
* The termination host and SIP credentials for that trunk. In Twilio these live
  under Elastic SIP Trunking.
* Admin access to your SLNG organisation. Creating a connection is a dashboard
  task, and the **Telephony** section is admin only.
* An agent to place the calls. Keep its ID for the API path. If you do not have
  one, see [Create an agent](/guides/get-started/create-a-project/create-agent).
* An SLNG key for the API path. See
  [How to set up](/guides/get-started/quickstart).

## Create the connection

<Steps>
  <Step title="Open the Telephony section">
    In the dashboard sidebar, open **Telephony**, stay on the **Outbound** tab,
    and click **Add connection**. Pick **Twilio** for the guided setup or
    **Manual** for any other SIP provider.

    <Frame caption="The Outbound tab of the Telephony section, with each connection's status and agents.">
      <img src="https://mintcdn.com/slng-new-docs/_MURdOw87SJsfVag/heroshots/telephony-outbound-list.png?fit=max&auto=format&n=_MURdOw87SJsfVag&q=85&s=145de1ac672679c5666568b026091165" alt="The Telephony section listing outbound connections with status, caller ID count, and agent count" width="2560" height="1600" data-path="heroshots/telephony-outbound-list.png" />
    </Frame>
  </Step>

  <Step title="Name the connection and set the route">
    Fill in four values:

    | Field                        | What to enter                                                                                                                       |
    | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
    | **Connection name**          | A name you will recognize in the agent picker, such as `wayne-enterprises-outbound`                                                 |
    | **Termination host**         | The carrier host that accepts outbound calls, such as `wayne.pstn.twilio.com`. In Twilio, use the host from the Termination SIP URI |
    | **Caller ID pool (rotates)** | The E.164 numbers the agent calls from, one per line or comma-separated                                                             |
    | **Transport**                | **Auto**, unless your carrier requires **UDP**, **TCP**, or **TLS**                                                                 |

    <Frame caption="The first step of the outbound wizard: name, termination host, caller IDs, and transport.">
      <img src="https://mintcdn.com/slng-new-docs/fgzHSTXC7k7AhIuF/heroshots/telephony-outbound-twilio-step-1.png?fit=max&auto=format&n=fgzHSTXC7k7AhIuF&q=85&s=d2130be002c4f9cebfa481b58ac37bf9" alt="Step one of the create outbound connection wizard showing the name, termination host, caller ID, and transport fields" width="2560" height="1600" data-path="heroshots/telephony-outbound-twilio-step-1.png" />
    </Frame>
  </Step>

  <Step title="Set the SIP credentials">
    Enter the auth username and password your carrier expects. In Twilio mode
    you can click **Generate credentials** to have SLNG produce a pair, then add
    that pair to Twilio in the next step.

    Passwords must contain at least one uppercase letter, which is a Twilio
    requirement rather than an SLNG one.

    <Frame caption="The credentials step, with the option to generate a username and password.">
      <img src="https://mintcdn.com/slng-new-docs/fgzHSTXC7k7AhIuF/heroshots/telephony-outbound-twilio-step-2.png?fit=max&auto=format&n=fgzHSTXC7k7AhIuF&q=85&s=9767d1e5af02896061ac47aebfaa941b" alt="Step two of the create outbound connection wizard showing auth username and password fields with a generate button" width="2560" height="1600" data-path="heroshots/telephony-outbound-twilio-step-2.png" />
    </Frame>
  </Step>

  <Step title="Finish the setup on your carrier">
    In **Twilio** mode the last step is a checklist to complete in the Twilio
    console:

    * **Credentials List**: add the username and password from the previous step.
    * **Termination**: confirm the termination host matches what you entered.
    * **Numbers**: confirm your Twilio number is attached to the trunk.

    <Frame caption="The final step lists the Twilio console tasks, then Create connection provisions the trunk.">
      <img src="https://mintcdn.com/slng-new-docs/fgzHSTXC7k7AhIuF/heroshots/telephony-outbound-twilio-step-3.png?fit=max&auto=format&n=fgzHSTXC7k7AhIuF&q=85&s=355d223b613d18a1817bb039b878d0eb" alt="Step three of the create outbound connection wizard showing the Twilio checklist and the Create connection button" width="2560" height="1600" data-path="heroshots/telephony-outbound-twilio-step-3.png" />
    </Frame>

    In **Manual** mode there is no checklist. Configure the carrier to accept
    calls authenticated with the credentials you entered.
  </Step>

  <Step title="Wait for the connection to become active">
    A new connection starts as `pending`, then becomes `active`. If it ends in
    `error`, the connection shows the reason. You cannot attach a connection to
    an agent until it is active.
  </Step>
</Steps>

## How the caller ID is chosen

An outbound connection can hold more than one number. The caller ID is selected
at random from this pool for each call. Edit the connection to add or remove
numbers.

The caller ID always comes from this pool. A dispatch request sets the
destination number, so give a campaign that needs a specific caller ID its own
connection.

## Attach the connection to an agent

<Tabs>
  <Tab title="Dashboard" icon="monitor">
    Open the project, go to its **Telephony** section, and pick the connection
    under **Outbound calls**. You can pick the same connection for multiple
    agents in the same region.

    <Frame caption="The project's Telephony section, with the outbound connection picker open.">
      <img src="https://mintcdn.com/slng-new-docs/_MURdOw87SJsfVag/heroshots/telephony-attach-outbound.png?fit=max&auto=format&n=_MURdOw87SJsfVag&q=85&s=eb006382597c90b4e8ad0e9998e06bb3" alt="The project Telephony section with the outbound connection dropdown open" width="2560" height="1600" data-path="heroshots/telephony-attach-outbound.png" />
    </Frame>
  </Tab>

  <Tab title="API" icon="code">
    List the connections available to the agent.

    ```bash Request theme={null}
    curl https://api.agents.slng.ai/v1/agents/$AGENT_ID/sip-trunk-options \
      -H "Authorization: Bearer $SLNG_API_KEY"
    ```

    ```json Response expandable theme={null}
    {
      "inbound": [],
      "outbound": [
        {
          "id": "8d2a7c60-19be-4e35-a4f7-0c53f1b9e2d4",
          "name": "wayne-enterprises-outbound",
          "livekit_trunk_id": "ST_a8Jk3mP2wQ9R",
          "numbers": ["+15551234567"],
          "status": "active",
          "selectable": true,
          "is_current": false,
          "unavailable_reason": null
        }
      ]
    }
    ```

    Copy the `id` of a connection where `selectable` is `true`, then set
    `sip_outbound_trunk_id` on the agent.

    ```bash Request theme={null}
    curl -X PATCH https://api.agents.slng.ai/v1/agents/$AGENT_ID \
      -H "Authorization: Bearer $SLNG_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{ "sip_outbound_trunk_id": "8d2a7c60-19be-4e35-a4f7-0c53f1b9e2d4" }'
    ```

    A successful response returns the updated agent with
    `sip_outbound_trunk_id` set to the connection ID. Sending `null` detaches the
    connection.
  </Tab>
</Tabs>

If a connection shows as **(Unavailable)** in the picker, it cannot be attached
yet. See
[When a connection cannot be attached](/guides/agents/telephony/overview#when-a-connection-cannot-be-attached).

## Verify outbound calls

Use [Dispatch outbound calls](/guides/agents/telephony/dispatch-calls) to call a
number you can answer. Confirm that the phone rings, the caller ID belongs to the
connection's pool, and the agent uses `outbound_greeting` when you have set one.
If the call fails, confirm that the connection is `active`, attached to the
agent, and configured with credentials that your carrier accepts.

## What an outbound connection is required for

With one attached, the agent can:

* Be dispatched on a call. See
  [Dispatch outbound calls](/guides/agents/telephony/dispatch-calls).
* Use `outbound_greeting`, so a person the agent called hears a different
  opening line than someone who dialled in. Directional greetings need at least
  one connection attached, and the agent fails to save without one.
* Use the Transfer Call tool, which places an outbound call to reach a person.

## Rotate the credentials

For a Twilio connection, keep the old credentials in Twilio until you verify the
new pair:

<Steps>
  <Step title="Generate a new pair">
    In the **Telephony** section, open **Rotate creds**, then click **Generate
    credentials**. Copy the new username and password.
  </Step>

  <Step title="Add the pair to Twilio">
    Add the new pair to the trunk's **Credentials List**. Do not remove the old
    pair yet.
  </Step>

  <Step title="Activate the new credentials">
    Return to the dashboard and click **Activate**. The connection starts using
    the new pair immediately.
  </Step>

  <Step title="Verify and remove the old pair">
    Place a test call and confirm that it connects. You can then remove the old
    pair from Twilio.
  </Step>
</Steps>

<Frame caption="Rotate creds generates a new username and password. Update Twilio before you activate it.">
  <img src="https://mintcdn.com/slng-new-docs/fgzHSTXC7k7AhIuF/heroshots/telephony-rotate-credentials.png?fit=max&auto=format&n=fgzHSTXC7k7AhIuF&q=85&s=a52ee7f0524859fec8e8f687f43677ae" alt="The Rotate credentials dialog with a generated username, a Generate credentials button, and Activate" width="2560" height="1600" data-path="heroshots/telephony-rotate-credentials.png" />
</Frame>

For a manual connection, open **Edit** and update the username and password to
match the pair configured by your carrier. Coordinate the change because calls
can fail while the two sides use different credentials.

## Next steps

* [Dispatch outbound calls](/guides/agents/telephony/dispatch-calls) to place
  the first one.
* [Receive calls on a number](/guides/agents/telephony/inbound) if callers also
  dial the agent.
