XML API Looking for 'calls in queue' info

Talk with others about developing applications for Switchvox

Moderators: bmdhacks, dpodolsky, tristand, jwitt, joshuas

XML API Looking for 'calls in queue' info

Postby dribar » Wed Nov 10, 2010 12:31 pm

Greetings,

I am new to asterisk but not to XML and programming.

We have one main call queue that I'm looking to get realtime number of calls in queue. I am going to put this on our wallboard with an XML call but I'm not too sure where I can find the data point.

Any suggestions?

Thanks in advance.

Dan Ribar
dribar
Newsterisk
 
Posts: 29
Joined: Wed Nov 10, 2010 12:28 pm

Re: XML API Looking for 'calls in queue' info

Postby dpodolsky » Thu Nov 18, 2010 11:39 pm

Dan,
Currently there isn't an API for getting call queue information out of Switchvox realtime, however, this is something we are working on for a future release.
dpodolsky
Oldsterisk
 
Posts: 325
Joined: Thu Apr 23, 2009 2:35 pm

Re: XML API Looking for 'calls in queue' info

Postby DeepTech » Wed Feb 16, 2011 3:37 pm

I second that request.
DeepTech
Newsterisk
 
Posts: 44
Joined: Wed Mar 04, 2009 8:20 am

Re: XML API Looking for 'calls in queue' info

Postby dribar » Thu Mar 10, 2011 8:36 am

I figured out a way to do this using switchvox.currentcalls.getlist and will post my code soon. trying to get past authentication for now....
dribar
Newsterisk
 
Posts: 29
Joined: Wed Nov 10, 2010 12:28 pm

Re: XML API Looking for 'calls in queue' info

Postby dribar » Fri Mar 11, 2011 1:52 pm

Success. I have 4 queues to watch: green,yellow,red,claims. I actually stick my data in a table for other processes to use, but this will give you a string output. Just comment out what you don't want to see. The other thing is this really helps you figure out what is actualy coming back from the switch.

Golden code I tell you....

Here you go including the digest connection:

Code: Select all

Dim myXML As String = "<request method='switchvox.currentCalls.getList'><parameters></parameters></request>"

        Dim myURL As String = "https://myBox/xml"
        Dim myCred As New NetworkCredential("admin", "adminPassword", "myDomain.com")
        Dim MyURI As New Uri(myURL)
        Dim myReq As HttpWebRequest = WebRequest.Create(MyURI)
        Dim credCache As CredentialCache = New CredentialCache

        credCache.Add(MyURI, "Digest", myCred)

        myReq.Credentials = credCache

        Dim myWriter As StreamWriter = Nothing

        myReq.Method = "POST"
        myReq.ContentLength = myXML.Length
        'myReq.ContentType = "application/x-www-form-urlencoded"
        myReq.ContentType = "text/xml"

        myWriter = New StreamWriter(myReq.GetRequestStream())
        myWriter.Write(myXML)
        myWriter.Close()

        Dim myRes As HttpWebResponse = myReq.GetResponse

        Dim sr As StreamReader
        sr = New StreamReader(myRes.GetResponseStream())
       
        Dim ReadMe As XmlTextReader = New XmlTextReader(sr)
        Dim CallStatus As String = ""
        Dim CallQueue As String = ""
        Dim GreenQueueCalls As Integer = 0
        Dim YellowQueueCalls As Integer = 0
        Dim RedQueueCalls As Integer = 0
        Dim ClaimsQueueCalls As Integer = 0

        Do While (ReadMe.Read())
            ' Do some work here on the data.
            CallQueue = ""
            CallStatus = ""

            If ReadMe.Name = "current_call" Then
                l_msg.Text &= "<br>=============================="
                l_msg.Text &= "<br>Name:" & ReadMe.Name
                l_msg.Text &= "<br>Value:" & ReadMe.Value
                l_msg.Text &= "<br>Encoding:" & ReadMe.Encoding.ToString
                l_msg.Text &= "<br>LineNumber:" & ReadMe.LineNumber.ToString
                l_msg.Text &= "<br>attribute count:" & ReadMe.AttributeCount.ToString

                Dim z As Integer
                For z = 0 To ReadMe.AttributeCount - 1

                    Dim aStr As String = ReadMe.GetAttribute(z).ToString()

                    'turn this on to see all values
                    l_msg.Text &= "<br>attribute " & z.ToString & ":" & aStr

                    Select Case z
                        Case 3 ' who is getting the call
                            CallQueue = aStr
                            l_msg.Text &= "<br>attribute " & z.ToString & ":" & aStr
                        Case 7 ' this is the status: talking, ivr, queued
                            CallStatus = aStr
                            l_msg.Text &= "<br>attribute " & z.ToString & ":" & aStr
                    End Select
                Next

                If CallStatus = "queued" Then
                    Select Case LCase(CallQueue)
                        Case "green"
                            GreenQueueCalls += 1
                        Case "red"
                            RedQueueCalls += 1
                        Case "yellow"
                            YellowQueueCalls += 1
                        Case "claims"
                            ClaimsQueueCalls += 1
                    End Select
                End If
            End If
        Loop
        sr.Close()

        l_msg.Text &= "<br>================================"
        l_msg.Text &= "<br>Green Queued Calls:" & GreenQueueCalls.ToString
        l_msg.Text &= "<br>Yellow Queued Calls:" & YellowQueueCalls.ToString
        l_msg.Text &= "<br>Red Queued Calls:" & RedQueueCalls.ToString
        l_msg.Text &= "<br>Claims Queued Calls:" & ClaimsQueueCalls.ToString

dribar
Newsterisk
 
Posts: 29
Joined: Wed Nov 10, 2010 12:28 pm


Return to Switchvox Developers

Who is online

Users browsing this forum: No registered users and 2 guests