assistant-api binds a TCP AudioSocket server on AUDIOSOCKET__PORT at startup.
2
Verify the module is loaded
asterisk -rx "module show like audiosocket"# Expected: res_audiosocket.so
If not loaded, add to /etc/asterisk/modules.conf:
[modules]load = res_audiosocket.so
3
Configure the dialplan
# /etc/asterisk/extensions.conf[globals]RAPIDA_API_KEY = rpd-xxx-your-api-keyRAPIDA_HOST = {PUBLIC_ASSISTANT_HOST} ; HTTP/webhook host (HTTPS)RAPIDA_AS_HOST = {PUBLIC_ASSISTANT_HOST} ; AudioSocket TCP hostRAPIDA_PORT = 4573ASSISTANT_ID = 123456789[rapida-inbound]exten => _X.,1,Answer() same => n,Set(CHANNEL(audioreadformat)=slin) same => n,Set(CHANNEL(audiowriteformat)=slin) ; Phase 1 — register the call and get a contextId same => n,Set(CTX=${CURL(https://${RAPIDA_HOST}/v1/talk/asterisk/call/${ASSISTANT_ID}?from=${CALLERID(num)}&x-api-key=${RAPIDA_API_KEY})}) same => n,GotoIf($["${CTX}" = ""]?error) ; Phase 2 — open AudioSocket TCP using contextId as UUID same => n,AudioSocket(${CTX},${RAPIDA_AS_HOST}:${RAPIDA_PORT}) same => n,Hangup() same => n(error),Playback(an-error-has-occurred) same => n,Hangup()
CHANNEL(audioreadformat)=slin and CHANNEL(audiowriteformat)=slin are required. AudioSocket expects SLIN (signed linear PCM) — without this Asterisk will not convert the audio format.
For outbound calls, Rapida uses Asterisk’s ARI to originate the channel. The RAPIDA_CONTEXT_ID channel variable is injected by Rapida ARI automatically:
; /etc/asterisk/extensions.conf[rapida-outbound]exten => s,1,Set(CHANNEL(audioreadformat)=slin) same => n,Set(CHANNEL(audiowriteformat)=slin) ; RAPIDA_CONTEXT_ID is set by Rapida ARI when originating the call same => n,AudioSocket(${RAPIDA_CONTEXT_ID},${RAPIDA_AS_HOST}:${RAPIDA_PORT}) same => n,Hangup()
ARI vault credential keys (store in Rapida vault, provider type Asterisk):
# docker/assistant-api/.assistant.envPUBLIC_ASSISTANT_HOST=your-hostname.com# No AudioSocket port needed — WebSocket uses standard HTTPS
2
Verify the module is loaded
asterisk -rx "module show like chan_websocket"# Expected: chan_websocket.so — requires Asterisk 20+
If not loaded, add to /etc/asterisk/modules.conf:
[modules]load = chan_websocket.so
3
Configure the dialplan
# /etc/asterisk/extensions.conf[globals]RAPIDA_API_KEY = rpd-xxx-your-api-keyRAPIDA_HOST = {PUBLIC_ASSISTANT_HOST}ASSISTANT_ID = 123456789[rapida-inbound-ws]exten => _X.,1,Answer() ; Phase 1 — register the call and get a contextId same => n,Set(CTX=${CURL(https://${RAPIDA_HOST}/v1/talk/asterisk/call/${ASSISTANT_ID}?from=${CALLERID(num)}&x-api-key=${RAPIDA_API_KEY})}) same => n,GotoIf($["${CTX}" = ""]?error) ; Phase 2 — open WSS connection with contextId in the URL path same => n,WebSocket(wss://${RAPIDA_HOST}/v1/talk/asterisk/ctx/${CTX}?x-api-key=${RAPIDA_API_KEY}) same => n,Hangup() same => n(error),Playback(an-error-has-occurred) same => n,Hangup()
; /etc/asterisk/extensions.conf[rapida-outbound-ws]exten => s,1,NoOp(Outbound WebSocket call) ; RAPIDA_CONTEXT_ID is set by Rapida ARI same => n,WebSocket(wss://${RAPIDA_HOST}/v1/talk/asterisk/ctx/${RAPIDA_CONTEXT_ID}?x-api-key=${RAPIDA_API_KEY}) same => n,Hangup()
Same ARI vault credentials apply — see the AudioSocket section.