Agent Builder + FreePBX SIP trunk: how to transfer the caller to a FreePBX queue when they ask for a human?

Hi everyone,

I’m running a voice agent on LiveKit Cloud connected to a FreePBX (Asterisk, PJSIP) server, and I need help adding “transfer to a human” behavior.

Setup

  • LiveKit Cloud project, region EU (Frankfurt)
  • Agent built and deployed with Agent Builder
  • Model in Agent Builder: OpenAI GPT-Live 1 (realtime)
  • Language: Egyptian Arabic (law-office receptionist prompt)
  • Inbound SIP trunk in LiveKit: allow-lists my FreePBX server IP
  • Dispatch rule: type “Individual”, room prefix “call-”
  • FreePBX: a PJSIP trunk pointing to my LiveKit SIP endpoint

Current call flow (works end to end)

Caller → FreePBX Inbound Route (test DID) → FreePBX Queue 925
→ Queue static agent (a dummy number) → FreePBX Outbound Route
→ PJSIP trunk to LiveKit → LiveKit room → my agent

Audio is good, the agent answers and talks normally. I route through a
Queue so I can listen in and count calls.

What I want

When the caller says something like “transfer me to a human”, the agent
should hand the call to a FreePBX queue (extension 555) so a human agent
picks up. A cold transfer is fine.

What I found so far

The docs describe the TransferSIPParticipant API (SIP REFER) with a
function tool in code agents, like:

transfer_to = "sip:555@<my-freepbx-host>"
await job_ctx.api.sip.transfer_sip_participant(
    api.TransferSIPParticipantRequest(
        room_name=..., participant_identity=..., transfer_to=transfer_to
    )
)

But I couldn’t find anything about doing this inside Agent Builder.

Questions

  1. Does Agent Builder have a built-in tool for call transfer / SIP REFER?
    If yes, where do I enable it and what format should the destination
    use (sip:555@host or tel:555)?
  2. If not, can I add a custom tool in Agent Builder, or must I move to a
    code-based agent deployed to LiveKit Cloud?
  3. In my flow FreePBX is the one that originated the call to LiveKit
    (outbound trunk). Is SIP REFER from LiveKit back to FreePBX supported
    in this direction? Is there any known requirement on the Asterisk/PJSIP
    side (allow_transfer, transfer context, etc.)?
  4. I read that TLS is incompatible with REFER. My trunk uses
    [UDP / TCP - please check which one you use] transport. Is that fine?
  5. Is there a way to test the transfer manually during a live call
    (for example with lk sip participant transfer) to confirm FreePBX
    accepts the REFER before wiring it into the agent?

I can share SIP logs (pjsip set logger on) and agent logs if needed.

Thanks a lot!

Hi,

No, there’s no built-in tool for this. Although you could probably patch something together with an external HTTP function tool, I recommend converting to code (Agent Builder | LiveKit Documentation) and continuing development in code. I definitely recommend adding our agent coding tools, Coding agent support and tools | LiveKit Documentation , which let you produce reliable agents without having to understand every line of code.

From LiveKit’s perspective, that would be the inbound trunk. But yes, the SIP REFER would work in that case. I’m not familiar enough with Asterisk to say if there are any known requirements - AI is suggesting the same settings you already referenced (allow_transfer, transfer context) so I’ll defer to someone with hands-on experience.

I’m not sure where you are seeing that incompatibility referenced?

Not sure if that question was aimed at me, but you are using TCP, not UDP :slight_smile: ; you haven’t made any calls over TLS. I did notice you are defining allowed_addresses but be aware that features needs to be enabled, Inbound trunk | LiveKit Documentation

Yes, full docs here: Telephony | LiveKit Documentation .

We also have a troubleshooting section about call transfers here: SIP troubleshooting guide | LiveKit Documentation