I tried calling a flow module from Amazon Connect Customer AI Agent's manual search and searching for reservation information with Lambda
This page has been translated by machine translation. View original
Introduction
With Amazon Connect Customer AI Agents, operators can make inquiries in natural language from the agent workspace to check information needed for customer support.
This time, we tested a configuration where operators enter a name and phone number collected from a customer to check reservation information.
Reservation information is retrieved by calling a Lambda function from a flow module tool in the AI Agent. The AI Agent responds to operators with the reservation date, time, number of people, and other details returned by the Lambda function.
The following items were verified:
- Operators manually request reservation confirmation from the agent workspace
- The AI Agent confirms the name and phone number with the operator
- A Lambda function is called from the flow module tool
- The return value of the Lambda function is returned as the output of the flow module
- Tool instruction text and response examples are configured to include reservation details in responses
- Both the AI Agent and the logged-in user are configured with access to the flow module
The manual search referred to in this article means the operation where an operator directly queries the AI Agent from the Connect Assistant in the agent workspace.
ORCHESTRATION is specified as the AI Agent type, which allows the use of flow module tools. The ORCHESTRATION type supports multi-turn interactions and the invocation of pre-configured tools.
Prerequisites
The following prerequisites apply to this article.
- An Amazon Connect Customer instance has been created
- Amazon Connect Customer AI Agents are available
- The verification region is
ap-northeast-1 - A Lambda function has been added to the Amazon Connect Customer instance
- Basic creation procedures for AI Agents, flow modules, and security profiles are understood
Resource names and reservation information in this article are values used for verification purposes. When using this in practice, replace them with values appropriate for your own environment.
Configuration and Process Flow
The process flow for this configuration is as follows.
Receive a reservation confirmation request from a customer
↓
Operator requests reservation confirmation from Connect Assistant
↓
AI Agent confirms name and phone number
↓
Call the Reservation_Confirmation tool
↓
Execute AgentAssistanceOrchestrator_ConfirmReservation-module
↓
Lambda function searches for reservation information matching the name and phone number
↓
Return the search result as json_result
↓
AI Agent responds to the operator with the reservation information
It is the operator logged into the agent workspace, not the customer, who interacts directly with the AI Agent.
The operator collects the name and phone number during a call with the customer and enters that information into the Connect Assistant.
Contact Flow
The following is the contact flow used in this verification.

A contact flow that configures recording and analytics for voice and chat, enables Connect Assistant, and transfers to a queue
The contact flow primarily performs the following.
- Enables flow logging
- Configures the voice to use for text-to-speech
- Branches based on
CHATandVOICE - Configures recording and analytics behavior according to the channel
- Configures the Connect Assistant block
- Sets the queue and transfers
The Connect Assistant block specifies the assistant that manages the association with the AI Agent.
This article focuses on the configuration of the Lambda function, flow module, and AI Agent for reservation confirmation, rather than the entire contact flow.
Creating the Lambda Function
First, create a Lambda function to search for reservation information.
In this case, we created a mock function that holds simulated reservation data within the Lambda function and returns records where both the name and phone number match.
import json
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
MOCK_DATABASE = [
{
"phone_number": "09012345678",
"customer_name": "山田太郎",
"reservation_id": "RES-1001",
"date": "2026-03-15",
"time": "14:00",
"number_of_people": 4,
"status": "Confirmed"
},
{
"phone_number": "08098765432",
"customer_name": "鈴木花子",
"reservation_id": "RES-1002",
"date": "2026-03-16",
"time": "10:30",
"number_of_people": 2,
"status": "Pending"
}
]
def normalize(text):
if not text:
return ""
return (
str(text)
.replace(" ", "")
.replace(" ", "")
.replace("-", "")
)
def lambda_handler(event, context):
logger.info(
"Received event: %s",
json.dumps(event, ensure_ascii=False)
)
params = event.get("Details", {}).get("Parameters", {})
input_phone = (
params.get("phone_number")
or event.get("phone_number")
)
input_name = (
params.get("customer_name")
or event.get("customer_name")
)
logger.info(
"Input(Raw): Name=%s, Phone=%s",
input_name,
input_phone
)
found_reservation = None
if input_phone and input_name:
target_phone = normalize(input_phone)
target_name = normalize(input_name)
logger.info(
"Input(Normalized): Name=%s, Phone=%s",
target_name,
target_phone
)
for record in MOCK_DATABASE:
if (
record["phone_number"] == target_phone
and record["customer_name"] == target_name
):
found_reservation = record
break
if found_reservation:
logger.info(
"Reservation found: %s",
found_reservation["reservation_id"]
)
return {
"json_result": json.dumps(
found_reservation,
ensure_ascii=False
)
}
logger.info("Reservation not found.")
not_found_data = {
"status": "NotFound",
"message": "予約が見つかりませんでした。"
}
return {
"json_result": json.dumps(
not_found_data,
ensure_ascii=False
)
}
The main processes are as follows.
- Retrieve
phone_numberandcustomer_namefromevent.Details.Parameters - Normalize input values by removing half-width spaces, full-width spaces, and hyphens
- Search for a reservation where both the name and phone number match
- Convert the search result to a JSON string and return it stored in
json_result - If no reservation is found, return a JSON string indicating
NotFound
Input parameters added from the AWS Lambda function block in Amazon Connect Customer can be retrieved from event.Details.Parameters in the Lambda function.
Normalizing Input Values
Phone numbers may be entered in the following formats.
09012345678
090-1234-5678
090 1234 5678
Names may also contain half-width or full-width spaces.
Therefore, normalize removes the following before comparing.
- Half-width spaces
- Full-width spaces
- Hyphens
In the Lambda function logs verified this time, the name passed from the flow module was recorded correctly in Japanese.
Input(Raw): Name=山田太郎, Phone=09012345678
Input(Normalized): Name=山田太郎, Phone=09012345678
Reservation found: RES-1001
There was no character corruption when the Lambda function received the data, and it matched 山田太郎 in the simulated data. Therefore, no character encoding conversion processing was added.
json_result When a Reservation Is Found
When a reservation for Taro Yamada is found, the Lambda function returns the following value.
{
"json_result": "{\"phone_number\": \"09012345678\", \"customer_name\": \"山田太郎\", \"reservation_id\": \"RES-1001\", \"date\": \"2026-03-15\", \"time\": \"14:00\", \"number_of_people\": 4, \"status\": \"Confirmed\"}"
}
The type of json_result in the outer object is a string.
When the string stored in json_result is formatted as JSON, it contains the following.
{
"phone_number": "09012345678",
"customer_name": "山田太郎",
"reservation_id": "RES-1001",
"date": "2026-03-15",
"time": "14:00",
"number_of_people": 4,
"status": "Confirmed"
}
In the outer JSON, double quotes contained in the value of json_result are displayed as \".
json_result When No Reservation Is Found
When no reservation is found, the following value is returned.
{
"json_result": "{\"status\": \"NotFound\", \"message\": \"予約が見つかりませんでした。\"}"
}
The content stored in json_result is as follows.
{
"status": "NotFound",
"message": "予約が見つかりませんでした。"
}
The fact that no reservation was found is not treated as a Lambda function execution error.
By returning NotFound as a normal response, the AI Agent can check the tool execution result and respond to the operator that no reservation was found.
Reason for Returning as a JSON String
In this verification, STRING_MAP is specified for response validation in the AWS Lambda function block of the flow module.
When STRING_MAP is specified, the Lambda function response must be a flat object consisting of string-type key-value pairs. When JSON is specified, a valid JSON including nested structures can be returned.
Since the reservation information is handled as a single string value in this case, the entire reservation information was converted to a JSON string using json.dumps and stored in json_result.
In this verification, the reservation information returned in this format was handled as the output of the flow module, and the AI Agent was able to respond with it.
Creating the Flow Module
Next, create the flow module to be called from the AI Agent.
The flow module created this time is as follows.
AgentAssistanceOrchestrator_ConfirmReservation-module
Flow modules can be created as tools that can be called independently from outside a flow. Additionally, AWS Lambda function blocks can be used in flow modules for tools.
Input/Output Schema
The input schema and output schema for this verification are as follows.
{
"input": {
"schema": {
"type": "object",
"properties": {
"phone_number": {
"type": "string"
},
"customer_name": {
"type": "string"
}
},
"required": [
"phone_number",
"customer_name"
]
}
},
"resultData": {
"schema": {
"type": "object",
"properties": {
"json_result": {
"type": "string"
}
},
"required": [
"json_result"
]
}
}
}
The purpose of inputs and outputs is as follows.
| Type | Property | Purpose |
|---|---|---|
| Input | phone_number |
Phone number collected from the customer |
| Input | customer_name |
Name collected from the customer |
| Output | json_result |
JSON string of reservation information returned by the Lambda function |
These input and output schemas are also displayed as arguments and outputs in the AI Agent's tool, described later.
Passing Module Input to the Lambda Function
In the AWS Lambda function block, the flow module's input is passed to the Lambda function.
The configuration is as follows.
| Destination Key | Namespace | Key | Parameter |
|---|---|---|---|
phone_number |
Module | Input | phone_number |
customer_name |
Module | Input | customer_name |

Screen for configuring the flow module's phone_number and customer_name as input parameters for the Lambda function
In JSONPath, these correspond to the following values.
$.Modules.Input.phone_number
$.Modules.Input.customer_name
The AWS Lambda function block was set to synchronous execution, and STRING_MAP was specified for response validation.
With this configuration, the Lambda function's event contains input like the following.
{
"Details": {
"Parameters": {
"phone_number": "09012345678",
"customer_name": "山田太郎"
}
}
}
Setting the Lambda Function Return Value as Module Output
The return value of the Lambda function can be referenced from blocks after the AWS Lambda function block using the $.External namespace.
In the Return block, the json_result returned by the Lambda function was set as the output of the flow module.
Module output: json_result
Set value: $.External.json_result

Screen for setting the json_result returned by the Lambda function as the flow module output
For example, suppose the Lambda function returns the following value.
{
"json_result": "{\"customer_name\":\"山田太郎\",\"date\":\"2026-03-15\",\"time\":\"14:00\",\"number_of_people\":4}"
}
In this case, the string accessible from $.External.json_result is as follows.
{"customer_name":"山田太郎","date":"2026-03-15","time":"14:00","number_of_people":4}
In the Return block, this string is returned as the json_result of the flow module.
Even when no reservation is found, the Lambda function completes normally, so the json_result containing NotFound is returned through the same path.
Lambda function call failures or timeouts are treated as AWS Lambda function block errors, unlike cases where no reservation is found.
Creating a Version of the Flow Module
After configuring the flow module, create a version to be specified in the AI Agent's tool.
The following version was used in this verification.
Version 3
If the flow module is updated, also check the version referenced by the tool.
Configuring the AI Agent
The AI Agent created this time is as follows.
AgentAssistanceOrchestrator_ConfirmReservation
ORCHESTRATION was specified as the AI Agent type.
Operators manually request reservation confirmation from the Connect Assistant. After the AI Agent confirms the required name and phone number with the operator, it calls the flow module tool.

Screen showing the Reservation_Confirmation tool added to an ORCHESTRATION type AI Agent
The main settings for this verification are as follows.
| Item | Setting Value |
|---|---|
| Name | AgentAssistanceOrchestrator_ConfirmReservation |
| Agent Type | ORCHESTRATION |
| Locale | Japanese |
| Security Profile | AI Agent |
| Tool | Reservation_Confirmation |
| Prompt | AgentAssistanceOrchestration |
In this verification, the default AgentAssistanceOrchestration prompt was used as-is, and no custom AI prompt was created.
Adding a Flow Module Tool
The following tool was added to the AI Agent.
Reservation_Confirmation
In the tool, specify the flow module and version created earlier.
Namespace:
Flow Modules
AI Tool:
AgentAssistanceOrchestrator_ConfirmReservation-module
Version:
Version 3

Editing screen for the Reservation_Confirmation tool with the flow module and version specified
On the screen, you can confirm the input and output schemas defined in the flow module.
The correspondence between the flow module and tool is as follows.
| Flow Module | AI Agent Tool |
|---|---|
Input schema phone_number |
Tool argument phone_number |
Input schema customer_name |
Tool argument customer_name |
Output schema json_result |
Tool output json_result |
Instruction Text
The instruction text for the tool was set as follows.
Searches for reservation information using the customer's name and phone number.
Be sure to convey the "date", "time", and "number_of_people" returned in the execution result.
In addition to the tool's purpose, the items to include in the response from the execution result are specified.
Response Examples
Response examples were configured for when a reservation is found and when it is not found.
The good example for when a reservation is found is as follows.
<message>
山田太郎様ですね、確認いたしました。
2026年3月15日の14時から、4名様でご予約を承っております。
</message>
The good example for when no reservation is found is as follows.
<message>
申し訳ございません。いただいたお名前とお電話番号では、ご予約情報が見つかりませんでした。
恐れ入りますが、情報にお間違いがないかもう一度ご確認いただけますでしょうか?
</message>
Responses that do not include specific content from the search results were set as bad examples.
<message>
ご予約を確認いたしました。完了しました。他にお手伝いできることはありますか?
</message>
In this verification, the instruction text specified that the date, time, and number of people should be included in the response, and the response examples showed the expected response format.
After configuration, it was confirmed that the specified items were included in the reservation confirmation results in the responses.
Configuring Security Profiles
To use a flow module tool, configure access to the target flow module in the security profile assigned to the AI Agent.
In this verification, the following flow module was selected in the security profile for the AI Agent.
AgentAssistanceOrchestrator_ConfirmReservation-module

Screen showing access to the reservation confirmation flow module selected in the security profile for the AI Agent
When using tools with agent assistance, the logged-in user's security profile also needs the same permissions as the tools used by the AI Agent.
Tool invocation is authorized by combining the permissions of the AI Agent and the logged-in user. If the logged-in user's permissions are insufficient, the tool invocation will fail even if the AI Agent has the permissions.
Therefore, access to the same flow module was also configured in the security profile assigned to the logged-in user.

Screen showing access to the reservation confirmation flow module configured in the logged-in user's security profile
In this verification, when only the AI Agent side had access to the flow module configured, the tool could not be executed successfully.
After configuring access to the same flow module on the logged-in user's side as well, the tool execution succeeded.
Operation Verification
After configuration, an operator receiving a voice inquiry confirmed a reservation from the Connect Assistant in the agent workspace.
The operator enters the information collected during the conversation with the customer into the Connect Assistant.
The exchange was as follows.
[Operator]
I want to confirm a reservation.
[AI Agent]
Understood. I will confirm your reservation.
Could you please provide me with the customer's name and phone number?
[Operator]
It's Taro Yamada. The phone number is 09012345678.
[AI Agent]
I will confirm the reservation for Taro Yamada with phone number 09012345678.
Please wait a moment.
Rather than the operator entering the name and phone number all at once from the beginning, the AI Agent confirmed the items required for the reservation check additionally.
Tool Invocation Content
In the AI Agent's trace, the Reservation_Confirmation tool was called with the following arguments.
{
"type": "tool_use",
"name": "Reservation_Confirmation",
"arguments": {
"customer_name": "山田太郎",
"phone_number": "09012345678"
}
}
customer_name and phone_number match the property names defined in the flow module's input schema.
Lambda Function Logs
The following content was confirmed in the Lambda function logs.
Received event:
"Parameters": {
"phone_number": "09012345678",
"customer_name": "山田太郎"
}
Input(Raw): Name=山田太郎, Phone=09012345678
Input(Normalized): Name=山田太郎, Phone=09012345678
Reservation found: RES-1001
The Lambda function retrieved the name and phone number passed from the flow module and was able to match them against a reservation in the simulated data.
Tool Return Value
The tool return value is as follows. It has been formatted for readability.
{
"json_result": "{\"phone_number\": \"09012345678\", \"customer_name\": \"山田太郎\", \"reservation_id\": \"RES-1001\", \"date\": \"2026-03-15\", \"time\": \"14:00\", \"number_of_people\": 4, \"status\": \"Confirmed\"}"
}
The reservation information converted to a JSON string in the Lambda function is returned to the AI Agent via the flow module's json_result.
AI Agent Response
The final response from the AI Agent was as follows.
[AI Agent]
Taro Yamada, I have confirmed your reservation.
You have a reservation for 4 people at 14:00 on March 15, 2026.
Your reservation number is RES-1001.
Is there anything else I can help you with?

Screen showing successful tool execution after correcting the logged-in user's permissions and flow module configuration
The following items specified in the tool's instruction text are included in the AI Agent's response.
- Date: March 15, 2026
- Time: 14:00
- Number of people: 4
Additionally, the reservation number, which was not specified as a required item, was also added to the response based on the value included in json_result.
In this verification, the operator requested reservation confirmation from the Connect Assistant, the AI Agent confirmed the required name and phone number, then called the flow module tool and was able to respond with the reservation information.
Summary
We tested a configuration with Amazon Connect Customer AI Agent assistance where operators perform manual searches and retrieve Lambda function reservation information via a flow module.
The key points from this verification are as follows.
- The input and output schemas of the flow module were treated as the arguments and outputs of the AI Agent tool
- By converting reservation information to a JSON string in the Lambda function and returning it as
json_result, the AI Agent was able to respond with it - To execute tools with agent assistance, both the AI Agent and the logged-in user needed access to the flow module
When using flow module tools, it seems advisable to also verify the tool's instruction text, response examples, and the security profiles of both parties, in addition to the Lambda function and flow module configurations.
