Add analytics property during live conversation?

Hi, I've created a data action which I've used to set a property using
/api/v2/analytics/conversations/{conversationId}/details/properties
prior to the call being routed to an agent.

The flow works as expected but the property isn't added to the conversation.

When I use the same data action by testing it with the same inputs as were given in the flow after the conversation has ended the property is added.

Can analytics properties only be added to conversations that have ended?

Br

Hello,

It took me a while and few tests to understand the constraint on setting analytics properties in a conversation.

"Can analytics properties only be added to conversations that have ended?"
No, Analytics properties can be added while the conversation is active.

But the analytics properties must be set in a session's segment which is ended already.
I mean a session's segment with segmentStart and segmentEnd.

Note: while the call is managed by the IVR/Architect Inbound Call flow, you in fact only have 2 segments which are ended: one under the customer's participant (with segmentType = system), one under the ivr's participant (with segmentType = system). The segments with segmentType = interact (under the customer's participant and under the ivr's participant) are started - but not ended yet - so you can't add properties in these segments at this stage of the call.

With the /api/v2/analytics/conversations/{conversationId}/details/properties request, you don't really target a segment but provide a targetDate - this targetDate will have to be between segmentStart and segmentEnd of an ended/terminated segment.

The Architect built-in variable Flow.StartDateTimeUtc corresponds to a time which is greater than the segmentEnd time of the "system" segment (occurring in the "interact" segment).
So you can't use this value in your analytics properties request.

You would have two options:

  1. With Data Action approach: you will have to invoke 2 Data Actions. The first one to retrieve a valid targetDate (one that can correspond to a "system" segment) and possibly the sessionId of the customer's participant (if you want to attach the properties under the customer's participant instead of the ivr participant). And the second one to set the analytics properties.
    The drawback of this approach is that it will make use of and invoke 2 Data Actions (impacts rate limits).

  2. With External Tag approach:
    Recently the support of External Tag has been added on Genesys Cloud.
    External Tag allows you to set a value in the externalTag attribute (single value).
    ExternalTag can be retrieved in a conversation context (Conversations API) and in conversation details (Analytics API).
    ExternalTag can also be used as a dimension's filter in a Query for Conversation Details.
    It is also possible to set the external tag from an Architect flow using the Set External Tag action.
    The advantage of this approach is that it does not require to leverage a Data Action (or 2). So if you are not using the externalTag attribute already (for another purpose) and if you were planning to attach a single key/value in analytics properties, this approach may be more appropriate.

If you want to stick to the Data Action approach, you could leverage the following Genesys Cloud Data Action to retrieve the segmentStart time (of the first segment - the one with segmentType = system).
In the example below, I am retrieving the sessionId and segmentStart of the customer's participant.
If you want to attach your analytics properties under the IVR participant, just modify the Response configuration to look for a participant with purpose = ivr.

Input schema:

{
  "type": "object",
  "properties": {
    "convId": {
      "type": "string"
    }
  },
  "additionalProperties": true
}

Output schema:

{
  "type": "object",
  "properties": {
    "sessionId": {
      "type": "string"
    },
    "startTime": {
      "type": "string"
    }
  },
  "additionalProperties": true
}

Request configuration:

{
  "requestUrlTemplate": "/api/v2/analytics/conversations/${input.convId}/details",
  "requestType": "GET",
  "headers": {
    "Content-Type": "application/json"
  },
  "requestTemplate": "${input.rawRequest}"
}

Response configuration:

{
  "translationMap": {
    "sessionIdArray": "$.participants[?(@.purpose ==\"customer\" || @.purpose ==\"external\")].sessions[0].sessionId",
    "startTimeArray": "$.participants[?(@.purpose ==\"customer\" || @.purpose ==\"external\")].sessions[0].segments[0].segmentStart"
  },
  "translationMapDefaults": {},
  "successTemplate": "{\n   \"sessionId\": ${successTemplateUtils.firstFromArray(\"${sessionIdArray}\")}\n, \"startTime\": ${successTemplateUtils.firstFromArray(\"${startTimeArray}\")}\n}"
}

Regards,

Hi,

Thanks for the detailed answer, that clarifies why the data actions didn't result in properties being added from the data actions.

Br

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.