|
1 | 1 | --- |
2 | | -title: Telnyx SIP Integration |
| 2 | +title: Telnyx SIP integration |
3 | 3 | subtitle: How to integrate SIP Telnyx to Vapi |
4 | 4 | slug: advanced/sip/telnyx |
5 | 5 | --- |
6 | 6 |
|
7 | | -Integrate your Telnyx SIP trunk with Vapi.ai to enable your AI voice assistants to handle calls efficiently. This guide walks you through the complete setup process for both inbound and outbound calls. |
8 | | - |
9 | | -## 1. Retrieve Your Vapi.ai Private Key |
10 | | - |
11 | | -- Log in to your Vapi.ai account |
12 | | -- Navigate to **Organization Settings** |
13 | | -- In the **API Keys** section, copy your **Private Key** |
14 | | - |
15 | | -## 2. Configure Telnyx for Inbound Calls |
16 | | - |
17 | | -To allow Telnyx to forward incoming calls to Vapi.ai: |
18 | | - |
19 | | -1. **Create a SIP Trunk** |
20 | | - - Go to Voice / SIP Trunking / Create |
21 | | - - Select FQDN |
22 | | - - Click "Add FQDN" |
23 | | - - Select A record type |
24 | | - - Set FQDN to: `sip.vapi.ai` |
25 | | - - Port should be 5060 by default |
26 | | - |
27 | | -2. **Configure Inbound Settings** |
28 | | - - Navigate to the Inbound tab of your SIP trunk |
29 | | - - Configure settings as shown: |
30 | | - <Frame> |
31 | | - <img src="../../static/images/sip/telynx-inbound.png" /> |
32 | | - </Frame> |
33 | | - |
34 | | -3. **Assign Phone Number** |
35 | | - - Go to the Numbers tab |
36 | | - - Assign your acquired phone number to the SIP trunk |
37 | | - |
38 | | -4. **Configure SIP Invite** |
39 | | - - Go to Numbers, edit the number you'll be using |
40 | | - - Navigate to Voice settings |
41 | | - - Scroll down to find "Translated Number" |
42 | | - - Set this value to match your Vapi SIP URI |
43 | | - |
44 | | - *This setting modifies the SIP Invite to the Vapi platform so invites are correctly routed to your Vapi SIP URI.* |
45 | | - |
46 | | -## 3. Configure Telnyx for Outbound Calls |
47 | | - |
48 | | -To allow Vapi.ai to make outbound calls through your Telnyx account: |
49 | | - |
50 | | -1. **Set Up Outbound Authentication** |
51 | | - - Go to Voice / SIP Trunking / Authentication and routing |
52 | | - - Scroll down to "Outbound calls authentication" |
53 | | - - Create a new credential for Vapi to use |
54 | | - <Frame> |
55 | | - <img src="../../static/images/sip/telynx-outbound-auth.png" /> |
56 | | - </Frame> |
57 | | - |
58 | | -2. **Create Outbound Voice Profile** |
59 | | - - Go to Voice / Outbound Voice Profiles |
60 | | - - Create a new profile |
61 | | - - Name it appropriately |
62 | | - - Configure desired destinations |
63 | | - - Leave default configuration settings |
64 | | - - Assign your SIP trunk |
65 | | - - Complete setup |
66 | | - |
67 | | - Alternatively, go to your SIP trunk / Outbound tab and select your newly created outbound voice profile. |
68 | | - |
69 | | -3. **Configure Outbound Settings** |
70 | | - - Choose the country you'll be making most calls to |
71 | | - |
72 | | - *We recommend creating a separate SIP Trunk for each country you aim to be making most calls to.* |
73 | | - <Frame> |
74 | | - <img src="../../static/images/sip/telynx-outbound-settings.png" /> |
75 | | - </Frame> |
76 | | - |
77 | | -## 4. Add Your Telnyx SIP Credentials to Vapi.ai |
78 | | - |
79 | | -Use the Vapi API to create a SIP trunk credential: |
80 | | - |
81 | | -```bash |
82 | | -curl -X POST https://api.vapi.ai/credential \ |
83 | | - -H "Content-Type: application/json" \ |
84 | | - -H "Authorization: Bearer YOUR_VAPI_PRIVATE_KEY" \ |
85 | | - -d '{ |
86 | | - "provider": "byo-sip-trunk", |
87 | | - "name": "Telnyx Trunk", |
88 | | - "gateways": [ |
89 | | - { |
90 | | - "ip": "sip.telnyx.com" |
91 | | - } |
92 | | - ], |
93 | | - "outboundAuthenticationPlan": { |
94 | | - "authUsername": "YOUR_SIP_USERNAME", |
95 | | - "authPassword": "YOUR_SIP_PASSWORD", |
96 | | - "sipRegisterPlan": { |
97 | | - "realm": "sip.telnyx.com" |
| 7 | +Integrate your Telnyx SIP trunk with Vapi to enable your AI voice assistants to handle calls efficiently. This guide walks you through the complete setup process for both inbound and outbound calls. |
| 8 | + |
| 9 | +<Steps> |
| 10 | + <Step title="Retrieve your Vapi private key"> |
| 11 | + <Steps> |
| 12 | + <Step title="Get your private key"> |
| 13 | + - Log in to your Vapi account |
| 14 | + - Navigate to **Organization Settings** |
| 15 | + - In the **API Keys** section, copy your **Private Key** |
| 16 | + </Step> |
| 17 | + </Steps> |
| 18 | + </Step> |
| 19 | + |
| 20 | + <Step title="Configure Telnyx for inbound calls"> |
| 21 | + <Steps> |
| 22 | + <Step title="Create a SIP trunk"> |
| 23 | + - Go to Voice / SIP Trunking / Create |
| 24 | + - Select FQDN |
| 25 | + - Click "Add FQDN" |
| 26 | + - Select A record type |
| 27 | + - Set FQDN to: `sip.vapi.ai` |
| 28 | + - Port should be 5060 by default |
| 29 | + </Step> |
| 30 | + <Step title="Configure inbound settings"> |
| 31 | + - Navigate to the Inbound tab of your SIP trunk |
| 32 | + - Configure settings as shown: |
| 33 | + <Frame> |
| 34 | + <img src="../../static/images/sip/telynx-inbound.png" /> |
| 35 | + </Frame> |
| 36 | + </Step> |
| 37 | + <Step title="Assign phone number"> |
| 38 | + - Go to the Numbers tab |
| 39 | + - Assign your acquired phone number to the SIP trunk |
| 40 | + </Step> |
| 41 | + <Step title="Configure SIP invite"> |
| 42 | + - Go to Numbers, edit the number you'll be using |
| 43 | + - Navigate to Voice settings |
| 44 | + - Scroll down to find "Translated Number" |
| 45 | + - Set this value to match your Vapi SIP URI |
| 46 | + <Info> |
| 47 | + You can get your Vapi SIP URI when you create a new SIP number through the **Phone Numbers** tab in the Vapi dashboard. The URI will look like: |
| 48 | + <br /> |
| 49 | + <code>sip:<your-unique-id>@sip.vapi.ai</code> |
| 50 | + </Info> |
| 51 | + *This setting modifies the SIP Invite so invites are correctly routed to your Vapi SIP URI.* |
| 52 | + </Step> |
| 53 | + </Steps> |
| 54 | + </Step> |
| 55 | + |
| 56 | + <Step title="Configure Telnyx for outbound calls"> |
| 57 | + <Steps> |
| 58 | + <Step title="Set up outbound authentication"> |
| 59 | + - Go to Voice / SIP Trunking / Authentication and routing |
| 60 | + - Scroll down to "Outbound calls authentication" |
| 61 | + - Create a new credential for Vapi to use |
| 62 | + <Frame> |
| 63 | + <img src="../../static/images/sip/telynx-outbound-auth.png" /> |
| 64 | + </Frame> |
| 65 | + </Step> |
| 66 | + <Step title="Create outbound voice profile"> |
| 67 | + - Go to Voice / Outbound Voice Profiles |
| 68 | + - Create a new profile |
| 69 | + - Name it appropriately |
| 70 | + - Configure desired destinations |
| 71 | + - Leave default configuration settings |
| 72 | + - Assign your SIP trunk |
| 73 | + - Complete setup |
| 74 | + Alternatively, go to your SIP trunk / Outbound tab and select your newly created outbound voice profile. |
| 75 | + </Step> |
| 76 | + <Step title="Configure outbound settings"> |
| 77 | + - Choose the country you'll be making most calls to |
| 78 | + *We recommend creating a separate SIP Trunk for each country you aim to be making most calls to.* |
| 79 | + <Frame> |
| 80 | + <img src="../../static/images/sip/telynx-outbound-settings.png" /> |
| 81 | + </Frame> |
| 82 | + </Step> |
| 83 | + </Steps> |
| 84 | + </Step> |
| 85 | + |
| 86 | + <Step title="Add your Telnyx SIP credentials to Vapi"> |
| 87 | + Use the Vapi API to create a SIP trunk credential: |
| 88 | + ```bash |
| 89 | + curl -X POST https://api.vapi.ai/credential \ |
| 90 | + -H "Content-Type: application/json" \ |
| 91 | + -H "Authorization: Bearer YOUR_VAPI_PRIVATE_KEY" \ |
| 92 | + -d '{ |
| 93 | + "provider": "byo-sip-trunk", |
| 94 | + "name": "Telnyx Trunk", |
| 95 | + "gateways": [ |
| 96 | + { |
| 97 | + "ip": "sip.telnyx.com" |
| 98 | + } |
| 99 | + ], |
| 100 | + "outboundAuthenticationPlan": { |
| 101 | + "authUsername": "YOUR_SIP_USERNAME", |
| 102 | + "authPassword": "YOUR_SIP_PASSWORD", |
| 103 | + "sipRegisterPlan": { |
| 104 | + "realm": "sip.telnyx.com" |
| 105 | + } |
98 | 106 | } |
99 | | - } |
100 | | - }' |
101 | | -``` |
102 | | - |
103 | | -Replace `YOUR_VAPI_PRIVATE_KEY`, `YOUR_SIP_USERNAME`, and `YOUR_SIP_PASSWORD` with your actual credentials. |
104 | | - |
105 | | -If successful, the response will include an `id` for the created credential, which you'll use in the next step. |
106 | | - |
107 | | -## 5. Add Your Phone Number to Vapi.ai |
108 | | - |
109 | | -Associate your phone number with the SIP trunk in Vapi.ai: |
110 | | - |
111 | | -```bash |
112 | | -curl -X POST https://api.vapi.ai/phone-number \ |
113 | | - -H "Content-Type: application/json" \ |
114 | | - -H "Authorization: Bearer YOUR_VAPI_PRIVATE_KEY" \ |
115 | | - -d '{ |
116 | | - "provider": "byo-phone-number", |
117 | | - "name": "Telnyx SIP Number", |
118 | | - "number": "YOUR_PHONE_NUMBER", |
119 | | - "numberE164CheckEnabled": false, |
120 | | - "credentialId": "YOUR_CREDENTIAL_ID" |
121 | | - }' |
122 | | -``` |
123 | | - |
124 | | -Replace `YOUR_VAPI_PRIVATE_KEY`, `YOUR_PHONE_NUMBER`, and `YOUR_CREDENTIAL_ID` with your actual details. |
125 | | - |
126 | | -## 6. Assign Your Voice Assistant to Handle Calls |
127 | | - |
128 | | -- In your Vapi.ai dashboard, go to the **Build** section and select **Phone Numbers** |
129 | | -- Click on your **Telnyx Number** |
130 | | -- In the **Inbound Settings** section, assign your voice assistant to handle incoming calls |
131 | | -- In the **Outbound Form** section, assign your voice assistant to handle outgoing calls |
132 | | - |
133 | | -## 7. Make Outbound Calls |
134 | | - |
135 | | -To initiate outbound calls through your Telnyx SIP trunk: |
136 | | - |
137 | | -```bash |
138 | | -curl --location 'https://api.vapi.ai/call/phone' \ |
139 | | - --header 'Authorization: Bearer YOUR_VAPI_PRIVATE_KEY' \ |
140 | | - --header 'Content-Type: application/json' \ |
141 | | - --data '{ |
142 | | - "assistantId": "YOUR_ASSISTANT_ID", |
143 | | - "customer": { |
144 | | - "number": "CUSTOMER_PHONE_NUMBER", |
145 | | - "numberE164CheckEnabled": false |
146 | | - }, |
147 | | - "phoneNumberId": "YOUR_PHONE_ID" |
148 | | - }' |
149 | | -``` |
150 | | - |
151 | | -Replace all placeholder values with your actual information. |
152 | | - |
153 | | -By following these steps, your Telnyx SIP trunk will be fully integrated with Vapi.ai, allowing your AI voice assistants to manage calls effectively. |
| 107 | + }' |
| 108 | + ``` |
| 109 | + Replace `YOUR_VAPI_PRIVATE_KEY`, `YOUR_SIP_USERNAME`, and `YOUR_SIP_PASSWORD` with your actual credentials. |
| 110 | + If successful, the response will include an `id` for the created credential, which you'll use in the next step. |
| 111 | + </Step> |
| 112 | + |
| 113 | + <Step title="Add your phone number to Vapi"> |
| 114 | + Associate your phone number with the SIP trunk in Vapi: |
| 115 | + ```bash |
| 116 | + curl -X POST https://api.vapi.ai/phone-number \ |
| 117 | + -H "Content-Type: application/json" \ |
| 118 | + -H "Authorization: Bearer YOUR_VAPI_PRIVATE_KEY" \ |
| 119 | + -d '{ |
| 120 | + "provider": "byo-phone-number", |
| 121 | + "name": "Telnyx SIP Number", |
| 122 | + "number": "YOUR_PHONE_NUMBER", |
| 123 | + "numberE164CheckEnabled": false, |
| 124 | + "credentialId": "YOUR_CREDENTIAL_ID" |
| 125 | + }' |
| 126 | + ``` |
| 127 | + Replace `YOUR_VAPI_PRIVATE_KEY`, `YOUR_PHONE_NUMBER`, and `YOUR_CREDENTIAL_ID` with your actual details. |
| 128 | + </Step> |
| 129 | + |
| 130 | + <Step title="Assign your voice assistant to handle calls"> |
| 131 | + - In your Vapi dashboard, go to the **Build** section and select **Phone Numbers** |
| 132 | + - Click on your **Telnyx Number** |
| 133 | + - In the **Inbound Settings** section, assign your voice assistant to handle incoming calls |
| 134 | + - In the **Outbound Form** section, assign your voice assistant to handle outgoing calls |
| 135 | + </Step> |
| 136 | + |
| 137 | + <Step title="Make outbound calls"> |
| 138 | + To initiate outbound calls through your Telnyx SIP trunk: |
| 139 | + ```bash |
| 140 | + curl --location 'https://api.vapi.ai/call/phone' \ |
| 141 | + --header 'Authorization: Bearer YOUR_VAPI_PRIVATE_KEY' \ |
| 142 | + --header 'Content-Type: application/json' \ |
| 143 | + --data '{ |
| 144 | + "assistantId": "YOUR_ASSISTANT_ID", |
| 145 | + "customer": { |
| 146 | + "number": "CUSTOMER_PHONE_NUMBER", |
| 147 | + "numberE164CheckEnabled": false |
| 148 | + }, |
| 149 | + "phoneNumberId": "YOUR_PHONE_ID" |
| 150 | + }' |
| 151 | + ``` |
| 152 | + Replace all placeholder values with your actual information. |
| 153 | + </Step> |
| 154 | +</Steps> |
| 155 | + |
| 156 | +By following these steps, your Telnyx SIP trunk will be fully integrated with Vapi, allowing your AI voice assistants to manage calls effectively. |
0 commit comments