Author Topic: Mark Done, Agent Scripting, WDE and Outbound.  (Read 5224 times)

Offline daniel_san

  • Jr. Member
  • **
  • Posts: 84
  • Karma: 1
Mark Done, Agent Scripting, WDE and Outbound.
« on: March 23, 2016, 03:45:56 PM »
Hello,

I was wondering.. If you look at command chains of BundleClose of MarkDone on WDE, you can see that launch, BundleClose, InteractionVoiceBeforeClose and many others....

But if you try to do Mark Done with Agent Scripting (G_Interaction_MarkDone), this only launch one. "GASInteractionVoiceIfPossibleCloseInteraction".

Here is the important thing. This chain doesnīt contains MARKPROCESSED.

The problem is... In our MarkDone customization for Outbound we have developed some things before the markProcessed (Reschedule for example). Now the client wants to integrate the Mark Done on Agent Scripting, but the problem is when i press the button on Scripting to MarkDone the Record appears to be processed, and i canīt do nothing :(

I need to do manually the MarkProcessed also in Scriptingīs MarkDone.

Somebody can help?

Offline daniel_san

  • Jr. Member
  • **
  • Posts: 84
  • Karma: 1
Re: Mark Done, Agent Scripting, WDE and Outbound.
« Reply #1 on: March 28, 2016, 03:43:19 PM »
Maybe, somebody knows how to launch an event from Agent Scripting to Desktop... Trough this maybe i can try to close interaction from WDE....

Any help will be appreciated  ;D

Offline abudwill

  • Full Member
  • ***
  • Posts: 157
  • Karma: 4
Re: Mark Done, Agent Scripting, WDE and Outbound.
« Reply #2 on: March 31, 2016, 01:41:40 PM »
I ran into a defect with the way GAS attempts to close cases / mark them done.  I forget the exact details but I had opened a ticket and a hotfix was issued.  In the mean time I worked around it somehow (but adding a command to a command chain that was doing something inappropriate - I had to cause the command chain to halt its execution).  I never went back to update to the fixed version of GAS.

I have always rather been a fan of disabling the ability to mark done / close a case from GAS and have the end user mark done / close case from within IWS/WDE as they would normally.

Regarding launching an event from  Agent Scripting to Desktop, it is possible but a pain.  I accomplished this by writing AIL SDK (JSP) code in the API section of the agent script editor that would broadcast an EventUserEvent message to the agent DNs.  I would send whatever KVPs I needed to send.  Then on the IWS/WDE side I had to subscribe to TServer events for agents DN and filter to only receive EventUserEvents.  When I saw an EventUserEvent that had some key identifying KVPs in it (to let me know its a message I was sending to IWS/WDE from GAS), then I would pay attention to it and react accordingly.

I might be able to dig up some code if that would be helpful.

Offline daniel_san

  • Jr. Member
  • **
  • Posts: 84
  • Karma: 1
Re: Mark Done, Agent Scripting, WDE and Outbound.
« Reply #3 on: April 01, 2016, 10:44:31 AM »
Hi abudwill, thank you for your response.  :)

I was not friend of Mark Done Scripting neither. Other button is 20 cm up....  ???

I will try to do an approachment like yours with SDK from Scripting. If is not much work for you and you can borrow it, will be wellcome. If you canīt donīt worry, i will try to do by myself.

Thank you so much  :)

Offline abudwill

  • Full Member
  • ***
  • Posts: 157
  • Karma: 4
Re: Mark Done, Agent Scripting, WDE and Outbound.
« Reply #4 on: April 04, 2016, 02:36:04 PM »
I will post in parts.  This first part will demonstrate how to make IWS subscribe to TServer events that you will send from Agent Scripting AIL SDK.

Note I am typing this by hand, there could be some typos!

In your entry point / start up class, define an IViewEventManager and use dependency injection in the constructor to grab a reference:

[code]
private IViewEventManager viewEventManager;

public MyClass(IViewEventManager viewEventManager)
{
    this.viewEventManager = viewEventManager;
}
[/code]

In your Initialize method, subscribe to events
[code]
public void Initialize()
{
    viewEventManager.Subscribe(ViewEventManagerEventHandler);
}
[/code]

Define your event handler.  We want to register for TServer messages AFTER a login is detected (otherwise some references come back as null)
[code]
private void ViewEventManagerEventHandler(object eventObject)
{
    String eventMessage = eventObject as String;

    if(eventMessage.equals("Login"))
    {
        {
            RegisterForTServerMessages();
        }
    }
}
[/code]

Lets define RegisterForTServerMessages method.  Note you would want to detach any event handlers on the "Logout" event above (not shown):

[code]
private void RegisterForTServerMessages()
{
                IEnterpriseServiceProvider serviceProvider = agentManager.EntrepriseService.Provider;
                IChannelService channelService = serviceProvider.Resolve<IChannelService>("channelService");
                IClientChannel[] cChannels = channelService.ListChannels();
                if (cChannels != null)
                {                 
                    for (int i = 0; i < cChannels.Length; i++)
                    {
                        if (cChannels[i].Protocol.ProtocolDescription.ProtocolName != null)
                        {
                            if (cChannels[i].Protocol.ProtocolDescription.ProtocolName.Equals("TServer"))
                            {
                                if (cChannels[i].State != ChannelState.Closed)
                                {
                                    cChannels[i].RawSubscriber.SubscriptionBroker.Register<IMessage>(HandleUserEvents, new MessageIdFilter(EventUserEvent.MessageId));
                                    break;
                                }
                            }
                        }
                    }
                }
}
[/code]

Above we attached an event handler method named HandleUserEvents.  Lets define it now.  This is the method that will process the EventUserEvent messages.  Your reactions should happen in here:

[code]
private void HAndleUserEvents(IMessage message)
{
    EventUserEvent userEvent = message as EventUserEvent;

    // userEvent.UserData will contain KVP related info
   
    KeyValueCollection kvc = userEvent.UserData;

    if(kvc.ContainsKey("SomeKey"))
    {
        String myKeyValue = kvc["SomeKey"] as String;
        // do something here
    }

}
[/code]

There is lots of error checking and exception handling missing from the above.

Next part will be how to send EventUserEvents to agent DN from agent scripting.

Offline abudwill

  • Full Member
  • ***
  • Posts: 157
  • Karma: 4
Re: Mark Done, Agent Scripting, WDE and Outbound.
« Reply #5 on: April 04, 2016, 02:49:24 PM »
This next part demonstrates the jsp code needed to send EventUserEvents to the agents DNs.

You will need to define an API Interface in the Agent Scripting editor.  Define some inputs (in this case myValue, myValue2).  Assign them values before calling this custom API Interface.

basic JSP code is:

[code]
com.genesyslab.ail.AilFactory factory = com.genesyslab.ail.AilLoader.getAilFactory();

if (factory != null)
{
com.genesyslab.ail.Place ailPlace = factory.getPlace(placeId);
java.util.Collection dns = ailPlace.getDns();

if (dns != null)
{
java.util.Hashtable map = new java.util.Hashtable();

map.put("MyKey", myValue);
map.put("MyKey2", myValue2);

java.util.Iterator it = dns.iterator();

it = dns.iterator();

while (it.hasNext())
{
com.genesyslab.ail.Dn dn = (com.genesyslab.ail.Dn) it.next();
try
{
dn.sendUserEvent(map);
}
catch(com.genesyslab.ail.exception.RequestFailedException e)
{
}
}
}
}
[/code]

You probably want to include some sort of unique identifier in there like IWS Case UID, Outbound record handle, conn id, whatever you choose...

Hope this helps.

Offline daniel_san

  • Jr. Member
  • **
  • Posts: 84
  • Karma: 1
Re: Mark Done, Agent Scripting, WDE and Outbound.
« Reply #6 on: April 04, 2016, 03:58:05 PM »
Thank you so much abudwill!  :D

I was struggling to do the second part (send event from jsp) and for sure this will help me.

I will try to do on this days and post the results.

Thank you again :)