The solution allows users to use their conversation history to generate useful articles that will answer common questions. The articles will be available to be used by the Knowledge Base and Knowledge AI to improve communication between a customer and an agent.
The solution is a single interface that provides access on an LP account level.
The AI platform is used to generate end articles. The output is generated in KAI++ format and stored in the S3 bucket for 90 days.
Use case:
- A client is willing to enrich their knowledge base responses based on questions their users ask. Instead of providing answers by an agent manually, the Knowledge base will provide ready answers, taking information from previous similar conversations.
Main Features
The solution provides a UI interface through which users can create a workflow that will scan conversation history and process the dialogs. As a result, the task will output “articles” that contain question-answer topics in a Knowledge AI format.
The solution involves generative AI that helps generate Articles for a Knowledge base.
A client will be able to:
- Create new tasks with parameters required for data processing (for example a time frame).
- Track the progress of existing tasks
- Cancel running tasks
- Review generated articles
Generated articles:
- are available on an account level
- can be extracted as decrypted and encrypted data
- are stored in an encoded format using symmetric encryption algorithms (AES-256-GCM)
- symmetric key for decryption is encrypted with a public key (asymmetric encryption)
- are stored on S3 with a cycle of 90 days (will be deleted after that)
Key Components
Frontend
- Static website
- Framework React
- S3 hosted, accessed through API Gateway
- SPA with authorization capabilities and task monitoring.
Backend API
- Framework NestJS (Typescript)
- Task control capabilities on account level.
- K8S Hosted, accessed through API Gateway
Database & Storage
- DynamoDB tables for task metadata
- Table list:
- tasks - table contains task records, with search configuration and workflow status
- accounts - account configuration table with a list of onboarded accounts
- S3 bucket for intermediate data storage and generated articles
ETL
- Used for dialog processing a Knowledge Base article generation
- Step Function (Fargate) K8s containers are used to run scripts
- Python is used for data extraction and article generation
- Fetching data using the Messaging History endpoint
- Processing fetched data to generate KB articles in KAI++ format
- Backne API orchestrates order for article generation. Data extraction can run in parallel
Authentication and Authorization
The application is using Conversation Cloud credentials to provide access to the application.
The account must be onboarded and stored in the accounts table to be able to use the application.
The authentication flow is shown below:
Frontend design
Figma design link
Status columnThe Status column has unique display logic based on values coming from “currentStep”, “status” and “metrics” attribute values.
Condition | Display text |
---|
currentStep = “in queue” AND status = “pending” | Waiting in queue… |
currentStep is ANY and status = “canceled” | Canceled |
currentStep = “extraction” AND status = “starting” | Starting dialog collector… |
currentStep = “extraction” AND status = “in progress” | Collecting dialogs… |
currentStep = “extraction” AND status = “error” | Dialog collection failed ⓘ on hover show errorMessage in a tooltip |
currentStep = “extraction” AND status = “completed” | Articles collection completed. Waiting for processing… |
currentStep = “processing” AND status = “starting” | Starting article generator… |
currentStep = “processing” AND status = “error” | Article generation failed ⓘ on hover show errorMessage in a tooltip |
currentStep = “processing” AND status = “in progress” AND metrics.dialogCount > metrics.dialogsProcessed | Generating articles. Step 1/4 ({prog} %) where {prog} = dialogsProcessed / dialogCount * 100 |
currentStep = “processing” AND status = “in progress” AND metrics.articlesCount > metrics.articlesEmbedded | Generating articles. Step 2/4 ({prog} %) where {prog} = articlesEmbedded / articlesCount * 100 |
currentStep = “processing” AND status = “in progress” AND metrics.articlesCount > metrics.articlesClustered | Generating articles. Step 3/4 ({prog} %) where {prog} = articlesClustered / articlesCount * 100 |
currentStep = “processing” AND status = “in progress” AND metrics.clustersCount > metrics.summaryGenerated | Generating articles. Step 4/4 ({prog} %) where {prog} = summaryGenerated / clustersCount * 100 |
currentStep = “processing” AND status = “completed” OR currentStep = “completed” | Done - {metrics.summaryGenerated} articles created |
New Task form
Download the Decoded article dialog
Backend API Endpoints
GET /api/auth/login?accountId=123
Initiate login for the account passed as a parameter
javascript:
{ "redirectUrl": string}
200 - OK
400 - Bad request, incorrect query parameters
401 - Unauthorised
500 - Server issue
GET /api/auth/callback?code=123
Authorize user with Auth2 code
javascript:
{ "accessToken": string, "userData": string,}
200 - OK
400 - Bad request, incorrect query parameters
401 - Unauthorised
500 - Server issue
GET /api/auth/logout
Logout user and invalidate a token
An authorization token is required.
200 - OK
401 - Unauthorised
500 - Server issue
GET /api/tasks
Return all created account tasks
An authorization token is required.
javascript:
{ "total": 1, "data": [ <Object Tasks> ]}
200 - OK
400 - Bad request, incorrect query parameters
401 - Unauthorised
500 - Server issue
Request Flow
POST /api/tasks
Create a new task record.
An authorization token is required.
javascript:
{ "encryptionKey": "long string", "searchParams": { "start": { "from": 1696839042270, "to": 1696839042270 } }}
Response
javascript:
<Object Tasks>
201 - OK
400 - Bad request, incorrect parameters
401 - Unauthorised
500 - Server issue
Request Flow
POST /api/tasks/[:id]/cancel
Update status of a running task to “canceled”.
[:id] stands for an actual ID of a task.
201 - OK
404 - Task for required ID is not found
401 - Unauthorised
500 - Server issue
GET /api/tasks/[:id]/articles
Return a temporary link to encoded articles and enveloped key for decoding.
[:id] stands for an actual ID of a task.
Note: content is returned in an encrypted state. A user must use a private key in order to decrypt the enveloped key. The enveloped key can be used to decrypt the file content.
javascript:
{ "url": "string", "envelopedKey": "string"}
200 - OK
404 - Task for required ID is not found
400 - Bad request. The task is not yet completed (articles were not generated).
401 - Unauthorised
500 - Server issue
Request Flow
GET /api/filters/[:type] (TBD)
NOTE: This endpoint is yet to be implemented
Return list of possible values for a filter
javascript:
[ { ["id"]: "value" }]
200 - OK
404 -Not found
401 - Unauthorised
500 - Server issue
Database Objects
Tasks
javascript:
{
// unique identifier of a task
"id": "UUID",
// user's account id (also secondary key)
"accountId": "number",
// person who triggers the task
"createdBy": "string",
// Launch datetime
"createdAt": "epoch DATE",
// Time of task completion
"completedAt": "epoch DATE",
// parameters required for processing (will be used as a body for API request)
"searchParams": {
// required filter for data access
"start": { "from": "epoch DATE", "to": "epoch DATE" },
// optional range for MCS
"mcs": { "from": 0, "to": 100 },
// other possible filters could be placed within searchParams
// https://developers.liveperson.com/messaging-interactions-api-methods-conversations.html#url-parameters
"..."
},
// public key provided by a user to encrypt data
"publicKey": "string",
// Step represents a state of a task flow
"currentStep": "in queue | extraction | processing | completed",
// Status represents how successful was a task
"status": "pending | in progress | error | completed | canceled",
// errorMessage contains an error reason for the failure of the flow
"errorMessage": "string",
// job metrics as a result of extraction/processing
"metrics": {
// number of conversations found by API (end result of extraction job)
"dialogCount": "number",
// number of conversations processed by a generative ai
"dialogsProcessed": "number",
// number of articles generated by a generative ai
"articlesCount": "number",
// number of generated articles converted to embedded values
"articlesEmbedded": "number",
// number of articles grouped into clusters
"articlesClustered": "number",
// number of unique article clusters
"clustersCount": "number",
// number or articles generated from clusters (end result of the processing job)
"summaryGenerated": "number",
// token metrics that show ai usage
"tokens": {
"input": "number",
"output": "number",
"embedding": "number"
}
},
// S3 path where encoded dialogs will be placed
"dialogPath": "string",
// encrypted symmetric key used to encrypt dialogs
"dialogEncryptKey": "string",
// S3 path where encoded articles will be stored
"generatedArticlesPath": "string",
// encrypted symmetric key used to encrypt articles
"articlesEncryptKey": "string"
}
currentStep
variables:
in queue - record was created, but orchestrator didn’t took it into work yet
extraction - record was took into process, orchestrator changed it to extraction
processing - record was took into process, orchestrator changed it to processing
completed - record was took into process, orchestrator changed it to completed
status
variables:
pending - process not started yet. Pending is set after a record is created (in combination with “in queue” currentStep) or when the orchestrator is changing currentStep to a new value
in progress - a process has started. Value is set by a workflow task
error - a process has failed. Value is set by workflow task or by an orchestrator if the error is caused by an external issue (OOM, image error, invalid configuration, etc.)
completed - a process of a workflow is completed. The value is set by a workflow task
canceled - the task is canceled. The value is set by a user through a “POST /api/tasks/[:id]/cancel” endpoint.
ETL
ETL is done with the use of a Step Function workflow. The workflow contains the next steps:
- task invocation
- data extraction
- article generation
- fallback mechanism
Task Invocation
Backend API takes the role of an orchestrator for the task workflows.
Backend API repeatedly checks for pending states of tasks. If there is a pending task, it will attempt to invoke a Step Function workflow.
Data Extraction
Data extraction is a task of an article generation workflow.
The goal is to extract account dialogs and format them.
The extraction is done with the use of the Messaging Interactions API.
Input: Task ID (id record for a task)
Output: JSON file with dialog data
Environment variables:
- dynamodb table
- s3 bucket
- task ID
- API token
Next step: Article Generation
Fallback step: Fallback Mechanism
Article Generation
The Article generation task uses extracted dialog data to form articles.
The data should be taken from a storage where the previous step placed it.
The goal is to generate articles in KIA++ format.
Input: Task ID (id record for a task)
Output: CSV file with article data
Environment variables:
- dynamodb table
- s3 bucket
- task ID
- API token
Fallback step: Fallback Mechanism
Logging
Log Name | Location |
---|
| STDOUT |
* | /logs |
Deployment
CI/CD
All related pipelines are done with Jenkins.
AllCloud (infrastructure)
Architecture deployment is controlled by AllCloud team
Architectural diagram document:
Using the Knowledge Base AI Tool
For a detailed walkthrough on using the Knowledge Base AI tool, a dedicated video guide is available. This guide provides a high-level overview of the core functionalities to get you started.