Sunday, March 8, 2020

Asterisk Dialplan SET command examples

Here are some examples of the SET command


SET VAR1 (TRUE:FALSE) based on VAR2 condition (if BUSY)
Set(VAR1=${IF($["${VAR2}"="BUSY"]?TRUE:FALSE)})This will set VAR1 to TRUE or FALSE depending on VAR2 condition being met (BUSY)

SET based on OR results ( | ) pipe symbol
exten => s,n,Set(RESULT=${IF($["${VAR1}"="1" | "${VAR2}"="1" | "${VAR3}"="1"]?${VAR4}:))This will set RESULT = VAR4 if Var1 or Var2 or Var3 match
SET with a MATH command for a loop counter
exten => s,n,Set(Attempts=1) exten => s,n,Set(Attempts=${MATH(${Attempts}+1,i)})exten => s,n,ExecIf($["${Attempts}"="4"]?HANGUP())This is a loop counter that uses the SET command with a MATCH command to count the attempts a code is executed.



No comments:

Post a Comment