MediaSFU Blog

Build an AI Phone Receptionist with n8n, Your Own SIP Trunk and Your Own AI Keys

· Tutorial

A desk phone and a smartphone send glowing sound waves into a calm teal orb, the AI receptionist, and a thin line carries each call on to a floating automation workflow of connected cards.

A phone that rings out, or a voicemail nobody plays back until Monday, costs you the customer who called. This guide builds an AI receptionist that answers your business number, takes a proper message and offers a callback, then drops every call's summary into your n8n workflow, where it becomes a Slack message, a spreadsheet row or a CRM entry.

You keep the three pieces that matter: your own phone number on your own SIP trunk, your own AI provider keys (or MediaSFU-managed AI if you'd rather not), and your own self-hosted n8n. MediaSFU sits in the middle: it answers the call, runs the voice agent and writes the summary.

What you'll build

A flow diagram: a caller calls your number, the call travels over SIP from your SIP trunk to the MediaSFU AI receptionist, which uses your AI keys; when the call ends, a Phone Call Summary Ready event reaches the MediaSFU Trigger in n8n, which sends it on to Slack and Google Sheets.
  1. Someone calls your number. Your SIP provider passes the call to MediaSFU.
  2. The AI receptionist attached to that number answers, using your AI provider key.
  3. When the caller hangs up, MediaSFU writes a summary and sends it to your n8n workflow.
  4. n8n tells the front desk on Slack when a callback is needed, and logs every call in Google Sheets.

No code runs on your side apart from n8n. Allow about 30 minutes.

Before you start

  • A MediaSFU account and an API key from mediasfu.com/api-keys. A sandbox key is fine while you build.
  • A phone number on a SIP trunk. This guide uses a Twilio Elastic SIP Trunk; the docs also cover VoIP.ms, and Telnyx, Plivo and other providers work the same way.
  • An AI provider key for the voice agent, for example a Gemini Live or OpenAI Realtime key. Or skip it and use MediaSFU-managed AI.
  • A self-hosted n8n that the internet can reach over HTTPS without a custom port. For now the MediaSFU node installs on self-hosted n8n.

Step 1: Connect your SIP trunk

Your trunk needs to trust MediaSFU, and MediaSFU needs to know your number. In the Twilio Console, open your Elastic SIP Trunk:

  • IP Access Control List (Termination): add both MediaSFU SIP signalling addresses as /32 entries. MediaSFU signals from two regions, so keep both. The current addresses are on the Telephony guide.
  • Origination SIP URI (incoming calls): your number at sip01.mediasfu.com, for example sip:+15551234567@sip01.mediasfu.com.
  • Associate your number with the trunk.

Then, in the MediaSFU dashboard, open Phone & SIP Setup and choose Add a number:

  1. Enter the number in E.164 format (+15551234567), choose Twilio and the direction Both.
  2. On Peer Config, paste the host from the trunk's Termination SIP URI (for example your-trunk.pstn.twilio.com, without sip: or a port). Use port 5060 for UDP or TCP, or 5061 for TLS, and leave Register with Provider off.
  3. Choose Create SIP Config.

Prefer to script it? The same line can be created over HTTP from your server:

curl -X POST https://mediasfu.com/v1/sipconfigs \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $MEDIASFU_API_USERNAME:$MEDIASFU_API_KEY" \
  -d '{"action":"create","contactNumber":"+15551234567","provider":"twilio","supportSipActive":true,"supportSipNameCalls":true,"allowOutgoing":true}'

The full walkthrough, with fixes for calls that don't connect, is in Connect a Twilio SIP trunk.

Step 2: Add your AI keys

The receptionist listens, thinks and speaks with the AI provider you choose. In the dashboard, open AI Provider Keys and add your key under a nickname. A realtime speech provider such as Gemini Live or OpenAI Realtime gives the most natural conversation.

From your server, the same thing is one request:

curl -X POST https://mediasfu.com/v1/aicredentials \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $MEDIASFU_API_USERNAME:$MEDIASFU_API_KEY" \
  -d '{"action":"create","nickName":"front-desk-voice","type":"VOICE","extra":[{"key":"service","value":"Gemini-Live"}],"apiKey":"your-provider-key"}'

The supported providers include OpenAI, Anthropic Claude, Gemini, Deepgram, AssemblyAI, Whisper, ElevenLabs, Cartesia, OpenAI Realtime and Gemini Live; the dashboard's wizard lists more voices and options. MediaSFU shows the key masked from then on. To use MediaSFU-managed AI instead, skip this step.

Step 3: Create the receptionist

Open the Agents Workspace and pick the AI Receptionist template. Fill in your company name and the agent's name. The template's instructions are a good start:

You are {agentName}, the friendly AI receptionist for {companyName}. Greet people warmly, find out why they are reaching out, and either answer their question, take a detailed message, or offer a callback. Always collect the person's name and best contact number or email before wrapping up. If a request is urgent or clearly needs a person, offer to connect them with the team. Never invent details you are not sure about — take a message instead.

It greets callers first: "Hi! Thanks for reaching {companyName}. I'm {agentName}, the virtual receptionist. How can I help you today?" Add your opening hours, services and anything callers often ask, choose the AI key from Step 2, and attach the agent to your number.

Call your number now. The receptionist should answer. Ask a question, leave your name, and hang up.

Step 4: Install the MediaSFU node in n8n

In n8n, open Settings → Community Nodes → Install, enter n8n-nodes-mediasfu and accept the prompt. (From the command line instead: npm install n8n-nodes-mediasfu in your n8n custom-nodes folder, then restart n8n.) Search the node panel for MediaSFU: you should see MediaSFU (actions) and MediaSFU Trigger.

Add a MediaSFU API credential with your API username and API key. n8n tests it by reading your balance. The key stays in n8n's credential store and is sent only to MediaSFU.

Step 5: Send every call to your workflow

An n8n workflow canvas: the MediaSFU Trigger node, set to Phone Call Summary Ready, connects to an IF node that checks whether the summary mentions a callback; the true branch goes to a Slack node that messages the front desk, and both branches end in a Google Sheets node that appends a row.

Create a workflow and add these nodes:

  1. MediaSFU Trigger with the event Phone Call Summary Ready. Copy its production URL.
  2. IF, with the condition: {{ ($json.summary || '').toLowerCase() }} contains call back, OR the same expression contains callback.
  3. On the true branch, Slack: post to your front-desk channel.
  4. On both branches, Google Sheets: append a row to your call log.

Now point your number at the trigger. In Phone & SIP Setup, open your number and set its webhook URL to the trigger's production URL. Give the number a secure code if it has none, and enter the same code in the trigger's Call Webhook Token. The trigger refuses any request without that code, so nobody else can post fake calls into your workflow.

Each call arrives as a flat item, ready for expressions:

FieldWhat it holds
callerThe caller's number
calledNumberYour number they called
durationSecondsCall length
agentAnsweredWhether the receptionist took the call
summaryThe AI summary of the conversation
transcriptThe conversation, message by message
sipCallIdThe call's ID, for the MediaSFU node's call operations

A Slack message that the front desk can act on:

📞 Callback needed: {{ $json.caller }} called {{ $json.calledNumber }} ({{ $json.durationSeconds }} s)
{{ $json.summary }}

For the sheet, map columns such as Time ({{ $now }}), Caller, Number called, Duration, Summary and Call ID.

Step 6: Get a person on urgent calls

The receptionist offers to connect a caller with your team when something is urgent. Catch that moment with a second workflow: MediaSFU Trigger on Human Handoff Requested (same webhook URL and token), then Slack with {{ $json.priority }}, {{ $json.handoffReason }} and {{ $json.caller }}.

When a teammate is ready in the call's room, the MediaSFU node's Agent Call → Hand to Person operation, with the sipCallId, switches the live call from the agent to them. AI call control covers handing calls back and forth.

Test it

  1. Activate both workflows. The trigger listens on its production URL only while the workflow is active.
  2. Call your number, ask to be called back tomorrow, and hang up.
  3. Within a few seconds of the summary, a Slack message and a new sheet row appear.

If nothing arrives:

SymptomFix
The call rings but nobody answersAttach the agent to the number in the Agents Workspace, and check the number's SIP config is active
The trigger never firesn8n must be on public HTTPS without a custom port, and the workflow must be active, not just under test
Phone call events return 401The number's secure code and the trigger's Call Webhook Token must match
No summary arrivesSummaries need an AI provider: add your key under AI Provider Keys, or use MediaSFU-managed AI

After hours

Use a second agent for evenings and weekends: the After-hours line template tells callers when the team is next available, takes a clear message and marks anything urgent. Attach it to the number when the office closes, or switch agents on a schedule from your automation.

Good to know

  • Calls are recorded only if you turn on Auto Record for the number.
  • When a caller books a callback, the Callback Requested event passes the request on but never the caller's PIN.
  • The MediaSFU node also works as a tool for n8n's AI Agent node, and can create rooms, start outbound agent calls and read recordings.
  • A sandbox key keeps everything in sandbox while you build; switch the credential to a production key when you go live.

Next steps

Get your API key at mediasfu.com and let the receptionist take your next call.