Skip to navigation

Supabase

Save and look up records in your Supabase database with webhook tools.

Your receptionist can save details from a call to a Supabase table and look up a caller by phone number, through Supabase’s REST API. The setup below uses your project’s public key with row-level security, so the receptionist can only do what you allow.

Never put the service_role or secret key in a webhook tool. Those keys bypass row-level security and give full access to your database.

Before you start

In the Supabase dashboard, open Project Settings → API Keys and copy the publishable key, or the legacy anon key. Your project URL is https://PROJECT_REF.supabase.co.

Prepare the database

Run this in the SQL Editor. It creates a table your receptionist can only insert into, and a function that returns one customer by exact phone number. The function assumes an existing customers table with name, plan, notes, and phone columns, so adjust the names to your schema.

Callers can’t use the function to list customers: it returns nothing unless the exact phone number is known.

create table callback_requests (
id bigint generated always as identity primary key,
created_at timestamptz not null default now(),
caller_name text not null,
phone text not null,
reason text not null
);
alter table callback_requests enable row level security;
create policy "Receptionist can add callback requests"
on callback_requests for insert to anon
with check (true);
create function find_customer_by_phone(phone text)
returns table (name text, plan text, notes text)
language sql stable security definer set search_path = public
as $$
select c.name, c.plan, c.notes from customers c where c.phone = find_customer_by_phone.phone limit 1;
$$;
revoke execute on function find_customer_by_phone from public;
grant execute on function find_customer_by_phone to anon;

Create the tools

For both tools, go to Integrations, select Add integration, choose Webhook Tool, and add these request headers:

HeaderValue
apikeyYour publishable or anon key
AuthorizationBearer followed by the anon key. Leave it out for a publishable key.

Save a callback request

FieldValue
Namesave_callback_request
Description”Save a callback request whenever you promise the caller a follow-up.”
MethodPOST
URLhttps://PROJECT_REF.supabase.co/rest/v1/callback_requests
Body Parameterscaller_name, phone, and reason (all strings, required)
Assign to agentsReceptionist

Look up a customer

FieldValue
Namefind_customer
Description”Look up the caller’s account by phone number. Use it when a caller asks about their plan or account.”
MethodPOST
URLhttps://PROJECT_REF.supabase.co/rest/v1/rpc/find_customer_by_phone
Body Parametersphone (string, required): “The caller’s phone number in E.164 format, for example +14155550123.”
Assign to agentsReceptionist

Select Enable on each tool, then test your receptionist with a callback request. The row appears in Table Editor.

Troubleshooting

ProblemWhat to check
new row violates row-level security policyThe insert policy must target the anon role.
Could not find the functionThe body parameter must be named exactly like the function’s argument, here phone.
401 Invalid API keyWith a publishable key, remove the Authorization header.
Customers aren’t foundStore phone numbers in E.164 format, the same format your receptionist sends.