# LiveKit Cloud

> Connect LiveKit Cloud to Edesy in both directions - an outbound SIP trunk to your Edesy termination trunk, and an inbound trunk plus dispatch rule for calls on your Edesy number.

Source: https://edesy.in/docs/sip-trunking/guides/livekit-cloud

To connect LiveKit Cloud to Edesy, create two trunks on the LiveKit side. An **outbound trunk** points at your Edesy termination trunk so LiveKit agents can call phones. An **inbound trunk** gives you a LiveKit SIP URI, which you save in Edesy as a destination and attach to your number so incoming calls reach your agent.

## Before you start

- An Edesy termination trunk (credentials mode is simplest for LiveKit Cloud). See [Create a Trunk](https://edesy.in/docs/sip-trunking/termination-trunks/create-a-trunk).
- An Edesy number to use as caller ID and to receive calls.
- The LiveKit CLI (`lk`) logged in to your LiveKit Cloud project.

The **SIP** page in the Edesy portal has a **Wire LiveKit Cloud** card that fills in these snippets with your trunk's values.

## Outbound: LiveKit to Edesy

Save this as `outbound-trunk.json`:

```json
{
  "trunk": {
    "name": "Edesy outbound",
    "address": "tk-1a2b3c4d.trunk.edesy.in:5070",
    "numbers": ["+91XXXXXXXXXX"],
    "auth_username": "user-1a2b3c4d",
    "auth_password": "YOUR_TRUNK_PASSWORD",
    "transport": "SIP_TRANSPORT_AUTO"
  }
}
```

- `address` is your trunk host with port `5070`.
- `numbers` lists the Edesy numbers LiveKit may use as caller ID.
- For an IP allowlist trunk, drop `auth_username` and `auth_password`, and add LiveKit's egress IPs to the Edesy trunk.

Create the trunk and place a test call:

```bash
lk sip outbound create ./outbound-trunk.json
lk sip participant create --trunk <SIP_TRUNK_ID> --to +91XXXXXXXXXX --room test-room
```

## Inbound: Edesy to LiveKit

Save this as `inbound-trunk.json`:

```json
{
  "trunk": {
    "name": "Edesy inbound",
    "numbers": ["+91XXXXXXXXXX"]
  }
}
```

```bash
lk sip inbound create ./inbound-trunk.json
```

Then:

1. Copy your project's SIP URI from the LiveKit Cloud dashboard. It looks like `sip:<project>.sip.livekit.cloud`.
2. In Edesy, open **SIP → Inbound destinations → New destination**. Name it `My LiveKit Cloud` and save the URI with your number as the user part: `sip:+91XXXXXXXXXX@<project>.sip.livekit.cloud`.
3. Click **Test call** on the destination.
4. On your Edesy number, set **Inbound routing** to **SIP URI** and pick `My LiveKit Cloud`.

Optionally, add a dispatch rule so LiveKit puts each call in its own room or assigns your agent:

```bash
lk sip dispatch create --trunk <SIP_TRUNK_ID> --room-prefix call-
```

## Checklist

| Item | Value |
|---|---|
| Outbound address | `tk-<id>.trunk.edesy.in:5070` |
| Outbound auth | Trunk username and password, or IP allowlist |
| Caller ID | An Edesy number in the outbound trunk's `numbers` |
| Inbound destination | `sip:<number>@<project>.sip.livekit.cloud` |
| Codecs | G.711 μ-law / A-law |

## FAQ

### Calls from LiveKit fail with 403.

The caller ID is not one of your Edesy numbers, or (IP mode) LiveKit's IP is not on the trunk's allowlist.

### Inbound calls reach LiveKit but no agent joins.

Add a dispatch rule, or check that your agent is registered for the room the rule creates.

### Do I need the number in the inbound URI?

Yes, include it as the user part. LiveKit matches the inbound trunk on the dialled number.

See also [LiveKit SIP docs](https://docs.livekit.io/sip/quickstarts/).
