I’m a newbie to asterisk, and I spent some time reading documentation but I haven’t found anything suitable for what I need to do.
Basically, what I want to do is to pass control of the call to an external program, written in a real programming language (preferably python, but that’s not strictly necessary). This is because the call needs to be treated differently according to data that is not handled by Asterisk. The program would need to query a db and then, after a bit of manipulation, execute some asterisk applications before giving back management to the “standard” dialplan.
In other words, I need control flow in the dialplan, among with data manipulation and db query functions. Since asterisk doesn’t provide any (that I’m aware of), I came up with the idea above.
After spending some time searching the web, I realized that what I’m looking for is probably an interface to the asterisk manager API. I also found one: py-asterisk. The problem is that it’s very poorly documented, and I have no clue about how to use it.
Can somebody please point me out something that’s better documented, or give advice me on how to use py-asterisk, or maybe let me know if there are better solutions to my problem?
[quote=“dementrio”]I’m a newbie to asterisk, and I spent some time reading documentation but I haven’t found anything suitable for what I need to do.
Basically, what I want to do is to pass control of the call to an external program, written in a real programming language (preferably python, but that’s not strictly necessary). This is because the call needs to be treated differently according to data that is not handled by Asterisk. The program would need to query a db and then, after a bit of manipulation, execute some asterisk applications before giving back management to the “standard” dialplan.[/quote]
For this application you would be interested in the Asterisk AGI capability. Which works with almost any programming/scripting language, including Python:
Thank you very much for the tips. I spent the day trying to get pyst and then pyastre to work, and (much surprisingly) I succeeded, in both.
Now I have a question about performance: how do these thingies behave? The reason I bothered trying pyastre, after getting pyst already to work, is that I thought that spawning a python process for every call would suck up too much resources. pyastre, instead, works in a (to me) obscure manner: if I got it right, python is linked in asterisk, so that an embedded interpreter handles the scripts. Moreover, it doesn’t execute scripts one by one, but uses Twisted to manage them (which I believe makes use of threads to do it).
Having said this, will dumping pyst for pyastre help to spare resources and improve the system’s scalability? (pyastre is a bit more complex, so I would rather stick to pyst & pure AGI if performance differences are slight)