|
| 1 | +--- |
| 2 | +title: "SIP" |
| 3 | +sidebarTitle: "SIP" |
| 4 | +description: "You can make SIP calls to Vapi Assistants." |
| 5 | +--- |
| 6 | + |
| 7 | +<Accordion title="1. Create an Assistant."> |
| 8 | + |
| 9 | +## 1. Create an Assistant |
| 10 | + |
| 11 | +We'll create an assistant with `POST /assistant` endpoint. This is no different than creating an assistant for other transports. |
| 12 | + |
| 13 | +```json |
| 14 | +{ |
| 15 | + "name": "My SIP Assistant", |
| 16 | + "firstMessage": "Hello {{first_name}}, you've reached me over SIP. How can I help you today?" |
| 17 | +} |
| 18 | + |
| 19 | +``` |
| 20 | + |
| 21 | +</Accordion> |
| 22 | + |
| 23 | +<Accordion title="2. Create a SIP Phone Number."> |
| 24 | + |
| 25 | +## 2. Create A SIP Phone Number |
| 26 | + |
| 27 | +We'll create a SIP phone number with `POST /phone-number` endpoint. |
| 28 | + |
| 29 | +```json |
| 30 | +{ |
| 31 | + "provider": "vapi", |
| 32 | + "sipUri": "sip:your_unique_user_name@sip.vapi.ai", |
| 33 | + "assistantId": "your_assistant_id" |
| 34 | +} |
| 35 | + |
| 36 | +``` |
| 37 | + |
| 38 | +`sipUri` is the SIP URI of the phone number. It must be in the format `sip:username@sip.vapi.ai`. You are free to choose any username you like. |
| 39 | + |
| 40 | +</Accordion> |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +<Accordion title="3. Start a SIP call."> |
| 45 | + |
| 46 | +## 3. Start a SIP call. |
| 47 | + |
| 48 | +You can use any SIP softphone to test the Assistant. Examples include [Zoiper](https://www.zoiper.com/) or [Linphone](https://www.linphone.org/). |
| 49 | + |
| 50 | +You just need to dial `sip:your_unique_user_name@sip.vapi.ai` and the Assistant will answer your call. |
| 51 | + |
| 52 | +There is no authentication or SIP registration required. |
| 53 | + |
| 54 | +</Accordion> |
| 55 | + |
| 56 | +<Accordion title="4. Send SIP Headers to Fill Template Variables."> |
| 57 | + |
| 58 | +## 4. Send SIP Headers to Fill Template Variables. |
| 59 | + |
| 60 | +To fill your template variables, you can send custom SIP headers. |
| 61 | + |
| 62 | +For example, to fill the `first_name` variable, you can send a SIP header `x-first_name: John`. |
| 63 | + |
| 64 | +The header name is case insensitive. So, `X-First_Name`, `x-first_name`, and `X-FIRST_NAME` are all the same. |
| 65 | + |
| 66 | +</Accordion> |
| 67 | + |
| 68 | +<Accordion title="5. Use a Custom Assistant For Each Call."> |
| 69 | + |
| 70 | +## 5. Use a Custom Assistant For Each Call. |
| 71 | + |
| 72 | +You can use a custom assistant for SIP calls same as phone calls. |
| 73 | + |
| 74 | +Set the `assistantId` to `null` and the `serverUrl` to the URL of your server which will respond to the `assistant-request`. |
| 75 | + |
| 76 | +`PATCH /phone-number/:id` |
| 77 | +```json |
| 78 | +{ |
| 79 | + "assistantId": null, |
| 80 | + "serverUrl": "https://your_server_url" |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +Now, every time you make a call to this phone number, the server will receive a `assistant-request` event. |
| 85 | + |
| 86 | +</Accordion> |
| 87 | + |
0 commit comments