Author Topic: Update callresult on outbound campaign using PSDK  (Read 9967 times)

Offline luchosrock

  • Newbie
  • *
  • Posts: 43
  • Karma: 0
Update callresult on outbound campaign using PSDK
« on: March 11, 2016, 04:06:37 PM »
I have a softphone solution made with PSDK 8.0. During an outbound campaign, how can I change the CallResult value of an established call? What type of request should I make?

Thanks in advance,

Regards

Offline Kubig

  • Hero Member
  • *****
  • Posts: 2752
  • Karma: 44
Re: Update callresult on outbound campaign using PSDK
« Reply #1 on: March 11, 2016, 04:55:56 PM »
Use the OCS HTTP API which offers you the operations on OCS records. Look into dep guide for more details.

Offline luchosrock

  • Newbie
  • *
  • Posts: 43
  • Karma: 0
Re: Update callresult on outbound campaign using PSDK
« Reply #2 on: March 11, 2016, 06:41:26 PM »
Thanks Kubig for your quick reply,

So you say that I must do an HTTP request in order to update the callresult. But, is there a way I can achieve it by using the Platform SDK directly? I mean, I can see in the PSDK documentation that there are ScheduledCall and UpdateCallCompletionStats object types in the OutboundDesktop namespace that can be sent through protocolManagementService requests, I just can't quite get what call I should do  :(
« Last Edit: March 11, 2016, 06:43:01 PM by luchosrock »

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Update callresult on outbound campaign using PSDK
« Reply #3 on: March 11, 2016, 07:07:18 PM »
UpdateCallCompletitionStats with new call result

Offline luchosrock

  • Newbie
  • *
  • Posts: 43
  • Karma: 0
Re: Update callresult on outbound campaign using PSDK
« Reply #4 on: March 11, 2016, 07:45:38 PM »
How do I add CallResult to an UpdateCallCompletionStats  object type? the class has only these properties:

- ApplicationId
- CampaignName
- OtherFields
- RecordHandle

Should I add a KVP Collection informing the CallResult on the OtherFields property? Sorry but I'm kind of lost here.... :/

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Update callresult on outbound campaign using PSDK
« Reply #5 on: March 11, 2016, 08:20:32 PM »
Yes
Check OCS guide for more details

Offline luchosrock

  • Newbie
  • *
  • Posts: 43
  • Karma: 0
Re: Update callresult on outbound campaign using PSDK
« Reply #6 on: March 15, 2016, 01:06:54 PM »
Thanks Cav, I checked OCS guides, from which I now have this doubt:

Are OutboundDesktop requests made through TServer?

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Update callresult on outbound campaign using PSDK
« Reply #7 on: March 15, 2016, 02:12:37 PM »
Well, you send the request via monitored DN as a user event and then OCS receives it.

Offline luchosrock

  • Newbie
  • *
  • Posts: 43
  • Karma: 0
Re: Update callresult on outbound campaign using PSDK
« Reply #8 on: March 15, 2016, 02:44:44 PM »
Thanks! I will try that way  ;D

Offline luchosrock

  • Newbie
  • *
  • Posts: 43
  • Karma: 0
Re: Update callresult on outbound campaign using PSDK
« Reply #9 on: March 15, 2016, 08:25:53 PM »
Unfortunately, I couldn't find a way to make the appropiate request :(

I think I'm missing something important here, as I can't tell for sure trough which object/namespace I should make the request for update (I checked for TServer.Requests namespace and couldn't understand how to do it). There are threads related here, but pointing to a broken link.

Cavagnaro: I read about the Monitored DN, but I couldn't understand how the request is made (under what namespace).

Any help will be appreciated :/

Offline PeteHoyle

  • Full Member
  • ***
  • Posts: 126
  • Karma: 13
Re: Update callresult on outbound campaign using PSDK
« Reply #10 on: March 16, 2016, 09:33:05 AM »
There are various ways to do this.

The basic way is to send a UserEvent from the Agents DN.

To send a UserEvent have a look at the RequestSendEvent request.

Platform SDK 8.5 API Reference
RequestSendEvent Class

Namespaces ► Genesyslab.Platform.Voice.Protocols.TServer.Requests.Special ► RequestSendEvent

In the UserEvent need to add the required fields to the UserData for either a  UpdateCallCompletionStats or a RecordProcessed request (see the Outbound Contact Reference Manual)..


For example a RecordProcessed request would be something like:

        private void btnRecordProcess_Click(object sender, EventArgs e)
        {
            KeyValueCollection kvp = new KeyValueCollection();
            kvp.Add("GSW_AGENT_REQ_TYPE", "RecordProcessed");
            kvp.Add("GSW_CALL_RESULT", 9);//AnswerMachine Detected
            gc.ProcessRecord(prot_name, dn, kvp);
        }


        internal void ProcessRecord(string prot_name, string dn, KeyValueCollection kvp)
        {
            DNState state = DNStateHolder.Instance.getDNState(dn);
            if(state ==null)
                return;

            Dictionary<String, CallState> calls = state.Calls;
            foreach(String key in calls.Keys)
            {
                CallState call = calls[key];
                KeyValueCollection call_data = call.UserData;
                if (call_data.ContainsKey("GSW_RECORD_HANDLE"))
                {
                    kvp.Add("GSW_RECORD_HANDLE", call_data.GetAsInt("GSW_RECORD_HANDLE"));
                }

                if (call_data.ContainsKey("GSW_APPLICATION_ID"))
                {
                    kvp.Add("GSW_APPLICATION_ID", call_data.GetAsInt("GSW_APPLICATION_ID"));
                }

                if (call_data.ContainsKey("GSW_CALLING_LIST"))
                {
                    kvp.Add("GSW_CALLING_LIST", call_data.GetAsString("GSW_CALLING_LIST"));
                }

                if (call_data.ContainsKey("GSW_CAMPAIGN_NAME"))
                {
                    kvp.Add("GSW_CAMPAIGN_NAME", call_data.GetAsString("GSW_CAMPAIGN_NAME"));
                }

                if (call_data.ContainsKey("GSW_CAMPAIGN_NAME"))
                {
                    kvp.Add("GSW_CAMPAIGN_NAME", call_data.GetAsString("GSW_CAMPAIGN_NAME"));
                }
            }

            SendUserEvent(prot_name, dn, kvp);
        }

        internal void SendUserEvent(string prot_name, string dn, KeyValueCollection kvp)
        {
            RequestSendEvent req = RequestSendEvent.Create();   
            CommonProperties comm = CommonProperties.Create();
            comm.ThisDN = dn;
            comm.UserData = kvp;
            comm.UserEvent = EventUserEvent.MessageId;
            req.UserEvent = comm;
            sendRequest(prot_name, req);
        }


Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Update callresult on outbound campaign using PSDK
« Reply #11 on: March 16, 2016, 12:16:40 PM »
And what are the other ways? Using http commands to OCS?

Offline luchosrock

  • Newbie
  • *
  • Posts: 43
  • Karma: 0
Re: Update callresult on outbound campaign using PSDK
« Reply #12 on: March 16, 2016, 02:35:18 PM »
It worked like a charm Pete, thanks a lot!

Another question... When the call is finished (one of the parties hang up the phone), the record is marked as updated and I wouldn't be able to change it. Is it possible to reinject the record in AfterCallWork? If so, can I retrieve all the contact records related with the chain_id or recordhandle during the call in order to use them in AfterCallWork?

I'm just checkin' if it can be done, but the snippet you posted helped a lot and may be enough!

Thanks.


Offline PeteHoyle

  • Full Member
  • ***
  • Posts: 126
  • Karma: 13
Re: Update callresult on outbound campaign using PSDK
« Reply #13 on: March 16, 2016, 03:45:52 PM »
Have a look at the OCS option below.

If the Agent goes into Ready at the end of a call the OCS will assume that record is finished with, so if you set this option to not let the Agent go into Ready that should mean you can still update the record.

outbound_release_action
Type: Optional
Default Value: soft_previous
Valid Value(s): hard_ready, hard_not_ready, soft_previous, hard_acw
Changes Take Effect: Immediately
Determines the agent’s place state after an outbound call is released.
• When set to hard_ready, OCS sends a request to T-Server to force the
teleset to the Ready state.
• When set to hard_not_ready, OCS sends a request to T-Server to force the
teleset to the Not Ready state.
• When set to soft_previous, OCS uses the Agent State provided by Stat
Server.
• When set to hard_acw, OCS sends a request to T-Server to force the teleset
to the After Call Work state after an outbound call is released from an
agent’s DN.

Offline PeteHoyle

  • Full Member
  • ***
  • Posts: 126
  • Karma: 13
Re: Update callresult on outbound campaign using PSDK
« Reply #14 on: March 16, 2016, 03:48:08 PM »
[quote author=cavagnaro link=topic=9421.msg42706#msg42706 date=1458130600]
And what are the other ways? Using http commands to OCS?
[/quote]

Hi,

Yes as you say using http commands to OCS is one way.

The other way I was thinking was using the OutboundDesktop PSDK API, in the background it's the same in that it sends a UserEvent, just a slightly different API. I've never used this method though, always just create my own UserEvents..