What are the four main sections of a Lambda function?
What does the imports section of a Lambda do?
Brings in libraries and SDKs like json - os - boto3 - difflib - re
What does the clients section of a Lambda do?
Creates connections to AWS services like dynamodb = boto3.client(‘dynamodb’) and bedrock_runtime = boto3.client(‘bedrock-runtime’)
What does the helper functions section of a Lambda do?
Contains reusable logic that the handler calls - like get_ddb_entry() - classify_intent_bedrock() - extract_extension_number()
What does the handler section of a Lambda do?
Entry point that auto-runs when Lambda is triggered - orchestrates helper functions and returns results
What is the handler function signature?
def lambda_handler(event - context) - event contains input data - context contains runtime info
What triggers the ivr-router Lambda?
Lex invokes it when a caller speaks - AWS automatically calls lambda_handler
What does ivr-router receive in the event object?
inputTranscript (what caller said) - sessionState - sessionAttributes including PhoneNumber and Language
What is the order of operations in ivr-router handler?
What are the helper functions in ivr-router?
get_ddb_entry - get_bedrock_response - classify_intent_bedrock - extract_extension_number - extract_name - simple_match_utterance - _respond
What does get_ddb_entry() do?
Queries DynamoDB using phone number (DNIS) to get that LOB’s configured intents
What does simple_match_utterance() do?
Fuzzy matches the caller’s transcript against configured utterances in DynamoDB
What does classify_intent_bedrock() do?
Uses Claude/Bedrock to classify the intent if fuzzy matching fails
What does extract_extension_number() do?
Parses the transcript to find extension numbers like “extension 123” or “dial 500”
What does extract_name() do?
Parses the transcript to find names like “connect me to John Smith”
What does _respond() do?
Formats the return object with session attributes (action - QueueArn - Response - label)
What does ivr-router return to Lex?
Session attributes dictionary containing action - QueueArn - Response - PhoneNumber - InfoPrompt - ModuleArn - label
Why are clients defined outside the handler?
Performance - they’re initialized once when Lambda cold starts - reused across invocations
What is a Lambda cold start?
First invocation when AWS spins up new container - imports and clients run once - subsequent calls reuse them
What happens if get_ddb_entry() returns nothing?
Lambda falls back to default behavior - returns NoMatch action