FreePBX
FreePBX can be integrated with Fone AI using custom SIP trunk connection.
Have the following information in hand from your Fone AI Console and FreePBX service:
- API_KEY β Create one if needed from the API Keys page
- PUBLIC_IP β Your FreePBX serverβs public IP. You can get it from executing
curl ifconfig.me
using terminal or visting IP Chicken from that server. - BINDING_PORT β The SIP binding port (usually
5060
) - LOCAL_NET β If NAT is applicable, provide the local subnet
- SIP_USERNAME β Your SIP username. Available in the SIP Integration page.
- SIP_PASSWORD β Your SIP password. Available in the SIP Integration page.
FreePBX Configurationsβ
Go to Configuration File Editor using Admin β Config Edit β Asterisk Custom Configuration Files
.
Append the below codes to the respective files
Custom AOR
[ai-aor]
type=aor
max_contacts=20
contact=sip:sip.fone.ai:5060
Custom Auth
[ai-auth]
type=auth
auth_type=userpass
username=SIP_USERNAME ; <-- Replace with your SIP username
password=SIP_PASSWORD ; <-- Replace with your SIP password
Custom Endpoint
[ai-endpoint]
type=endpoint
context=ai-transfer
disallow=all
direct_media=no
allow=ulaw,alaw,gsm
transport=transport-udp-ai
outbound_auth=ai-auth
aors=ai-aor
Custom Registration
[ai-registration]
type=registration
outbound_auth=ai-auth
server_uri=sip:sip.fone.ai:5060
client_uri=sip:ai@PUBLIC_IP:BINDING_PORT ; <-- Replace with your public IP and binding port
contact_user=ai
retry_interval=60
Custom Transports
[transport-udp-ai]
type=transport
protocol=udp
external_media_address=PUBLIC_IP ; <-- Replace with your public IP
;local_net=LOCAL_NET ; <-- Replace with your local net if applicable
external_signaling_address=PUBLIC_IP ; <-- Replace with your public IP
bind=0.0.0.0:BINDING_PORT ; <-- Replace with your binding port
Custom Extensions
[handler]
exten => addheader,1,Set(PJSIP_HEADER(add,X-api-key)=API_KEY) ; <-- Replace with your API Key
;same => n,Set(PJSIP_HEADER(add,X-custom)={"key1":"value1","key2":"value2"})
same => n, Return()
[ai]
exten => _XXXXXXXX.,1,NoOP()
same => n,Dial(PJSIP/${EXTEN}@ai-endpoint,,b(handler^addheader^1))
same => n,Hangup()
Apply Config
Click on the Apply Config button to the right of the topbar to apply the modified configuration
After you set up the configurations, you can dial into the AI through DID or through internal extensions.
For Inbound DIDsβ
Create a Custom Trunkβ
Create a custom trunk by going to Connectivity β Trunks
. Click β Add Trunk β β Add Custom Trunk
.
In the General tab of the Add CUSTOM Trunk, enter the Trunk Name.
Under Custom Settings, enter the Custom Dial String as:
Local/$OUTNUM$@ai
This will invoke the local ai
dialplan context created in extensions_custom.conf
.
Click the Submit button at the bottom to create the custom trunk.
Create an Outbound Routeβ
Create an outbound route by going to Connectivity β Outbound Routes
. Click β Add Outbound Route
.
In the Route Settings tab:
- Enter the Route Name
- Set Trunk Sequence for Matched Routes to the Custom Trunk created earlier
In the Dial Patterns tab:
- Set Prefix to
0000
- Set Match Pattern to
X.
Click the Submit button at the bottom to save the route.
Create a Misc Destinationβ
Go to Applications β Misc Destinations
. Click β Add Misc Destination
.
In the form:
- Set Description appropriately (e.g.,
AI Misc Destination
) - Set Dial to:
0000{campaign_extension}
If you used a different prefix, prepend that to the Campaign Extension from the Fone AI console.
For example, if the prefix is 0000
and the campaign extension is 4140515644
, set Dial to:
00004140515644
Click Submit to create the Misc Destination.
Create an Inbound Routeβ
Go to Connectivity β Inbound Routes
. Click β Add Inbound Route
.
In the form:
- Set the Description
- Set DID Number to your incoming number
- Under Set Destination, choose
Misc Destinations
and select the AI destination created earlier
Click on the Apply Config button to the right of the topbar to apply the modified configuration
Once done, calling the DID will route the call to the Fone AI campaign through FreePBX.
Direct Dial Through an Extensionβ
You can also directly dial the AI from an extension by navigating to Connectivity β Extensions
Create a new extension or edit an existing one.
In the Advanced tab of the extension, scroll down to find the Dial field under the Edit Extension form group. Set the Dial value to:
Local/{campaign_extension}@ai
For e.g., Local/4140515644@ai to connect with the campaign 4140515644.
Click Submit, then click the Apply Config button at the top right to apply the changes.
Once done, calling this extension will route the call to the corresponding Fone AI campaign through FreePBX.