Making IVR bot with the help of Python, where should I start off?

Hello, so I’ve been meaning to use Asterisk and SIP trunking as my main utillity for IVR. Now our backend API is running on Python Flask server (previously using Plivo as VoIP), but moving over to SIP trunking and Asterisk due to lower pricing, in short.

I want to make IVR using Python, but don’t know where to start or which library to use as I found no documentation that would contain what I need (DTMF, Call Recording, AMD, Transfer to our agent and a way to differentiate between multiple calls if there are multiple at one).

If somebody would point me into the right direction I would greatly appreciate it. Saw some Asterisk AMI Python library, but couldn’t get my head around as what should I do with it.

Thanks in advance

You don’t need to touch Asterisk’s AMI for IVR deployment unless you want to use AMI-specific actions like Originate and some other particular cases. One thing to keep in mind when creating an IVR is that there are Asterisk dial plan functions that won’t be available using AGI. And if you stick to a library, if problems arise, you will need to contact the library creator.

I’d suggest dialplan is the best language for IVRs.

1 Like

Well, I need to be able to place outbound call, therefore Originate is a must right? I need it to be active for API requests sent from my agents(place a requested call) or clients themselves (request a call). Now I’m trying to put all of this into an app, which has backend API written in Python and is used by our agents and supervisors (listing all concurrent calls, DTMF from them, who is talking to them etc., basically functions I described in my first post). If there’s any other alternative to it, as mentioned DialPlan, I’d love to hear it.

Originate from AMI, then dialplan for the rest of it.

I totally agree, and one of the reasons for this is the intrinsic functions of Asterisk for handling the channels. When it comes to doing this with a library, it is like rewriting something that works like a wheel, but not being a wheel.

Connecting an inbound call leg to an outbound call leg, based on actions/selections in an IVR, is exactly what Asterisk is designed to do.

Originate is only required when a call needs to be initiated without any existing call leg. You probably won’t need that unless you are doing some sort of advanced thing like scheduled callback.

Also, if you really want to write it in python rather than using the dialplan, I would suggest you look at AGI: it was designed specifically for using arbitrary programming languages to drive the dialplan flow. The AGI interface is pretty simple and is very stable.

  • Darrin

The division between AMI and AGI seems a bit arbitrary, Luckily, you can mix the two with AsyncAGI mode.

It’s pretty clear. AGI is initiated by the current call. AMI is initiated by some external controlling process.

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