API reference / Voice and AI
Connect FreeSWITCH
This page connects FreeSWITCH, and FusionPBX on top of it, to Drop Cowboy®:
- Text to speech.
speakplays text in Drop Cowboy voices, and FusionPBX's Speech app records greetings in them. - AI agents. A gateway sends live calls to one of your published AI agents over SIP.
- Sends. A send preset, such as a voicemail or a text, is triggered by its send URL. FusionPBX gets a Send Now page for it, and texts to your Drop Cowboy numbers reach its SMS app.
For answering machine detection, see Replace FreeSWITCH AMD.
| What you install | dc-connect, one static Linux binary, linked as dc-tts |
| What you need | A connector key, with the scopes for the parts you use |
| Where secrets live | /etc/dc-tts/dc-tts.conf and /etc/dc-connect/dc-connect.conf, mode 0640 |
| Versions | Tested on FreeSWITCH 1.10.12 |
Before you start
- A connector key. Create one in the dashboard or with the API. See
Create a connector key. Give
it
tts:synthesizefor text to speech andconnect:triggerfor sends. AI agents need the SIP scope described in SIP login. Setallowed_cidrsto the public address your server connects from. - Outbound access from the server to
api-v2.dropcowboy.comon port 443. AI agents also needsip.dropcowboy.comon the SIP port you choose. - Root access on the server.
- The account FreeSWITCH runs as. It is
freeswitchon most package installs andwww-dataon FusionPBX. Check withps -o user= -C freeswitch.
Text to speech
Install dc-tts
Run this as root, with the account FreeSWITCH runs as:
curl -fsSLO https://github.com/Drop-Cowboy/pbx-connect/releases/latest/download/dc-connect-linux-amd64
curl -fsSLO https://github.com/Drop-Cowboy/pbx-connect/releases/latest/download/SHA256SUMS
sha256sum --ignore-missing -c SHA256SUMS
chmod +x dc-connect-linux-amd64
sudo ./dc-connect-linux-amd64 tts install --bin-dir /usr/local/bin \
--cache-dir /var/lib/dc-tts/cache --user freeswitch --group freeswitch \
--default-voice VOICE_ID
On FusionPBX, pass --user www-data --group www-data. On an ARM server, use
dc-connect-linux-arm64.
VOICE_ID is a voice's voice_id, from the dashboard or
GET /voice/public/voices. See Pick a voice.
The installer asks for your connector key and its secret without showing
them, writes /etc/dc-tts/dc-tts.conf with mode 0640, and runs
dc-tts check. The config file
lists its settings, including [voices] for short voice names.
Point mod_tts_commandline at it
- Save this as
autoload_configs/tts_commandline.conf.xml, in/etc/freeswitchor/usr/local/freeswitch/conf, replacing the file that is there:
<configuration name="tts_commandline.conf" description="Drop Cowboy text to speech">
<settings>
<param name="command" value="/usr/local/bin/dc-tts speak --voice ${voice} --rate ${rate} --out ${file} --text ${text}"/>
</settings>
</configuration>
- Make sure
mod_tts_commandlineloads. FusionPBX loads it already. Otherwise add<load module="mod_tts_commandline"/>toautoload_configs/modules.conf.xmland runfs_cli -x "load mod_tts_commandline". - Run
fs_cli -x reloadxml.
FreeSWITCH quotes ${text}, ${voice} and ${file} for the shell itself,
so leave them bare. Don't add quotes. The key never appears on this command
line: dc-tts reads it from its config file.
Speak in the dialplan
<action application="speak" data="tts_commandline|VOICE_ID|Thanks for calling."/>
The voice is a voice_id or a name from [voices]. Leave it empty, as in
tts_commandline||Hello, to use default_voice. Calls with a 16 kHz codec
get 16 kHz audio.
- The first call with a text fetches the audio, and later calls play it from the cache. You're billed per character fetched, and each fetch counts toward the key's daily spend cap.
speaksets no result variable. When the audio can't be made in time, nothing plays and the dialplan goes on to the next action. The reason is in/var/log/dc-tts/dc-tts.log, which never contains the text.- Never pass text from callers or other untrusted sources to
speak. Only speak text you wrote.
Record FusionPBX greetings from text
The Speech app records greetings and other files from text. Its local
engine can use dc-tts, which then runs as a small service on the server.
- Install
dc-ttswith--user www-data --group www-data, as above. - In
/etc/dc-tts/dc-tts.conf, add:
listen = 127.0.0.1:8001
serve_token = SERVE_TOKEN
Make SERVE_TOKEN random, with 16 or more letters, digits, - or _.
openssl rand -hex 24 makes one.
3. Get the service file from the repository and start it:
git clone --depth 1 https://github.com/Drop-Cowboy/pbx-connect
sudo install -m 0644 pbx-connect/freeswitch/conf/dc-tts.service /etc/systemd/system/dc-tts.service
sudo systemctl daemon-reload && sudo systemctl enable --now dc-tts
- In Advanced > Default Settings, category
speech, setenginetolocal. Setapi_urltohttp://followed by127.0.0.1:8001/SERVE_TOKEN/speech, with your token and no spaces. - The Speech app lists its own voice names for
local, such asaf_heart. Map the ones you use under[voices], as inaf_heart = VOICE_ID. Any other name usesdefault_voice.
The service listens on 127.0.0.1 only, and answers only requests that
start with the token. Anyone who can read the token, including FusionPBX
superadmins, can make speech on your account up to the key's daily spend
cap, so treat it like the key.
AI agents over SIP
A call you send to sip:<agent_id>@sip.dropcowboy.com is answered by that
AI agent. Your account must have SIP calls to AI agents turned on, and the
agent must be published. See Publish an agent.
The SIP gateway signs in with the connector key's SIP login: the username is the
key's key_id, and the password is its sip_secret, shown once when the key
gets the SIP scope. The key's allowed_cidrs apply to these calls.
Add the SIP gateway
On FreeSWITCH, save this as sip_profiles/external/dropcowboy-agents.xml:
<include>
<gateway name="dropcowboy-agents">
<param name="username" value="KEY_ID"/>
<param name="password" value="SIP_SECRET"/>
<param name="realm" value="sip.dropcowboy.com"/>
<param name="proxy" value="sip.dropcowboy.com:5080"/>
<param name="register" value="false"/>
</gateway>
</include>
Make the file readable only by root and the FreeSWITCH group, because it
holds the SIP secret. Then run fs_cli -x "sofia profile external rescan".
Port 5080 takes UDP and TCP. For TLS, use port 5081 and a TLS profile.
On FusionPBX, open Accounts > Gateways and click Add:
| Field | Value |
|---|---|
| Gateway | dropcowboy-agents |
| Username | The key's key_id |
| Password | The key's sip_secret |
| Proxy | sip.dropcowboy.com:5080 |
| Realm | sip.dropcowboy.com |
| Register | False |
| Profile | external |
Save. FusionPBX names the SIP gateway by its UUID. Find it with
fs_cli -x "sofia status gateway".
Send calls to an agent
Bridge the call to the SIP gateway, with the agent's agent_id as the number:
<extension name="dropcowboy-agent">
<condition field="destination_number" expression="^7001$">
<action application="bridge" data="{absolute_codec_string=PCMU,PCMA}sofia/gateway/dropcowboy-agents/4c8e2a6f-3b9d-4e1a-9c7b-5d2f8a3e6b19"/>
</condition>
</extension>
On FusionPBX, add it in Dialplan > Dialplan Manager, and put the SIP gateway's
UUID in place of dropcowboy-agents. Then send calls to 7001 from an IVR
option, a destination or a ring group's fail over.
Hand calls back
The agent sends a call back with a blind transfer. It reaches the user a
preset on the key names, in the call's own dialplan context, so name
extensions that exist there. Where the agent can transfer to is set on that
preset: refer_targets for transfers it chooses during the call, and
outcome_routes for where it sends the call when it finishes. See
Connector presets.
Call results also arrive on the ai_agent.* webhooks. See
Call results.
Send presets
A send preset fixes what is sent: a voicemail, a text, a voice broadcast or an AI voice broadcast, with its content, phone line and consent rule. A request to its send URL adds only who to send it to.
Create the preset
- In the dashboard, open Settings > PBX Connect and click New send preset.
- Choose what it sends, its content and its phone line.
- Under Connector key, choose a key with
connect:trigger. - For FusionPBX Send Now, leave Dispositions that trigger it empty and choose We attest every lead consented. Send Now has no disposition or lead field to pass.
- Copy the Dispo Call URL. It is shown once, and it carries the preset's send token, so keep it as secret as a key.
From FreeSWITCH itself, any program that can make an HTTPS request can call
the send URL, such as an event socket app after a call. SEND_URL is the
Dispo Call URL up to the ?. The fields are in
Call it after the call:
curl -fsS 'SEND_URL' \
--data-urlencode 'lead_id=12345' \
--data-urlencode 'uniqueid=b2f6d1e8-9a3c-4f7e-8d1b-6c5a4e3f2a19' \
--data-urlencode 'phone_number=+15125550142'
Send from FusionPBX
Install the app:
- Copy the app into FusionPBX, from the repository you cloned above:
sudo cp -r pbx-connect/freeswitch/fusionpbx/app/dropcowboy /var/www/fusionpbx/app/dropcowboy
- Create the config file:
sudo install -d -o root -g www-data -m 0750 /etc/dc-connect
sudo install -o root -g www-data -m 0640 /dev/null /etc/dc-connect/dc-connect.conf
- Edit it as root, with a
[preset-N]section for each preset:
webhook_secret = SIGNING_SECRET
[preset-1]
name = Follow up
send_url = DISPO_CALL_URL
N runs from 1 to 9999, and presets are listed in that order. name is
how the preset is listed on the page. send_url is the whole Dispo Call
URL; anything after the ? is ignored. webhook_secret is needed only
for inbound texts.
4. In FusionPBX, run Advanced > Upgrade with App Defaults,
Menu Defaults and Permission Defaults checked. Log out and in
again.
Then open Applications > Drop Cowboy Send Now:
- Choose the Preset.
- Paste up to 100 Phone numbers, one per line. Ten digits are taken as
US or Canada. Other countries need a leading
+. - Click Check list, check it, then click Send to N numbers.
Each number gets a result:
| Result | Meaning |
|---|---|
| Queued | Accepted. It then goes through the same checks as a send made with the API, including Do Not Call and calling hours. The outcome shows under Sends on the PBX Connect page. |
| Already sent | This batch already sent to the number. |
| Refused | The preset's consent rule wasn't met. The reason is Opt-in Missing. |
| Skipped | The preset only sends on certain dispositions. Clear them on the preset. |
| Failed | The request didn't reach Drop Cowboy, or came back with an error. |
| Not sent | The batch stopped before this number. |
A 401, 403, 404 or 429 stops the batch, and so do three failures in a
row. Send again retries the batch. Numbers already sent show as
Already sent, and aren't sent twice. New list starts a new batch.
Only the superadmin group gets the page. The presets belong to the whole
server, not to a domain, so don't give the dropcowboy_send permission to
domain admins on a shared system.
Inbound texts in FusionPBX
Texts to your Drop Cowboy numbers can reach extensions through FusionPBX's SMS app. Install the app above first.
- Each number must be on a Drop Cowboy line linked to a registered texting (10DLC) campaign.
- In Applications > SMS, add the number as a destination routed to an extension, as for any carrier.
- In Drop Cowboy, under Settings > Webhooks, add a webhook for the
contact.msg.receivedevent athttps://pbx.example.com/app/dropcowboy/sms_hook.php, with your PBX's address. - Put the webhook's signing secret in
webhook_secretin/etc/dc-connect/dc-connect.conf.
Each text is checked against the signing secret. One without a valid
signature, or more than five minutes old, gets a 401. See
Verify the signature. Attachments are
noted in the text. Open the conversation in Drop Cowboy to see them.
The SMS app drops a text to a number it has no destination for, after the
hook has accepted it. Its sms_hook_common.php also logs every text's
numbers and body to the PHP error log, from every carrier.
Texts from extensions out through Drop Cowboy aren't supported on FusionPBX.
Don't add dropcowboy under Default Settings > sms > carriers. Reply
from the conversation in Drop Cowboy instead.
Consent
Every preset has a consent rule, and a send that doesn't meet it is refused
with 6011. Send Now works only with We attest every lead consented:
your account attests that every number this preset sends to has consented.
A preset that sends a text must use a phone line linked to a registered
texting (10DLC) campaign.
A send that passes its consent rule then goes through the same checks as a send made with the API. See Consent.
Common problems
speakplays nothing. Check/var/log/dc-tts/dc-tts.log. A 401 means the key indc-tts.confis wrong, a 403 that the server's address isn't inallowed_cidrs, and a 402 that the balance or the daily spend cap ran out.dc-ttsrefuses the config file. Other users can read it, or the FreeSWITCH account isn't in its group. Install again with the right--userand--group.- The Speech app saves no recording. Check
systemctl status dc-tts, and thatapi_urlholds the same token asserve_token. - The agent call fails with 403. The SIP username or secret is wrong, the
key lacks the SIP scope, or the server's address isn't in
allowed_cidrs. - The agent call fails with 404. The
agent_idis wrong, or the agent isn't published. - The agent call fails with 486. The call went past
max_concurrentormax_cpson the key. Raise them, or clear them for no cap. - Send Now isn't in the menu. Run Advanced > Upgrade with the three defaults checked, then log out and in.
- Send Now says the config file is readable by other users. Run
chmod 0640 /etc/dc-connect/dc-connect.conf. If it says the file can't be read, set its group towww-data. - Send Now says there are no presets. Add a
[preset-1]section withnameandsend_url. - Every Send Now number is Refused or Skipped. The preset uses a lead field, or lists dispositions. Use We attest every lead consented and no dispositions.
- Texts don't reach extensions. Check the webhook URL and the signing secret, and that the number is a destination in the SMS app.
Ringless voicemail technology delivers messages directly to voicemail inboxes. Delivery success depends on carrier compatibility, device type, and recipient settings. While designed for voicemail delivery, technical factors may affect performance. Drop Cowboy does not guarantee delivery rates or specific outcomes.
While Drop Cowboy provides tools to support compliance efforts, customers remain solely responsible for obtaining proper consent, maintaining opt-out lists, and complying with all federal and state telemarketing regulations. Consult with your legal counsel to ensure your specific use case and consent mechanisms comply with applicable laws.
This information is for educational purposes only and does not constitute legal advice. Regulations vary by jurisdiction and use case. Always consult with qualified legal counsel to ensure your specific practices comply with applicable federal and state laws.