Knowledge Management
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
Base URL
https://api-prd.kpn.com/data/pollyhelp/knowledgemanagement
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 an e-mail, an Id
, IdType
, a polly.help token and a 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
Requirements
To fill and configure the knowledge base, the same e-mail address will be used as the one you registered with at the KPN Developer Portal. 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
Make sure you've read What's in it for you for more info on how to register and start testing APIs.
Authentication
The API follows the KPN Store API Authentication Standard to secure the API. It includes the use of OAuth 2.0 client_id
and client_secret
to receive an access token.
Go to the Authentication tab on top of this page to find out how to:
- Authenticate to an API using cURL.
- Authenticate to an API on Swaggerhub.
- Import Open API Specifications (OAS), also called Swagger files into Postman.
Setting up your third-party account with Polly.help
When you add this Knowledge Management API to your project in the My Developer Portal, 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 Polly.help 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:
- Select
GET /token
. - Click
Try it out
. - Check the response code and message.
Postman:
- Select
GET (GetToken)
. - Click
Send
. - 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:
- Select
POST /graphql
. - Supply query, token and publication id in the payload. See below for examples.
- Click
Try it out
. - Check the response code and message.
Postman:
- 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. - Supply query, token, publication id in the payload.
- Click Send.
- 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.