Asterisk in the beginning started as a PBX but over its life has evolved into that of a communications toolkit. In fact if you ever run into me and ask me what Asterisk is I will always start with “Asterisk is a telecommunications toolkit”. Saying this is one thing but what does this actually mean in practice?
It means that Asterisk is providing the foundational elements to create other things. The building blocks as it were. To that end I urge you whenever you are looking for functionality and don’t find it to break it down into the constituent parts because the precise feature you may want does not exist but the building blocks are present to put it together and create it. A great example is one that I’ve seen come up a few times: injecting a sound file into a channel while it is doing other things.
Let’s break this down into what is actually needed:
- The ability to inject audio into a channel no matter what it is doing
- The ability to play back an audio file
- The ability to connect these two things together
- The ability to trigger this to happen
If you look at these individually then Asterisk has the required building blocks but not the feature:
- ChanSpy with whisper functionality
- Playback application
- Local channels
- Channel origination
This means that we can use the Originate functionality in Asterisk to dial a Local channel that calls Chanspy with whisper. Once answered we can connect it to Playback and have an audio file played.
This is a great example of using the building blocks to create new functionality that isn’t built in.
So if you ever find yourself not able to do something, then try this approach and see if you can create it!