Asterisk to Discord Voice Gateway – Feasible or Fantasy?

I’d like to preface this with an apology, my entire topic is fairly silly and the entirety of this site and asterisk in general is a really professional and powerful community. I am sincerely sorry to bother you with help for this, however all of my resources point toward asterisk being the solution and I cannot figure it out along.

I want to interact with a discord server using a voip phone, and eventually old school phones from the thrift store with a voip adapter. I have the basic node.js bot logic down, it joins a specific discord channel and sends audio from a local mic, while playing any audio in the channel over a local speaker. Asterisk is installed on the same machine, and I’ve configured a pjsip server that my cheap voip phone can connect too. I’ve got a rough dialplan set so when a specific extension is dialed a stasis app is launched. My current thinking is that I can send/rec audio through rtp in some fashion, and this may be misguided.

This is my first question. For my sanity, is this possible with asterisk, and am I approaching it with the right method?

My second question is more complex and irrelevant if this isn’t the right idea. In the stasis app, I’ve been trying to create an audio bridge, move the channel in there and hopefully find a way to get the audio out (I haven’t got that far). I’ve tried this with the node-asterisk-ami and cobbling url’s together in python(i know more python than node.js) and ive reached the same issue in both: joining the channel and bridge gives me 404: resource not found.

Thank you sincerely for reading this, I can follow up with more detailed logs if this method is actually viable. If it’s not viable, I would sincerely appriciate being pointed in the right direction.

For me personally, what attracts me to a discussion topic is how interesting it is, not how “professional” or “important” or “serious” it is.

I, too, use Python a lot. And while I claim some familiarity with JavaScript, I am not so au fait with JavaScript in the form of NodeJS.

Feeling that all the existing Python bindings for the Asterisk APIs were too limited or too mired in the past in terms of Python capabilities used, I created my own in the form of Seaskirt. This covers all the public APIs, and supports both synchronous and asynchronous (event-loop-based) programming styles.

I haven’t done any proper documentation, apart from the README (sorry), but I did throw together some examples here. In there you will see an example of how to use ARI to originate two channels for the two ends of a call and join them via a bridge (track_call_ari_bridged_async). Maybe that will be of some help.

You will note that that example waits for events from Asterisk to notify that the channels have reached a suitable state before trying to join them to the bridge.

I did some very basic testing with mod_portaudio in FreeSWITCH years ago, but I’m not sure about how it would work in Asterisk.

A different approach could be to use chan_console: asterisk/configs/samples/console.conf.sample at 22.2.0 · asterisk/asterisk · GitHub

The idea would be to redirect the asterisk audio to whatever mic the discord bot is using.

While I have nothing concrete to add, I can safely say messing with the node.js ari library did end up working. This had more to do with my inexperience with node.js