Skip to main content
Version: ChatLead

Chat Review Using AI

Author(s)

  • Reshmi Karan
  • ...

Last Updated Date

2025-08-27


SRS References


Version History

VersionDateChangesAuthor
1.02025-03-31Initial draftReshmi Karan
2.02025-08-27Implement Get Review using openrouter SDKReshmi 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

  1. Retrieve Chat Information

Fetch chat details, including transcript and metadata.

  1. Retrieve Existing Chat Review

Query the database for an existing review based on the chat ID.

If found, return the stored review.

  1. 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.

  1. Store AI-Generated Review

Save the AI-generated review, rating, and insights in the database.

  1. 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:

    EndpointMethodParametersResponseResponse Status Codes
    /api/SubscriberAnalytics/ChatReviewFromAIGETchatId (Guid),subId(Guid)ChatReviewResponse200, 204, 500
    api/chat/analyze-chat-reviewPOSTchatTranscript (string)ChatReviewResponse200, 204, 500
  • Third-Party Integrations:
    (OpenRouter via SDK, integrated using Microsoft.Extensions.AI with preset-based configuration)

  • Workflow:

    1. Retrieve chat details
    2. Check for Existing Review in the database
    3. 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.
    1. Store AI review in the database
    2. Return the review to the requestor

Development Tasks & Estimates

NoTask NameEstimate (Hours)DependenciesNotes
1Get Basic Chat data1 hours
2Get Review data from Db1 hours
3If not found get from AI endpoint using chat analysis and prechat data and save to DB6 hours
4create a api who get review from openrouter using Microsoft.Extension.AI(also poc)16 hours
5If found return30 min
6Integration Testing2hr
7Total20 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.)

RiskImpactLikelihoodMitigation 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.)