Introduction

The Knowledge Management API allows you to organize your organization's information with knowledge management software and request information on the knowledge base using advanced GraphQL queries.


API specification

Test the API on SwaggerHub


Base URL

https://api-prd.kpn.com/data/pollyhelp/knowledgemanagement


Conceptual model

Conceptual model


Definitions

Token

To interact with an entity within the knowledge base, you will require a token to uniquely indentify the entity. This token information consists of: E-mail, Id, IdType, polly.help Token and DocName. The information from the token will be used in the POST /graphql request.

The token service returns a JSON message and looks like this:

^^Response example^^
[
    {
        "CustomerEmail": "xx@xx.xx",
        "Id": "xxxx",
        "IdType": "knowledgebase",
        "Token": "xxxx",
        "DocName": "Demo Retail NL"
    }
]


API workflow

Sequence diagram


Prerequirements

To fill and configure the knowledge base, the same e-mail address will be used as the one you registered with on the API Store. There are also some publication types that require a buddy e-mail account setup, which will be a different e-mail address from the one registered with our Store.


Features and constraints

Features

  • Create and query knowledge base collections of articles.
  • Create simple or complex graphQL queries on your categorised knowledge.
  • For external (website) or internal use.

Constraints

  • Decision trees are not accessible through the API.


Getting started

When you add this Knowledge Management API to your app on the KPN API Store, you will receive an e-mail at the e-mail address that you registered. The e-mail will provide you with your password to log into the management website. Go to the Polly.help login page and log in with your e-mail address and provided password. Once logged in, you can create a knowledge base. Select the appropriate template from the list of templates for the type of knowledge base you would like to create. For example: Demo Retail NL, which provides you with default collections, articles and more, written in Dutch. With collections and articles in place, you can create a publication. Add collections to the publications and publish one or more articles.


How to...

Get token information

This request returns one or more tokens of your published information. Use token id and polly.help token in the POST /graphql request.

SwaggerHub:

  1. Select GET /token.
  2. Click Try it out.
  3. Check the response code and message.

Postman:

  1. Select GET (GetToken).
  2. Click Send.
  3. Check the response code and message.

Get query information

This is a powerful request that allows you to fire a graphQL query on the knowledge base. For each request you will need to provide id and token, that were previously retrieved by the GET /token request.

SwaggerHub:

  1. Select POST /graphql.
  2. Supply query, token and publication id in the payload. See below for examples.
  3. Click Try it out.
  4. Check the response code and message.

Postman:

  1. In the Postman collection, there are different payload based requests available, based on a query using same endpoint POST /graphql. See below for the queries.
  2. Supply query, token, publication id in the payload.
  3. Click Send.
  4. Check the response code and message.

In Postman payloads are available in the collection, whereas this is not available in SwaggerHub. Here is an overview of available GraphQL queries, so you can provide the payload to the SwaggerHub request.

Query name   Postman request   Query content payload  
Get article   POST (get article)   { "query": "{ article(id: \"{{articleId}}\") { id name content } }", "variables": {"publicationId": "{{publicationId}}", "api_token": "{{polly-api-token}}" } }
Search   POST (search)   { "query": "{ search(query: \"article\") { results { id name contentsnippet(length: 100) }} }", "variables": { "publicationId": "{{publicationId}}", "api_token": "{{polly-api-token}}" } }
Publications popular   POST (get publication > most popular)   { "query": "{ publication { mostpopular(first: 5) { id name contentsnippet(length: 100) } } }", "variables": { "publicationId": "{{publicationId}}", "api_token": "{{polly-api-token}}" } }
Publication   Post (get publication)   { "query": "{ publication { mostpopular(first: 5) { name } collections { name, mostpopular(first:3) { name}}} }", "operationName": "", "variables": { "publicationId": "{{publicationId}}", "api_token": "{{polly-api-token}}", "user": "{{emailAddress}}" } }
Analytics   POST (get analytics count article.views)   { "query": "{ search(query: \"article\") { results { id name contentsnippet(length: 100) }} }", "variables": { "publicationId": "{{publicationId}}", "api_token": "{{polly-api-token}}" } }
Suggestion   POST (submitSuggestion)   { "query": "mutation submitSuggestion { submitSuggestion( content:\"I suggest to...\" articleId:\"{{articleID}}" value:0 feedbackReason:1 priority:1 ){ id } }", "variables": { "publicationId": "{{publicationId}}", "api_token": "{{polly-api-token}}", "user" : "{{emailAddress}}" } }

Create GraphQL queries

For creating GraphQL queries, you could use an online editor. In this editor, copy and uncomment the lines below # Use these query variables for access to the demo publication: and copy this to the QUERY VARIABLES section below it. Now create your own GraphQL. If you need a GraphQL reference, check out this cheatsheet.


Return codes

Code Description
200 Success.
201 Created.
202 Accepted.
302 Found. Link in location header.
400 Bad request.
401 Unauthorized.
403 Forbidden.
404 Not found.
405 Method not allowed.
412 Precondition failed.
429 Too many requests.
500 Internal server error.
502 Bad gateway.
503 Service unavailable.

Mopinion feedback