Follow-Up Request
Event representing a request to send a follow-up message for a conversation
Event Channel:AWS SQS
Overview
The Follow-Up Request event represents a request to send an automated follow-up message for a conversation. This event is published to the Follow-Up Queue and consumed by the Follow-Up Processor.
Payload
The payload follows the FollowUpPayload schema:
{ "id": "string" // Conversation ID}Schema Definition
const FollowUpPayloadSchema = z.object({ id: z.string() // Conversation ID});Producing the Event
Follow-up requests are published to the Follow-Up Queue by:
- Scheduled Lambda Functions: Cron jobs that check for conversations needing follow-ups
- Message Service: When a conversation meets follow-up criteria
- Follow-Up Service: When manually scheduling follow-ups
import { SQSClient } from './clients/sqs-client';
const sqsClient = new SQSClient();
await sqsClient.sendMessage({ id: "conversation-123"}, 'follow_up');Consuming the Event
The event is consumed by the followUpProcessor Lambda function:
export const handler = async (event: SQSEvent): Promise<SQSBatchResponse> => { return sqsBatchProcessor<FollowUpPayload>({ schema: FollowUpPayloadSchema, processPayload: processFollowUp, shouldRetry: (error) => { if (error instanceof FollowUpError) { return error.shouldRetry; } return true; }, })(event);};Processing Flow
- Conversation ID is extracted from payload
- Conversation is loaded and validated
- Business rules are checked (status, tenant config, appointments, etc.)
- Customer and conversation history are loaded
- AI chatbot generates follow-up message
- Follow-up message is sent via WhatsApp
Business Rules
Follow-up messages are only sent when:
- Conversation status is “open”
- Tenant has APPOINTMENTS module enabled
- Tenant has follow-up feature enabled
- Customer has no existing appointments
- Channel is active or sender is in test senders list
Event-driven architecture documentation: Impulsell