Using Asterisk's manager interface to generate calls (From Python using pyst)


This is not a deep and profound project, it's a quick "hello world" example script that allows you to generate a call via Asterisk that connects a SIP URI to a particular extension in your call plan. You could use this as-is to create a phone survey or similar system that connects a user to an IVR phone survey.

[Note: I've now published a Twisted package that allows both AMI and FastAGI operation, you likely would want to use that instead of this recipe for new development]

Comments

  1. Pavel

    Pavel on 03/22/2006 3:02 p.m. #


    Dear mcfletch,<br />
    I tried this script and failed.<br />
    all the files was modified (manager.conf, extensions.conf) saved script as callback.agi, put it to the /var/lib/asterisk/agi-bin folder and called it this way:<br />
    AGI(callback.agi)<br />
    I made only modifications in the script:<br />
    targetURL changed with real sip account and changed the string 'SIP/%s'%(targetURL,), with 'SIP/sipnet/%s'%(targetURL,),<br />
    may be I did something wrong?<br />

  2. Kirill

    Kirill on 04/05/2006 12:38 p.m. #


    Pavel,<br />
    <br />
    you can try this, it works for me:<br />
    <br />
    #! /usr/bin/env python<br />
    from Asterisk import Manager<br />
    <br />
    Manager.DEBUG = 3<br />
    HOST = '127.0.0.1'<br />
    PORT = 5038<br />
    <br />
    addr = (HOST, PORT)<br />
    <br />
    m = Manager.Manager( addr, 'user', 'password')<br />
    targetURL = 'userid'<br />
    <br />
    m.Originate(<br />
    'SIP/sipnet/%s' % targetURL , <br />
    extension = 's', <br />
    context='outgoing',<br />
    priority='1'<br />
    )<br />
    <br />
    print m.Status()<br />
    <br />
    m.Logoff()

  3. fahad

    fahad on 04/02/2008 12:16 p.m. #


    i need to know as if call is made by asterisk manager api call is connected now i want to but that call into a queue as queue() in asterisk can u please help me in tht

  4. pulakkil

    pulakkil on 04/05/2012 4:31 a.m. #

    i tried this calls are originating but how can i pass channel variable when originate calls from python..just give me example .

    thanks in advance..

Comments are closed.

Pingbacks

Pingbacks are closed.