Author Topic: Keeping track of agents extension number  (Read 5115 times)

Offline Roath

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Keeping track of agents extension number
« on: February 04, 2016, 10:44:06 PM »
Hey Guys

Long time CTI developer , but new to developing on Genesys. ( Used to install and configure Genesys back in 1999 , so it's not totally new to me)

I've done a few integration projects.. latest one is to replace a failing solution. Solution provides a WS front end, where other parties can request a call to be made from agent X ( passing agent logon) to Number Y. The current solution is pretty hideous where for each request the service gets all dn's from Config and then queries each one from TServer until it finds a match, grabs the DN and then sends the makecall request. ( It's all in Java and does a few things which has me scratching my head!)

I'm replacing this with a Windows Service , so I can keep a state model of what agent is logged on where, so the requests can be processed without creating lots of load for each request.

Being playing around with approaches.. but not sure which is the best way.

a) Fetching all DN's from Config , adding a request to monitor to TServer for all of them so I can keep a list of Agents / dns. Maybe poll Config every X minutes and check for new ones / removed ones. Worried about if the site uses dynamic monitoring , that I will be making TServer monitor everything and what implications that has

b) Is there a way I can use Stat server? ( potentially allot easier) Monitor all agents either via an Agent Group that covers everyone? Hopefully the DN is there for those stats? ( Haven't looked, I'm still getting used to Stat server data and how to confirm whats there.. maybe the place data?)

I'm working on SDK 8.5 .NET

Any suggestions or concerns very much appreciated.

Thanks

Rob

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Keeping track of agents extension number
« Reply #1 on: February 05, 2016, 12:21:45 AM »
Can you re-describe your current app? Can't understand what it does exactly. WS is WebService?

Offline Roath

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Keeping track of agents extension number
« Reply #2 on: February 05, 2016, 03:04:11 AM »
Yes it's a web service  which allows other applications ( including web pages) to make a call for an agent.

For some reason ( I guess it's legacy) the requesting client only knows the user name.  Here are a few Java snippets

This happens for every get request.

Gets all dn's from the configuration service

        [color=red] Protocol pr = pms.getProtocol("cfgserver");

        KeyValueCollection filter = new KeyValueCollection();
        filter.addInt("dn_type", CfgDNType.CFGExtension.asInteger());[/color]
[color=red]
        RequestReadObjects rro = RequestReadObjects.create(
                CfgObjectType.CFGDN.asInteger(), filter);[/color]

then for each dn it queries TServer to get the details of that DN.



[color=#ff0000]      if (!tsopened) {[/color]
[color=#ff0000]            tso2 = initTserverConnection(pms);[/color]
[color=#ff0000]        }[/color]

[color=#ff0000]        Protocol pr = pms.getProtocol("tserver");[/color]      [color=red] RequestQueryAddress rqa = RequestQueryAddress.create(dn,
                AddressType.DN, AddressInfoType.DNStatus);[/color]

Then grabs the agentid  (after casting response to EventAddressInfo)

        [color=red]  id = eai.getAgentID()[/color]

and compares this to the username , if it matches then it uses that DN to request make the call.



      [color=#ff0000] if (!tsopened) {[/color]
[color=#ff0000]            tso2 = initTserverConnection(pms);[/color]
[color=#ff0000]        }[/color]

[color=#ff0000]        Protocol pr = pms.getProtocol("tserver");[/color]
[color=#ff0000]        RequestRegisterAddress rra = RequestRegisterAddress.create(dn,[/color]
[color=#ff0000]                RegisterMode.ModeShare, ControlMode.RegisterDefault,[/color]
[color=#ff0000]                AddressType.DN);[/color]
[color=#ff0000]        RequestMakeCall rmc = RequestMakeCall.create(dn, num,[/color]
[color=#ff0000]                MakeCallType.Regular);[/color]
[color=#ff0000]        RequestUnregisterAddress rua = RequestUnregisterAddress.create(dn,[/color]
[color=#ff0000]                ControlMode.RegisterDefault);[/color]

[color=#ff0000]        String message = "";[/color]
[color=#ff0000]        try {[/color]
[color=#ff0000]            pr.request(rra);[/color]

[color=#ff0000]            pr.request(rmc);[/color]
[color=#ff0000]            message = "<h3>MakeCall sent successfully</h3>";[/color]

[color=#ff0000]            pr.request(rua);[/color]
[color=#ff0000]        } catch (ProtocolException e) {[/color]
[color=#ff0000]            log.info("WebCaller::makeCall ProtocolException: " + e.getMessage());[/color]
[color=#ff0000]            log.error("WebCaller::makeCall", e);[/color]

[color=#ff0000]            message = "<h3>ProtocolException</h3>";[/color]
[color=#ff0000]        } catch (IllegalStateException e) {[/color]
[color=#ff0000]            log.info("WebCaller::makeCall IllegalStateException: "[/color]
[color=#ff0000]                    + e.getMessage());[/color]
[color=#ff0000]            log.error("WebCaller::makeCall", e);[/color]

[color=#ff0000]            message = "<h3>IllegalStateException</h3>";[/color]
[color=#ff0000]        }[/color]
[color=#ff0000]        if (!tsopened && tso2) {[/color]
[color=#ff0000]            closeGenesysConnections(false, true, pms);[/color]
[color=#ff0000]        }[/color]


So rather than every call having to query every dn in TServer to find the right agent, I was hoping I could have a statistic from Stat server which will norify me of what agent has logged in or out of any DN, or worst case a single process that keeps track of the agents.

Actually I am now wondering if I can use Stat Server and peek a statistic passing the agent id and get the dn. ( or maybe I need to get the db id of the user first). ( I'm thinking out loud here :)

Many thanks for taking the time


Rob


Offline Roath

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Keeping track of agents extension number
« Reply #3 on: February 05, 2016, 06:19:16 AM »
Ahh , missed something in the existing java code ( I struggle a little to read it  ::) )

There is another call to Config server to get the employeeID. I see that's needed now.

Just tried another approach. ( not tested end to end)

If I get a 'make call' request for an user id that I have no record for, go to step 1 , otherwise fetch details from memory and go to step 5

1) I get the  EmployeeID from config server. ( needed to create the statistic)
[size=2]
[color=blue]       
      Dim service As IConfService = ConfServiceFactory.CreateConfService(CSP)
      Dim query As New Queries.CfgFilterBasedQuery(CfgObjectType.CFGPerson)
      query.Filter.Add("user_name", username)
      Dim test As Object = service.RetrieveObject(query)[/color][/size]
2) I create a new statistic "CurrentAgentState" for that user ( which will receive the logoff as an event in the future)

3) Get the DN from config server using the the place id that is provided in the return from creating the 'CurrentAgentState'
*Update* , seems like I need to fetch the cfgplace  from config server , then fetch the DN from the config server using the dbid of the dn provided in the place. ( sheesh)

4) Store this agents details ( Agent ID, EmployeeID DN and the Statistic ID for the 'CurrentAgentState' statistic)

5) Make the call to TServer

6) Reply with result.


I would clear the statistics for any agent that has not had activity for more  than X ( time) to make sure I am not left with old ones.


This seems a much better approach to the current solution.

Is there another way which is cleaner / less problematic?


Many thanks
Rob
« Last Edit: February 05, 2016, 07:35:09 AM by Roath »

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Keeping track of agents extension number
« Reply #4 on: February 05, 2016, 01:38:36 PM »
Less problematic, no, as your requirement is kinda complex as well.
I guess this is a kinda dialer solution you are making, if so, why not just use OCS and maybe see its HTTP capabilities?

Offline Roath

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Keeping track of agents extension number
« Reply #5 on: February 05, 2016, 07:39:48 PM »
I am replacing a faulty component from an existing solution, therefore I don't have the option to change the solution. I have to match the Web Service interface exactly  so it just 'slots' in  8)

Looks like my new approach will work to me and be allot less load on things ( current component failing under load).

I'll go ahead and build it next week.

Cheers

Rob


Offline PeteHoyle

  • Full Member
  • ***
  • Posts: 126
  • Karma: 13
Re: Keeping track of agents extension number
« Reply #6 on: February 09, 2016, 12:29:53 PM »
Hi Rob,

For the Statistics you could use a definition like this in StatServer:

Category = CurrentState
MainMask = *
Objects = Agent
Subject DNStatus



That will give you the Voice DN, Place and Switch that an Agent is logged onto:

'EventInfo' ('2')
message attributes:
REQ_ID [int]    = 1
USER_REQ_ID [int] = 0
TM_SERVER [int] = 1455020597
TM_LENGTH [int] = 0
LONG_VALUE [int] = 0
VOID_VALUE [object] = AgentStatus {
AgentId = MCR_Agent0
AgentStatus = 8
Time = 1455020565
PlaceStatus = PlaceId = SIP_Server_Place3
PlaceStatus = 8
Time = 1455020565
DNs = DnCollection (size=2) [
[0] DnStatus {
ObjectType = Agent
DN Id = 7003
SwitchId = SIP_Switch
GSW DN TYPES = 1
DN Status = 8
Time = 1455020565
}
[1] DnStatus {
ObjectType = Agent
DN Id = chat
GSW DN TYPES = 0
DN Status = 8
Time = 1455020597
}
]
LoginId = 5000
}

You could also look at using  RequestGetStatistic which will give you a one off event and then you don't need to worry about closing any statistics after x seconds of inactivity:

"Requests one-time notification about a particular predefined statistic. Note, this request is not applicable to the CurrentTargetState category. "


Hope this helps,

Pete.

Offline Roath

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Keeping track of agents extension number
« Reply #7 on: February 10, 2016, 08:55:35 PM »
Hey Pete..

That's fantastic advice, thank you. I will have a look at that approach today.

I am currently getting place info back from the Stat Server when I request the statistic, the place id is correct, but the DN's is always empty. ( If I query the Place from config manager , i get the dn ids)

I will check out the statistic I am currently using , maybe it's different.

Nice idea about the single stat, have to decide if it's nicer to keep in memory and reduce the requests or keep it simple. I do like simple though 8)

Thanks so much, most appreciated.

Rob