Lambda_Structure_Flashcards

(20 cards)

1
Q

What are the four main sections of a Lambda function?

A
  1. Imports (libraries/SDKs) 2. Clients (AWS service connections) 3. Helper Functions (reusable logic) 4. Handler (entry point that auto-runs)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the imports section of a Lambda do?

A

Brings in libraries and SDKs like json - os - boto3 - difflib - re

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the clients section of a Lambda do?

A

Creates connections to AWS services like dynamodb = boto3.client(‘dynamodb’) and bedrock_runtime = boto3.client(‘bedrock-runtime’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the helper functions section of a Lambda do?

A

Contains reusable logic that the handler calls - like get_ddb_entry() - classify_intent_bedrock() - extract_extension_number()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the handler section of a Lambda do?

A

Entry point that auto-runs when Lambda is triggered - orchestrates helper functions and returns results

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the handler function signature?

A

def lambda_handler(event - context) - event contains input data - context contains runtime info

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What triggers the ivr-router Lambda?

A

Lex invokes it when a caller speaks - AWS automatically calls lambda_handler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does ivr-router receive in the event object?

A

inputTranscript (what caller said) - sessionState - sessionAttributes including PhoneNumber and Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the order of operations in ivr-router handler?

A
  1. Get transcript from event 2. Query DynamoDB for LOB intents 3. Try to match utterance 4. Return session attributes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the helper functions in ivr-router?

A

get_ddb_entry - get_bedrock_response - classify_intent_bedrock - extract_extension_number - extract_name - simple_match_utterance - _respond

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does get_ddb_entry() do?

A

Queries DynamoDB using phone number (DNIS) to get that LOB’s configured intents

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does simple_match_utterance() do?

A

Fuzzy matches the caller’s transcript against configured utterances in DynamoDB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does classify_intent_bedrock() do?

A

Uses Claude/Bedrock to classify the intent if fuzzy matching fails

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does extract_extension_number() do?

A

Parses the transcript to find extension numbers like “extension 123” or “dial 500”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does extract_name() do?

A

Parses the transcript to find names like “connect me to John Smith”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does _respond() do?

A

Formats the return object with session attributes (action - QueueArn - Response - label)

17
Q

What does ivr-router return to Lex?

A

Session attributes dictionary containing action - QueueArn - Response - PhoneNumber - InfoPrompt - ModuleArn - label

18
Q

Why are clients defined outside the handler?

A

Performance - they’re initialized once when Lambda cold starts - reused across invocations

19
Q

What is a Lambda cold start?

A

First invocation when AWS spins up new container - imports and clients run once - subsequent calls reuse them

20
Q

What happens if get_ddb_entry() returns nothing?

A

Lambda falls back to default behavior - returns NoMatch action