Call python script from asterisk dialplan

Hi Guys,

Please help me with the syntax to call python script from dialplan directly, If I type below command on terminal it creates successful .wav file but I have to call this directly from dialplan.

python polly.py cbnomsg Ops I missed that can you please say it again

Regards,
swapnil

Use system() command and specify the full path and make sure the right permissions are set

Thanks will check this surely and I need one more help. Can we built a system where an incoming call from an IVR can we forward to other PRI not to other server.

means If I receive incoming calls on DID 12387001 and play ivr options 1,2,3,4 so if anybody select option 4 then that call would be forward on other DID 12356601??? I did this as I dialed 12356601 but caller id was getting changed and it was showing 12387001 instead of caller

Open a new thread for this question, and use CALLERID() function to pass the desired caller id assuming your carriers allows you to do it.

I think it most likely that your provider’s policy doesn’t allow you to override the caller ID. This is a good thing a it stops spammers and phishers from pretending to be someone else.

yes they allow but we can only show any DID amongs 30 DIDs those are actually the part of pilot pri.

There are two (2) approaches you can take.

  • Executing a python script using System() to perform a task related to the call.
  • Use a Python library, such as pyst2 to interact with the call.

The later, allows you to pass Asterisk variables to and from the python script.

The second option is really a special case of interacting directly over a socket. You can always implement the AGI protocol directly.