Post Session API Overview
The Post Session API is an internal service responsible for executing various post-conversation tasks after a session (voice or text) concludes with the AI agent. This service operates behind API Gateway, processing sessions asynchronously to ensure smooth user experiences.
Core Responsibilities
Session Processing
- Receives session completion notifications from AI Engine
- Retrieves and processes conversation transcripts from the database
- Handles both voice calls and text chat sessions uniformly
- Generates conversation analytics using Amazon Bedrock
Analytics Generation
flowchart TD
A[Session Completed] --> B[Fetch Transcript]
B --> C[Process with Bedrock]
C --> D[Generate Analytics]
D --> E[Store Results]
subgraph "Analytics Metrics"
I[Intent Detection]
S[Conversation Summary]
C[Category Classification]
CJ[Category Justification]
AS[Average Sentiment]
DS[Detailed Sentiment Analysis]
end
D --> I
D --> S
D --> C
D --> CJ
D --> AS
D --> DS
subgraph "Category Types"
C1[Immediate Buyer]
C2[Potential Buyer]
C3[Just Exploring]
C4[Facing Issue]
C5[Others]
end
C --> C1
C --> C2
C --> C3
C --> C4
C --> C5
The service processes conversations to extract several key analytics using Amazon Bedrock:
-
Intent Detection
- Identifies the primary purpose of the conversation
- Extracts key objectives from the dialogue
-
Conversation Summary
- Generates a concise summary of the entire interaction
- Highlights key discussion points
-
Category Classification
- Classifies visitors into specific categories:
- Immediate Buyer
- Potential Buyer
- Just Exploring
- Facing Issue
- Others
- Classifies visitors into specific categories:
-
Category Justification
- Provides reasoning for the assigned category
- Extracts supporting evidence from the conversation
-
Sentiment Analysis
- Average sentiment score for the entire conversation
- Detailed sentiment tracking throughout the interaction
- Identifies emotional patterns and changes
Communication Flow
Email Notifications
- Configurable email sending via Amazon SES
- Customizable email templates
- Conditional sending based on admin settings
- Tracking of email delivery status
- Comprehensive email logging in database (
email_logtable)- Delivery status tracking
- Timestamp logging
- Recipient information
- Template used
sequenceDiagram
participant AI as AI Engine
participant PS as Post Session API
participant DB as Database
participant SES as Amazon SES
participant CRM as Third-party CRM
AI->>PS: Session Completion Notice
PS->>DB: Fetch Session Data
PS->>PS: Process Analytics
alt Email Enabled
PS->>SES: Send Email to Visitor
SES-->>PS: Delivery Status
end
alt CRM Integration Active
PS->>CRM: Sync Session Data
CRM-->>PS: Sync Status
end
PS->>DB: Update Session Records
Integration Features
Third-Party Integrations
- CRM data synchronization (e.g., HubSpot, Salesforce)
- Hubspot usecase currently implemented:
- The visitor who had the conversation is synced with Hubspot CRM and the conversation analytics are added to that CRM contact as notes.
- New conversations had by the visitor under the same email will get appended on the same CRM contact.
- Custom webhook support
Analytics Processing
- Sentiment analysis of conversations
- Topic classification
- Key insights extraction
- Action item identification
- Custom metrics generation
- Error handling and retry mechanisms (max 3/5 times if LLM fails to generate analytics)
Technical Implementation
Session Processing Flow
- Receive session completion webhook
- Validate session data
- Fetch complete transcript
- Generate analytics
- Process enabled integrations
- Send email notifications to visitor
- Update session records
Error Handling
- Retry mechanism for failed operations
- Error logging and monitoring
Configuration Options
Email Settings
- Template customization
- Trigger conditions (enabled/disabled toggle)
- Sender configuration
- Attachment options
- Email logging preferences
- Log retention period
- Logging detail level
- Error notification thresholds