> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# Supabase

접수 담당자는 Supabase의 REST API를 통해 통화 세부 정보를 Supabase 테이블에 저장하고, 전화번호로 발신자를 조회할 수 있습니다. 아래 설정은 행 수준 보안이 적용된 프로젝트의 공개 키를 사용하므로 접수 담당자는 허용한 작업만 수행할 수 있습니다.

> **Warning**
>
> `service_role` 또는 비밀 키를 웹훅 도구에 절대 넣지 마세요. 이러한 키는 행 수준 보안을 우회하여
> 데이터베이스의 모든 권한을 부여합니다.

## 시작하기 전에

Supabase 대시보드에서 **Project Settings** → **API Keys**를 열고 **publishable** 키 또는 레거시 **anon** 키를 복사하세요. 프로젝트 URL은 `https://PROJECT_REF.supabase.co`입니다.

## 데이터베이스 준비

**SQL Editor**에서 다음을 실행하세요. 접수 담당자가 삽입만 할 수 있는 테이블과 정확한 전화번호로 고객 한 명을 반환하는 함수를 생성합니다. 이 함수는 `name`, `plan`, `notes`, `phone` 열이 있는 기존 `customers` 테이블을 전제로 하므로, 스키마에 맞게 이름을 조정하세요.

발신자는 정확한 전화번호를 알고 있지 않으면 이 함수를 사용해 고객 목록을 조회할 수 없습니다.

```sql
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;
```

## 도구 만들기

두 도구 모두에서 **Integrations**로 이동해 **Add integration**을 선택하고 **Webhook Tool**을 선택한 다음, 다음 요청 헤더를 추가하세요.

| 헤더              | 값                                                  |
| --------------- | -------------------------------------------------- |
| `apikey`        | publishable 또는 anon 키                              |
| `Authorization` | `Bearer ` 뒤에 anon 키를 붙입니다. publishable 키에서는 생략하세요. |

### 콜백 요청 저장

| 필드           | 값                                                           |
| ------------ | ----------------------------------------------------------- |
| **이름**       | `save_callback_request`                                     |
| **설명**       | "발신자에게 후속 조치를 약속할 때마다 콜백 요청을 저장합니다."                        |
| **메서드**      | POST                                                        |
| **URL**      | `https://PROJECT_REF.supabase.co/rest/v1/callback_requests` |
| **본문 매개변수**  | `caller_name`, `phone`, `reason` (모두 문자열, 필수)               |
| **에이전트에 할당** | **Receptionist**                                            |

### 고객 조회

| 필드           | 값                                                                    |
| ------------ | -------------------------------------------------------------------- |
| **이름**       | `find_customer`                                                      |
| **설명**       | "전화번호로 발신자의 계정을 조회합니다. 발신자가 요금제나 계정에 관해 문의할 때 사용하세요."                |
| **메서드**      | POST                                                                 |
| **URL**      | `https://PROJECT_REF.supabase.co/rest/v1/rpc/find_customer_by_phone` |
| **본문 매개변수**  | `phone` (문자열, 필수): "E.164 형식의 발신자 전화번호(예: +14155550123)."            |
| **에이전트에 할당** | **Receptionist**                                                     |

각 도구에서 **Enable**을 선택한 다음 콜백 요청으로 [접수 담당자를 테스트하세요](/docs/ko/reception-ai/receptionist/testing). 행이 **Table Editor**에 표시됩니다.

## 문제 해결

| 문제                                           | 확인할 사항                                                |
| -------------------------------------------- | ----------------------------------------------------- |
| `new row violates row-level security policy` | 삽입 정책은 `anon` 역할을 대상으로 해야 합니다.                        |
| `Could not find the function`                | 본문 매개변수 이름은 함수의 인수 이름과 정확히 일치해야 합니다. 여기서는 `phone`입니다. |
| 401 `Invalid API key`                        | publishable 키를 사용하는 경우 `Authorization` 헤더를 제거하세요.     |
| 고객을 찾을 수 없음                                  | 접수 담당자가 전송하는 형식과 동일한 E.164 형식으로 전화번호를 저장하세요.          |