# /etc/asterisk/extensions.conf
[globals]
RAPIDA_API_KEY = rpd-xxx-your-api-key
RAPIDA_HOST = {PUBLIC_ASSISTANT_HOST} ; HTTP/webhook host (HTTPS)
RAPIDA_AS_HOST = {PUBLIC_ASSISTANT_HOST} ; AudioSocket TCP host
RAPIDA_PORT = 4573
ASSISTANT_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()