Pulling Text Analytics data

Medallia’s Text Analytics engine works by associating topics, themes and sentiment to free text data.

Accessing TA data for a comment field

Comment fields can be expanded on to retrieve TA information. For every topic or theme, the Query API can return the ID, name, and region where the tag occurred. For sentiment taggings, the Query API returns the sentiment identified, and the region.

Example: Pulling TA data for field q_bp_cc_additional_channels_used_cmt

query textAnalyticsData {
  feedback(ids: "23391") {
    nodes {
      additionalChannels: fieldData(
        fieldId: "q_bp_cc_additional_channels_used_cmt"
      ) {
        ... on CommentFieldData {
          field {
            id
            name
          }
          values
          topics: ruleTopicTaggingsPage {
            nodes {
              topic {
                id
                name
              }
              regions {
                startIndex
                endIndex
              }
            }
          }
          themes: dataTopicTaggingsPage {
            nodes {
              topic {
                id
                name
              }
              regions {
                startIndex
                endIndex
              }
            }
          }
          sentiment: sentimentTaggingsPage {
            nodes {
              sentiment
              regions {
                startIndex
                endIndex
              }
            }
          }
        }
      }
    }
  }
}

Sample response

{
  "data": {
    "feedback": {
      "nodes": [
        {
          "additionalChannels": {
            "field": {
              "id": "q_bp_cc_additional_channels_used_cmt",
              "name": "Additional Channels Used Comment"
            },
            "values": [
              "Erin was very kind and quick to respond!"
            ],
            "topics": {
              "nodes": [
                {
                  "topic": {
                    "id": "663",
                    "name": "Staff - Attitude"
                  },
                  "regions": [
                    {
                      "startIndex": 0,
                      "endIndex": 4
                    },
                    {
                      "startIndex": 14,
                      "endIndex": 18
                    }
                  ]
                }
              ]
            },
            "themes": {
              "nodes": [
                {
                  "topic": {
                    "id": "5909",
                    "name": "Answer"
                  },
                  "regions": [
                    {
                      "startIndex": 32,
                      "endIndex": 39
                    }
                  ]
                },
                {
                  "topic": {
                    "id": "17819",
                    "name": "Kind Quick"
                  },
                  "regions": [
                    {
                      "startIndex": 23,
                      "endIndex": 28
                    },
                    {
                      "startIndex": 14,
                      "endIndex": 18
                    }
                  ]
                },
                {
                  "topic": {
                    "id": "5885",
                    "name": "Kind"
                  },
                  "regions": [
                    {
                      "startIndex": 14,
                      "endIndex": 18
                    }
                  ]
                },
                {
                  "topic": {
                    "id": "17322",
                    "name": "Answer Quick"
                  },
                  "regions": [
                    {
                      "startIndex": 32,
                      "endIndex": 39
                    },
                    {
                      "startIndex": 23,
                      "endIndex": 28
                    }
                  ]
                }
              ]
            },
            "sentiment": {
              "nodes": [
                {
                  "sentiment": "STRONGLY_POSITIVE",
                  "regions": [
                    {
                      "startIndex": 0,
                      "endIndex": 40
                    }
                  ]
                }
              ]
            }
          }
        }
      ]
    }
  },
  "errors": null,
  "_links": null,
  "_allowed": [
    "POST",
    "GET"
  ]
}

Matching taggings

To find topic, theme, or sentiment taggings matching specific filter criteria, use the nodes ruleTopicTaggingsPage, dataTopicTaggingsPage, and sentimentTaggingsPage. Each node is available when expanding on a comment field, like so:

Example: Find all sentiment taggings that match the criteria

query findTaggings($taFilter: TaggingFilter!) {
  feedback(ids: "23391") {
    nodes {
      matchingTaggings: fieldData(
        fieldId: "q_bp_cc_additional_channels_used_cmt"
      ) {
        ... on CommentFieldData {
          sentimentTaggingsPage(filters: [$taFilter]) {
            nodes {
              sentiment
              regions {
                startIndex
                endIndex
              }
            }
          }
        }
      }
    }
  }
}

The nodes take a filter as input; pass it as a variable for readability:

Use of variables in the filter for readability

{
  "taFilter": {
    "commentFields": [
      "q_bp_cc_additional_channels_used_cmt"
    ],
    "tagpools": ["26"],
    "topics": ["623"],
    "topicType": "RULE",
    "sentiments": [
      "STRONGLY_POSITIVE",
      "POSITIVE",
      "MIXED_OPINION",
      "NEGATIVE",
      "STRONGLY_NEGATIVE",
      "NO_OPINION"
    ]
  }
}

The filter must include either the ID of a given tag pool, or a list of topic IDs. Contact your Medallia representative to find these IDs.

The filter also determines whether the query returns data topics (themes) or rule topics (topics). It is not possible to filter on data and rule topics at the same time.

You must provide a list of sentiments.

Sample response

{
  "data": {
    "feedback": {
      "nodes": [
        {
          "matchingTaggings": {
            "sentimentTaggingsPage": {
              "nodes": [
                {
                  "sentiment": "STRONGLY_POSITIVE",
                  "regions": [
                    {
                      "startIndex": 0,
                      "endIndex": 40
                    }
                  ]
                }
              ]
            }
          }
        }
      ]
    }
  },
  "errors": null,
  "_links": null,
  "_allowed": [
    "POST",
    "GET"
  ]
}

Combine the results from the ruleTopicTaggingsPage, dataTopicTaggingsPage, and sentimentTaggingsPage nodes to get all matching taggings.

Finding records with a comment

For every comment field in the system there is a field that tracks the number of characters in the comment. If the field is called q_bp_cc_additional_channels_used_cmt the length will be stored in the field comment_length_q_bp_cc_additional_channels_used_cmt. All comments are concatenated in the field a_comments, so to find all records that have a comment across comment fields, filter on a_comment_length.

To find comments with a comment, simply filter on the length of the comment being greater than 0:

filter: {
          fieldIds: "a_comment_length"
          gt: "0"
        }