AMI etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
AMI etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

10 Temmuz 2012 Salı

AMI Queue (Kuyruk İşlemleri)


Ami ile kuyruk işlemleri asterisk ile otomatik arayıcı veya ivr uygulamaları geliştirdiğimizde oldukça işimize yarayacak işlevler üstlenirler. Bir çağrı merkezinde genelde operatörlerin belirli gruplara üye olup günün belirli saatlerinde sisteme giriş, çıkış, mola gibi işlemleri yapması istenir. İşte bu anlarda biz daha önceki yazılarımızda bahsettiğimiz çağrı bağlama işlemlerini operatörlere değil kuyruklara yaparız. Böylece Asteriskin ACD (Automatic Call Distrubutor) akıllı çağrı dağıtım nimetlerinden faydalanabiliriz.

Kuyruğa Operatör Eklemek


public void AgentAddQueue(String Exten)
        {
            try
            {
                Asterisk.NET.Manager.Action.QueueAddAction action = new QueueAddAction();
                action.ActionId = "14";
                action.Queue = mQueue;
                action.Interface = "SIP/" + Exten;
                action.MemberName = Exten;
                action.Penalty = 0;
                action.Paused = true;

                Asterisk.NET.Manager.Response.ManagerResponse mr =
                    manager.SendAction(action);
            }
            catch
            {
                //err
            }
        }


Kuyruktan Operatörü Çıkarmak


public void AgentRemoveQueue(String Exten)
        {
            try
            {
                Asterisk.NET.Manager.Action.QueueRemoveAction action = new QueueRemoveAction();
                action.ActionId = "13";
                action.Queue = mQueue;
                action.Interface = "SIP/" + Exten;

                Asterisk.NET.Manager.Response.ManagerResponse mr =
                    manager.SendAction(action);
            }
            catch
            {
               //err
            }
        }


Operatörü Kuyrukta Bekletme


public bool AgentLock(String Queue, string Exten, bool Lock)
        {
            try
            {
                Asterisk.NET.Manager.Action.QueuePauseAction action = new QueuePauseAction();
                action.ActionId = "11";
                action.Queue = Queue;
                action.Interface = "SIP/" + Exten;
                action.Paused = Lock;

                Asterisk.NET.Manager.Response.ManagerResponse mr =
                   manager.SendAction(action);
                if (mr != null)
                    return true;
                else
                    return false;
            }
            catch
            {
                return false;
            }
        }



Operatörün Kuyruktaki Durumu



protected void AgentQueueStatus(string Exten)
        {
            try
            {
                Asterisk.NET.Manager.Action.QueueStatusAction action = new QueueStatusAction();
                action.ActionId = "12";
                action.Member = Exten;
                action.Queue = mQueue;

                Asterisk.NET.Manager.Response.ManagerResponse mr =
                    manager.SendAction(action);
            }
            finally
            {
            }
        }
gibi.....





24 Haziran 2012 Pazar

Ami Diğer Olaylar



Ami Diğer  Bazı Olayların Kullanılması

manager = new ManagerConnection(Properties.Settings.Default.astserver, 5038, 
                    Properties.Settings.Default.astuser,Properties.Settings.Default.astpass);

                manager.OriginateResponse += new OriginateResponseEventHandler(manager_OriginateResponse);
                manager.Dial += new DialEventHandler(manager_Dial);
                manager.NewState += new NewStateEventHandler(manager_NewState);
                manager.Hangup += new HangupEventHandler(manager_Hangup);
                manager.NewCallerId += new NewCallerIdEventHandler(manager_NewCallerId);
                manager.Login();




Yeni Çağrı Başlama Olayı


void manager_NewCallerId(object sender, Asterisk.NET.Manager.Event.NewCallerIdEvent e)
        {
            try
            {
              if (e.CallerIdNum != null)
                  if ((e.CallerIdNum == txtPhone.Text) || (e.CallerIdNum == txtCountry.Text))
                  {
                      updateTelBagText("Aranıyor....", Color.Lime);
                      updateAgentCommentText("",Color.Red);
                      lblHangup.Text = "";
                  }
                       
            }
            catch
            {
                
                throw;
            }
        }


Çağrı Sonlanması

void manager_Hangup(object sender, Asterisk.NET.Manager.Event.HangupEvent e)
        {
            try
            {
                if (e.CallerIdNum != null)
                    if ((e.CallerIdNum == txtPhone.Text)||(e.CallerIdNum == txtCountry.Text))
                    {
                        updateTelBagText(" Görüşme Bitti.", Color.Red);

            
                        if (e.Cause == 16)
                        {
                            lblHangup.Text = "Normal Kapanma...";
                            lblHangup.BackColor = Color.LightBlue;
                        }
                        else if (e.Cause == 17)
                        {
                            lblHangup.Text = "Meşgul Verdi...";
                            lblHangup.BackColor = Color.Magenta;
                        }
                        else if (e.Cause == 19)
                        {
                            lblHangup.Text = "Cevap Yok...";
                            lblHangup.BackColor = Color.Fuchsia;
                        }
                        else if (e.Cause == 1)
                        {
                            lblHangup.Text = "Numara Yok...";
                            lblHangup.BackColor = Color.Fuchsia;

                        }
                        
                        updateAgentCommentText("Çağrı Sonlandı...",
                        Color.LightGreen);
                    }
            }
            catch
            {
                
            
            }
        }


Çağrı Durumu Olayı

void manager_NewState(object sender, Asterisk.NET.Manager.Event.NewStateEvent e)
        {
            bool callidok = false;
            bool agentidok = false;

            try
            {
                if (e.CallerId != null)
                    if (e.CallerId == cCallerID)
                        callidok = true;
                    else if (e.CallerId == Extension)
                        agentidok = true;


                if ((!callidok) && (e.CallerIdNum == cCallerID))
                    callidok = true;
                else if ((!agentidok) && (e.CallerIdNum == Extension))
                    agentidok = true;

                if (agentidok)
                {
                    if (e.ChannelState == "5")
                    {
                        updateAgentCommentText("Çağrıyı Kabul Edin...",
                        Color.Red);
                    }
                    else if (e.ChannelState == "6")
                    {
                        updateTelBagText("Açtınız...", Color.Lime); ;
                    }
                    else if (e.ChannelState == "7")
                    {
                        updateTelBagText("Meşgul verdiniz..",Color.Red);
                    }
                }

                if (callidok)
                {
                    if (e.ChannelState == "5")
                    {
                        updateTelBagText(cCallerID + " Çalıyor...",
                        Color.Yellow);
                    }
                    else if (e.ChannelState == "6")
                    {
                        updateAgentCommentText("Çağrı Bağlandı...",
                        Color.LimeGreen);
                        updateTelBagText(cCallerID + " Açıldı...",
                        Color.LimeGreen);
                    }
                    else if (e.ChannelState == "7")
                    {
                        updateAgentCommentText("",Color.Red);
                        updateTelBagText(cCallerID + " Meşgul...",
                        Color.Pink);
                    }
                }


            }
            catch
            {
               
            }  
        }

Bağlatı Durumu Olayı


void manager_OriginateResponse(object sender, Asterisk.NET.Manager.Event.OriginateResponseEvent e)
        {
            bool orgCall = false;
            string orgExten = "";

            try
            {
                if (e.Channel != null)
                {
                    string tmpch = e.Channel.Substring(e.Channel.IndexOf("SIP/") + 4, 3);
                    if (tmpch == Extension)
                    {
                        if (e.Response == "Failure")
                        {
                            updateTelBagText( orgExten + "Hata Bağlantı Yapılamadı...",Color.Red);       
                            cCallerID = "";
                        }
                        else if (e.Response == "Success")
                        {
                            if (e.Exten != null)
                            {
                                orgExten = e.Exten;
                                cCallerID = orgExten;
                            }
                            updateTelBagText(orgExten + " bağlanıyor...", Color.Orange);
                            updateAgentCommentText("Kabul Ettiniz...",
                            Color.Lime);
                        }

                    }
                }
            }
            catch
            {
                updateTelBagText("Originate Eroor...",Color.Red);
            }

        }


8 Mayıs 2012 Salı

Asterisk AMI & AGI



Nihayetinde Asterisk ile entegre çalışan bir çözüm üzerine gittiğinizde Asteriskin size sunduğu AMI (Asterisk Manager Interface) ve AGI (Asterisk Gateway Interface) arayüzleri size oldukça fayda sağlayacaktır. Bu servisler TCP/IP üzerinden 5038 portu üzerinden çalışan protokol ile sağlanmakta. manager.conf dosyasından kullanıcı adı - şifre ve yetki ayarı yapıldıktan sonra ami ile bağlantı sağlayıp basit komutları deneyebilirsiniz.


http://www.voip-info.org/wiki/view/Asterisk+manager+API sitesinden alıntı

Komutlar

Output from the CLI command show manager commands:
(For Asterisk 1.4 and greater, use manager show commands)

  • AbsoluteTimeout: Set Absolute Timeout (privilege: call,all)
  • ChangeMonitor: Change monitoring filename of a channel (privilege: call,all)
  • Command: Execute Command (privilege: command,all)
  • Events: Control Event Flow
  • ExtensionState: Check Extension Status (privilege: call,all)
  • GetVar: Gets a Channel Variable (privilege: call,all)
  • Hangup: Hangup Channel __(privilege: call,all)
  • IAXpeers: List IAX Peers (privilege: system,all)
  • ListCommands: List available manager commands
  • Logoff: Logoff Manager
  • MailboxCount: Check Mailbox Message Count (privilege: call,all)
  • MailboxStatus: Check Mailbox (privilege: call,all)
  • Monitor: Monitor a channel (privilege: call,all)
  • Originate: Originate Call (privilege: call,all) NOTE: starting from 1.6: originate,all
  • ParkedCalls: List parked calls
  • Ping: Ping
  • QueueAdd: Queues (privilege: agent,all)
  • QueueRemove: Queues (privilege: agent,all)
  • Queues: Queues
  • QueueStatus: Queue Status
  • Redirect: Redirect (privilege: call,all)
  • SetCDRUserField: Set the CDR UserField (privilege: call,all)
  • SetVar: Set Channel Variable (privilege: call,all)
  • SIPpeers: List SIP Peers (chan_sip2 only. Not available in chan_sip as of 9/20/2004) (privilege: system,all)
  • Status: Status (privilege: call,all)
  • StopMonitor: Stop monitoring a channel (privilege: call,all)
  • ZapDialOffhook: Dial over Zap channel while offhook
  • ZapDNDoff: Toggle Zap channel Do Not Disturb status OFF
  • ZapDNDon: Toggle Zap channel Do Not Disturb status ON
  • ZapHangup: Hangup Zap Channel
  • ZapTransfer: Transfer Zap Channel
  • ZapShowChannels: Show Zap Channels

(New?) in Asterisk 1.2.1 (was "CVS HEAD") (Taken from the output of CLI command show manager commands):
  • AgentCallbackLogin: Sets an agent as logged in by callback (Privilege: agent,all)
  • AgentLogoff: Sets an agent as no longer logged in (Privilege: agent,all)
  • Agents: Lists agents and their status (Privilege: agent,all)
  • DBGet: Get DB Entry (Privilege: system,all)
  • DBPut: Put DB Entry (Privilege: system,all)
  • QueuePause: Makes a queue member temporarily unavailable (Privilege: agent,all)
  • SIPshowPeer: Show SIP peer (text format) (Privilege: system,all)

New in Asterisk 1.4.0
  • GetConfig: Display a configuration file, used mainly by AJAM/Asterisk-gui. (Privilege: config,all)
  • PlayDTMF: Play DTMF signal on a specific channel. (Privilege: call,all)
  • UpdateConfig: Updates a configuration file, used mainly by AJAM/Asterisk-gui. (Privilege: config,all)


Available in Asterisk 1.6.0
  • AbsoluteTimeout: Set Absolute Timeout (Priv: system,call,all)
  • AgentLogoff: Sets an agent as no longer logged in (Priv: agent,all)
  • Agents: Lists agents and their status (Priv: agent,all)
  • AGI: Add an AGI command to execute by Async AGI (Priv: call,all)
  • Bridge: Bridge two channels already in the PBX (Priv: call,all)
  • Challenge: Generate Challenge for MD5 Auth (Priv: <none>)
  • ChangeMonitor: Change monitoring filename of a channel (Priv: call,all)
  • Command: Execute Asterisk CLI Command (Priv: command,all)
  • CoreSettings: Show PBX core settings (version etc) (Priv: system,reporting,all)
  • CoreShowChannels: List currently active channels (Priv: system,reporting,all)
  • CoreStatus: Show PBX core status variables (Priv: system,reporting,all)
  • CreateConfig: Creates an empty file in the configuration directory (Priv: config,all)
  • DAHDIDialOffhook: Dial over DAHDI channel while offhook (Priv: <none>)
  • DAHDIDNDoff: Toggle DAHDI channel Do Not Disturb status OFF (Priv: <none>)
  • DAHDIDNDon: Toggle DAHDI channel Do Not Disturb status ON (Priv: <none>)
  • DAHDIHangup: Hangup DAHDI Channel (Priv: <none>)
  • DAHDIRestart: Fully Restart DAHDI channels (terminates calls) (Priv: <none>)
  • DAHDIShowChannels: Show status dahdi channels (Priv: <none>)
  • DAHDITransfer: Transfer DAHDI Channel (Priv: <none>)
  • DBDel: Delete DB Entry (Priv: system,all)
  • DBDelTree: Delete DB Tree (Priv: system,all)
  • DBGet: Get DB Entry (Priv: system,reporting,all)
  • DBPut: Put DB Entry (Priv: system,all)
  • Events: Control Event Flow (Priv: <none>)
  • ExtensionState: Check Extension Status (Priv: call,reporting,all)
  • GetConfigJSON: Retrieve configuration (JSON format) (Priv: system,config,all)
  • GetConfig: Retrieve configuration (Priv: system,config,all)
  • Getvar: Gets a Channel Variable (Priv: call,reporting,all)
  • Hangup: Hangup Channel (Priv: system,call,all)
  • IAXnetstats: Show IAX Netstats (Priv: system,reporting,all)
  • IAXpeerlist: List IAX Peers (Priv: system,reporting,all)
  • IAXpeers: List IAX Peers (Priv: system,reporting,all)
  • ListCategories: List categories in configuration file (Priv: config,all)
  • ListCommands: List available manager commands (Priv: <none>)
  • Login: Login Manager (Priv: <none>)
  • Logoff: Logoff Manager (Priv: <none>)
  • MailboxCount: Check Mailbox Message Count (Priv: call,reporting,all)
  • MailboxStatus: Check Mailbox (Priv: call,reporting,all)
  • MeetmeMute: Mute a Meetme user (Priv: call,all)
  • MeetmeUnmute: Unmute a Meetme user (Priv: call,all)
  • ModuleCheck: Check if module is loaded (Priv: system,all)
  • ModuleLoad: Module management (Priv: system,all)
  • Monitor: Monitor a channel (Priv: call,all)
  • Originate: Originate Call (Priv: originate,all)
  • ParkedCalls: List parked calls (Priv: <none>)
  • Park: Park a channel (Priv: call,all)
  • PauseMonitor: Pause monitoring of a channel (Priv: call,all)
  • Ping: Keepalive command (Priv: <none>)
  • PlayDTMF: Play DTMF signal on a specific channel. (Priv: call,all)
  • QueueAdd: Add interface to queue. (Priv: agent,all)
  • QueueLog: Adds custom entry in queue_log (Priv: agent,all)
  • QueuePause: Makes a queue member temporarily unavailable (Priv: agent,all)
  • QueuePenalty: Set the penalty for a queue member (Priv: agent,all)
  • QueueRemove: Remove interface from queue. (Priv: agent,all)
  • QueueRule: Queue Rules (Priv: <none>)
  • Queues: Queues (Priv: <none>)
  • QueueStatus: Queue Status (Priv: <none>)
  • QueueSummary: Queue Summary (Priv: <none>)
  • Redirect: Redirect (transfer) a call (Priv: call,all)
  • Reload: Send a reload event (Priv: system,config,all)
  • SendText: Send text message to channel (Priv: call,all)
  • Setvar: Set Channel Variable (Priv: call,all)
  • ShowDialPlan: List dialplan (Priv: config,reporting,all)
  • SIPpeers: List SIP peers (text format) (Priv: system,reporting,all)
  • SIPshowpeer: Show SIP peer (text format) (Priv: system,reporting,all)
  • SIPshowregistry: Show SIP registrations (text format) (Priv: system,reporting,all)
  • Status: Lists channel status (Priv: system,call,reporting,all)
  • StopMonitor: Stop monitoring a channel (Priv: call,all)
  • UnpauseMonitor: Unpause monitoring of a channel (Priv: call,all)
  • UpdateConfig: Update basic configuration (Priv: config,all)
  • UserEvent: Send an arbitrary event (Priv: user,all)
  • VoicemailUsersList: List All Voicemail User Information (Priv: call,reporting,all)
  • WaitEvent: Wait for an event to occur (Priv: <none>)