Tutorial - Jitsi / Jigasi & FreePBX integration. Along with Asterisk IVR to use Jitsi conference mapper API

Created on 2021-01-28T21:53:41-06:00

Return to the Index

This card pertains to a resource available on the internet.

This card can also be read via Gemini.

[Jitsi-Conference-Entry]
exten => s,1,Answer()
;Set the extension used for Jitsi
exten => s,2,Set(Jitsi=888)
;set variable to prevent looping
exten => s,3,Set(Attempts=0)
exten => s,4,Set(Attempts=${MATH(${Attempts}+1,i)})
;Test for invalid entries. On 4th attempt go to error sub
exten => s,5,ExecIf($["${Attempts}" = "4"]?Gosub(Attempts-Error,s,1))
exten => s,6(begin),NooP()
;system listens for DTMF and sets variable "confid"
;10=MAX DIGITS, 10=timeout
exten => s,n,Read(confid,conf-getpin,10,,,10)
;If blank value, start over
exten => s,n,ExecIf($["${confid}"=""]?goto(Jitsi-Conference-Entry,s,4))
;systems plays back the number entered
exten => s,n,Playback(you-entered)
exten => s,n,SayDigits(${confid})
;system asks to press 1 to accept or 2 to retry
exten => s,n,Read(digi,if-this-is-correct-press&digits/1&otherwise-press&digits/2,1,,1,10)
;If blank value, start over
exten => s,n,ExecIf($["${digi}"=""]?goto(Jitsi-Conference-Entry,s,4))
;if user presses 1 to confirm, system moves onto to check for passcode, if applicable
exten => s,n,ExecIf($["${digi}"="1"]?goto(passcode))
;if callers presses any other digit, system will re-ask them to enter in their number
exten => s,n,goto(Jitsi-Conference-Entry,s,begin)
;CURL Jitsi API with meeting pin & retrieve meeting name as the result 
exten => s,n(passcode),Set(CURL_RESULT=${SHELL(curl --silent https://jitsi-api.jitsi.net/conferenceMapper?id=${confid} | sed -e 's/.*"conference":"\(.*\)@.*/\1/')})
exten => s,n,Verbose(0, ${CURL_RESULT});
;speeding this up for the password, but you could mirror the process above if you want the extra readout and verification...
;system listens for DTMF and sets variable "confpin"
;6=MAX DIGITS, 10=timeout
exten => s,n,Read(confpin,pls-enter-conf-password&vm-then-pound&vm-tocancel,6,,,10)
;pls-enter-conf-password
;User will be sent onto the conference whether confpin is blank or not
exten => s,n,goto(enterconf)
;Add SIP Headers based on caller's entries & CURL result
exten => s,n(enterconf),SIPAddHeader(Jitsi-Conference-Room:${CURL_RESULT})
exten => s,n,SIPAddHeader(Jitsi-Conference-Room-Pass:${confpin})
;Sets CDR "userfield" with the Conference ID
;CDR can now be used to track number of calls and durations associated to the Conference ID
exten => s,n,Set(CDR(userfield)=Jitsi:${CURL_RESULT})
;Record Caller's Name
exten => s,n,Set(__rnum=${RAND()})
exten => s,n,Playback(vm-rec-name)
exten => s,n,Record(/tmp/name-${rnum}.gsm,3,10)
;set spygroup to be used for injecting whisper
exten => s,n,Set(SPYGROUP=1000)
;Dial Jitsi extension and play recorded name to the jitisi conference channel
;3 = seconds to ring , m = play music on hold , A = announcement for dialed channel, M = Macro after call connects
exten => s,n,Dial(SIP/${Jitsi},3,m(silence)A(/tmp/name-${rnum})M(Jitsi-join))
exten => s,n,Verbose(0, Contacting ${Jitsi}... Status is ${DIALSTATUS} );
;Take actions based on dialstatus 
exten => s,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?unknown)
exten => s,n,GotoIf($["${DIALSTATUS}" = "NOANSWER"]?conf-busy)
exten => s,n,GotoIf($["${DIALSTATUS}" = "CANCEL"]?unknown)
exten => s,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?unknown)
exten => s,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?unknown)
exten => s,n,GotoIf($["${DIALSTATUS}" = "DONTCALL"]?unknown)
exten => s,n,GotoIf($["${DIALSTATUS}" = "TORTURE"]?unknown)
exten => s,n,GotoIf($["${DIALSTATUS}" = "INVALIDARGS"]?unknown)
;Hangup if condition is not matched (in the event a new dialstatus is added with an update
exten => s,n,Hangup()
;Jitsi is not reachable, play error message
;This is also a good place to send an SMS to your lead system admins
exten => s,n(unknown),playback(please-contact-tech-supt&vm-goodbye)
exten => s,n,Hangup()
;Initial attempt was ok, but Jitsi didn't pickup the call. 
;It's likely that the host hasn't yet authenticated / started the meeting
;Indicate that we're waiting for the leader to join and keep trying
exten => s,n(conf-busy),Playback(conf-waitforleader)
;120 = seconds to ring , m = play music on hold , A = announcement for dialed channel, M = Macro after call connects
exten => s,n,Dial(SIP/${Jitsi},120,m(default)A(/tmp/name-${rnum})M(Jitsi-join))
exten => s,n,Hangup()

[Attempts-Error]
;system plays message and hangs up
exten => s,1,playback(sorry-youre-having-problems)
exten => s,n,playback(tt-monkeys)
;exten => s,n,playback(hangup-try-again)
exten => s,n,Hangup()

[macro-Jitsi-join]
exten => s,1,Originate(Local/999@JitsiWhisper,app,Playback,confbridge-join)

[JitsiWhisper]
exten => _X.,1,NoCDR
exten => _X.,n,Answer()
exten => _X.,n,ChanSpy(,g(1000),qw)
exten => _X.,n,Hangup()