Hello everyone,
For a long time, I’ve been trying to bypass silence during a BackgroundDetect in the dialplan. I’ve now managed to achieve this by using ChanSpy with the Whisper option to play a playback on the channel!
Here, I briefly describe in a visual guide how I implemented this!
I’m open to any suggestions for improvement!
hangup-application-noise.sh:
#!/bin/bash
SEARCH_PATTERN="application-noise"
LOCAL_PATTERN="Local"
CHANNELS=$(asterisk -rx "core show channels")
while IFS= read -r line; do
if echo "$line" | grep -q "$SEARCH_PATTERN" && echo "$line" | grep -q "$LOCAL_PATTERN"; then
FULL_CHANNEL_ID=$(echo "$line" | awk '{print $1}')
CHANNEL_ID=$(echo "$FULL_CHANNEL_ID" | sed 's/;[0-9]*$//')
asterisk -rx "channel request hangup $FULL_CHANNEL_ID"
if [ $? -eq 0 ]; then
echo "Success for channel: $FULL_CHANNEL_ID"
else
echo "Failed for channel: $FULL_CHANNEL_ID"
fi
fi
done <<< "$CHANNELS"
Make sure run:
chmod +x /path/to/hangup-application-noise.sh