Skip to content

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:

  1. Intent Detection

    • Identifies the primary purpose of the conversation
    • Extracts key objectives from the dialogue
  2. Conversation Summary

    • Generates a concise summary of the entire interaction
    • Highlights key discussion points
  3. Category Classification

    • Classifies visitors into specific categories:
      • Immediate Buyer
      • Potential Buyer
      • Just Exploring
      • Facing Issue
      • Others
  4. Category Justification

    • Provides reasoning for the assigned category
    • Extracts supporting evidence from the conversation
  5. 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_log table)
    • 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

  1. Receive session completion webhook
  2. Validate session data
  3. Fetch complete transcript
  4. Generate analytics
  5. Process enabled integrations
  6. Send email notifications to visitor
  7. 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