Integrating OpenAI Realtime Voice Agents with FusionPBX

Assumptions
  • Your OpenAI project is already configured, you have a project id and your agent is deployed.  If not, check out our OpenAI Real Time Starter Pack.

Setup TLS on the External Profile

OpenAI only supports signaling over TLS.  Hence, we have to setup TLS on the FusionPBX external profile.
  1. First open an ssh terminal or console window on your FusionPBX server and execute the following
cd /usr/src/fusionpbx-install.sh/debian/resources/
letsencrypt.sh
  1. Login to your FusionPBX installation.
  1. Navigate to Advanced > Variables.
  2. Scroll down to SIP Profile: External
  1. Click on external_ssl_enable
  2. Set external_ssl_enable value to true in lowercase as shown below:
  1. Click Save
  2. Navigate to Status > SIP Status.
  3. Click FLUSH CACHE at the top right.

Option 1: Using the Bridge App (Recommended)

Setup a Gateway

  1. Login to your FusionPBX installation
  2. Click Accounts -> Gateway
  3. Click Add
  4. Enter the following fields
    1. Gateway Name: choice any name
    2. Proxy: sip.api.openai.com:5061;tls
    3. Register set to False
  1. Click Save

Setup a Bridge

Setting up a Bridge will make the connection available from the different App in FusionPBX.  This means that you can select it when setting up routing logic in FusionPBX.
  1. Click Applications -> Bridge
  2. Enter in the following fields
    1. Name: choice any name
    2. Action: Gateway
    3. Gateways: Select the Gateway that you just created
    4. Destination Number: This is your OpenAI Project ID
  1. Click Save

Setup a Destination

  1. Click Dialplan -> Destinations
  2. Enter in the following information
    1. Destination: Enter in the DID that you received from your carrier
    2. Actions: Select the Bridge that you just created

Option 2: Connect Using External Profile Directly

Setup an Inbound Route

We will configure an Inbound route to bridge the call to OpenAI Real Time
  1. Login to your FusionPBX installation
  2. Click Dial Plan -> Destinations
  3. Click Add
  4. Enter your DID in the Destination field
  1. Click Save
  2. Click Dial Plan -> Inbound Routes
  1. Click the Destination number that you just entered.  It should look like this:
  1. Add an action tag with a type of bridge with sofia/external/proj_htXkeMVNcVimD9CMKMjR08Xg@sip.api.openai.com:5061;transport=tls.  Note the username portion should be replaced with your project id, which can be found in the OpenAI Dashboard.
  1. Click Save

Test New Inbound Route

  1. Login to the FusionPBX server using ssh
  2. Place a call to the DID that you defined