Help with extension config syntax

Hi all!

New FreePBX user here learning about how all this works.

I am working on setting up my own Lenny robot extension. One thing I really want it to do is wait about 5 seconds before playing the first audio file, and then using backgrounddetect for the rest of it. I am having a heck of a time figuring out how to do this. I can either get it to:

  1. Completely ignore my Wait
  2. Use the Wait before playing every audio file, or
  3. Just break all together.

Can I get some help on how to do this? Here’s what I have so far that does not work. Thank you in advance!

[Lenny]
exten => waitasec,1,Wait(5)
exten => talk,2,Set(i=${IF($[“0${i}”=“016”]?7:$[0${i}+1])})
same => n,ExecIf($[${i}=1]?MixMonitor(${UNIQUEID}.wav))
same => n,Playback(Lenny/Lenny${i})
same => n,BackgroundDetect(Lenny/backgroundnoise,1500)

Playback silence5 (I think that’s what it’s called) instead of trying to wait.

Thanks! I found the sound files and tried it, I think I still have some bad syntax somewhere as I get the default “The person you are trying to reach is unavailable” message.

Here’s what I have now:

[Lenny]
exten => waitamin,1,Playback(silence/5)
exten => talk,2,Set(i=${IF($[“0${i}”=“016”]?7:$[0${i}+1])})
same => n,Playback(Lenny/Lenny${i})
same => n,BackgroundDetect(Lenny/backgroundnoise,1500)

With the ‘exten’ structure, you include an extension name, and a ‘priority’. The priorities are incremental and start at ‘1’, so they need to go from ‘1’ to ‘2’ (or ‘n’) to ‘3’ (or ‘n’), etc. If you want to give a priority a name, you can, but they numbering is the normal process.

I’m going to guess there’s a problem with your step names. Normally, when you use a context like this, you will use an ‘s’ as the extension instead if “waitamin” or “talk”. Also, unless you’ve got it somewhere else, there’s no priority ‘1’ for ‘talk’.

[Lenny]
 exten => s,1,Playback(silence/5)
 same => n,Set(i=${IF($[“0${i}”=“016”]?7:$[0${i}+1])})
 same => n,Playback(Lenny/Lenny${i})
 same => n,BackgroundDetect(Lenny/backgroundnoise,1500)

Try it with ‘s’ as the extension (use the ‘same’ syntax for the rest of the lines). Troubleshoot from there.

Thank you! I thought the step names could be just randomly chosen. My fault.

It’s my understanding that the “BackgroundDetect” command looks specifically for the “talk” step name. The majority of my syntax came from a blog post. I’d post the link but apparently new users aren’t allowed to do that. If you’re interested, the google search that will get you to it is “Introducing Lenny”.

I’ve tried your script verbatim and it unfortunately still breaks and gives me the default “can’t be reached” message.

I have also tried creating two sections, one named Lenny and another named Kenny, and having my Lenny section answer, wait 5000 milliseconds then use the Goto command to go to Kenny,talk,1 and unfortunately that also breaks.

[Lenny]
exten => s,1,Answer(5000)
same => n,Goto(Kenny,talk,1)
[Kenny]
exten => talk,1,Set(i=${IF($[“0${i}”=“016”]?7:$[0${i}+1])})
same => n,Playback(Lenny/Lenny${i})
same => n,BackgroundDetect(Lenny/backgroundnoise,1500)

I am clearly having a hard time figuring out how the syntax works. Is there a log somewhere that will show useful error messages so I can get a clue as to what I am doing wrong with each iteration? I found /var/log/asterisk/full.log, but the message don’t seem very useful in troubleshooting this.

Thank you!

Thanks again for y’alls help!

To close the loop on this, this ended up working well. Applied this, then went into my inbound destinations and changed it to “Lenny,s,1”.

[Lenny]
exten => s,1,NoOP()
same => n,Wait(5)
same => n,Answer()
same => n,Goto(talk,1)
exten => talk,1,Set(i=${IF($[“0${i}”=“016”]?7:$[0${i}+1])})
same => n,Playback(Lenny/Lenny${i})
same => n,BackgroundDetect(Lenny/backgroundnoise,1500)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.