Chat Review Using AI
Author(s)
- Reshmi Karan
- ...
Last Updated Date
2025-08-27
SRS References
Version History
| Version | Date | Changes | Author |
|---|---|---|---|
| 1.0 | 2025-03-31 | Initial draft | Reshmi Karan |
| 2.0 | 2025-08-27 | Implement Get Review using openrouter SDK | Reshmi Karan |
| ... | ... | ... | ... |
Feature Overview
Objective:
Provide AI-powered chat reviews by analyzing chat transcripts, retrieving existing reviews, or generating new insights using an AI endpoint.
Key Inclusions:
Automated retrieval and storage of chat reviews Sentiment analysis (Positive, Negative, Neutral) Rating system for chat quality assessment Insights generation based on chat context Integration with external AI services for review generation
Scope:
The Chat Review AI feature aims to automate and enhance the process of analyzing chat transcripts by leveraging AI. It retrieves existing chat reviews from a database or generates new insights using an AI model if no prior reviews exist. The system evaluates customer sentiment, ratings, and key insights to provide meaningful feedback.
Limitations & Exclusions:
The AI model's accuracy depends on the quality of chat transcripts.
No manual review adjustments once an AI-generated review is stored.
No real-time chat analysis; operates only on completed chat transcripts.
Dependencies:
External AI service for analyzing chat transcripts and generating insights.
Requirements
Functional Requirements
- Retrieve Chat Information
Fetch chat details, including transcript and metadata.
- Retrieve Existing Chat Review
Query the database for an existing review based on the chat ID.
If found, return the stored review.
- Generate AI Review if Not Found
If no existing review is found, retrieve the chat transcript.
Send the transcript to an AI service via an API endpoint.
Receive and process the AI-generated review.
3.1. API Integration – OpenRouter with Microsoft.Extensions.AI
The Chat Review Service integrates with OpenRouter for AI-powered transcript analysis, using Microsoft.Extensions.AI SDK for abstraction.
- Store AI-Generated Review
Save the AI-generated review, rating, and insights in the database.
- Return Chat Review
Ensure the chat review is returned to the requesting service.
Design Specifications
-
UI/UX Design:
(Include wireframes, mockups, or links to design files.) -
Data Models:
[DataContract]
public class ChatTranscriptAI
{
[DataMember]
public Guid SubscriberId { get; set; }
[DataMember]
public string SubscriberName { get; set; }
[DataMember]
public string ProductName { get; set; }
[DataMember]
public string PreChatSurvey { get; set; }
[DataMember]
public string PostChatSurvey { get; set; }
[DataMember]
public string ChatText { get; set; }
}
[DataContract]
public class ChatReviewResponse
{
[JsonIgnore]
public Guid ChatId { get; set; }
[JsonIgnore]
public Guid SubscriberId { get; set; }
[DataMember]
public int Rating { get; set; }
[DataMember]
public CustomerSentiment CustomerSentiment { get; set; }
[DataMember]
public string Insights { get; set; }
}
public enum CustomerSentiment
{
None = 0,
Positive = 1,
Negative = 2,
Neutral = 3
}
[DataContract]
public class ChatBasicInfo
{
[DataMember]
public Guid ChatId { get; set; }
[DataMember]
public Guid LeadId { get; set; }
[DataMember]
public Guid VisitorSubscriberId { get; set; }
[DataMember]
public Guid ChatOwnerSubscriberId { get; set; }
[DataMember]
public Guid LeadSubmittedToId { get; set; }
} -
API Interfaces:
Endpoint Method Parameters Response Response Status Codes /api/SubscriberAnalytics/ChatReviewFromAIGETchatId(Guid),subId(Guid)ChatReviewResponse200,204,500api/chat/analyze-chat-reviewPOSTchatTranscript(string)ChatReviewResponse200,204,500 -
Third-Party Integrations:
(OpenRouter via SDK, integrated usingMicrosoft.Extensions.AIwith preset-based configuration) -
Workflow:
- Retrieve chat details
- Check for Existing Review in the database
- Generate AI Review (if not found)
- Use Microsoft.Extensions.AI abstractions with a configured preset for OpenRouter.
- Inject a strict system message requiring JSON output.
- Pass chat transcript as the user message.
- Send request via OpenRouter model using preset configuration.
- Capture raw response.
- Deserialize into strongly typed
ChatReviewResponse.
- Store AI review in the database
- Return the review to the requestor
Development Tasks & Estimates
| No | Task Name | Estimate (Hours) | Dependencies | Notes |
|---|---|---|---|---|
| 1 | Get Basic Chat data | 1 hours | ||
| 2 | Get Review data from Db | 1 hours | ||
| 3 | If not found get from AI endpoint using chat analysis and prechat data and save to DB | 6 hours | ||
| 4 | create a api who get review from openrouter using Microsoft.Extension.AI(also poc) | 16 hours | ||
| 5 | If found return | 30 min | ||
| 6 | Integration Testing | 2hr | ||
| 7 | Total | 20 hours |
Testing & Quality Assurance
(Outline the testing strategy and quality assurance measures for the feature.)
-
Unit Tests:
(List the unit tests that will be written for this feature.) -
Integration Tests:
Verify API response from AI service Ensure seamless database storage and retrieval -
Acceptance Criteria:
AI-generated reviews stored and retrieved correctly Accurate sentiment analysis and ratings -
Testing Tools:
(List any tools that will be used for testing.)
Deployment Considerations
- Configuration Changes:
CREATE TABLE tblChatReviewAI (
ChatId UNIQUEIDENTIFIER PRIMARY KEY,
SubscriberId UNIQUEIDENTIFIER NOT NULL,
Rating INT CHECK (Rating BETWEEN 1 AND 5),
CustomerSentiment NVARCHAR(100),
Insights NVARCHAR(MAX),
Logdts datetime
);
-- Stored Procedures:
CREATE PROCEDURE spSaveChatReviewAI AS BEGIN ... END;
CREATE PROCEDURE spGetChatReviewAI AS BEGIN ... END;
CREATE PROCEDURE spGetChatInfoById AS BEGIN ... END;
- Rollout Plan:
(Outline the plan for rolling out the feature, including any phased releases.)
Risks & Mitigations
(Identify potential risks and the strategies to mitigate them.)
| Risk | Impact | Likelihood | Mitigation Strategy |
|---|
Review & Approval
(Include a section for review and approval by stakeholders.)
-
Reviewer:
Rupanjan Hari, Ayon Das -
Approval Date:
2025-08-29
Notes
(Add any additional notes or considerations related to the feature development here.)