Create a JSON file with the following content and save it as flow-definition.json. Refer to this Create Flow request syntax documentation to prepare the flow definition. Note: Alternatively, you can use the Amazon Bedrock console to create the flow based on your requirements in the visual builder. Once you've created the flow, you can use the get-flow CLI command to retrieve the flow definition. Replace the <region> and <account-id> with the actual values for Lambda ARN.
{
"connections": [
{
"configuration": {
"data": {
"sourceOutput": "document",
"targetInput": "codeHookInput"
}
},
"name": "FlowInputNodeFlowInputNode0ToLambdaFunctionNode_RetrieveRequestByIdLambdaFunctionNode0",
"source": "FlowInputNode",
"target": "LambdaFunctionNode_RetrieveRequestById",
"type": "Data"
},
{
"configuration": {
"data": {
"sourceOutput": "modelCompletion",
"targetInput": "document"
}
},
"name": "Prompt_SummarizeResultPromptsNode0ToFlowOutputNode_ItemsExistsFlowOutputNode0",
"source": "Prompt_SummarizeResult",
"target": "FlowOutputNode_ItemsExists",
"type": "Data"
},
{
"configuration": {
"data": {
"sourceOutput": "functionResponse",
"targetInput": "statusCode"
}
},
"name": "LambdaFunctionNode_RetrieveRequestByIdLambdaFunctionNode0ToConditionNode_CheckStatusCodeConditionNode0",
"source": "LambdaFunctionNode_RetrieveRequestById",
"target": "ConditionNode_CheckStatusCode",
"type": "Data"
},
{
"configuration": {
"conditional": {
"condition": "Condition"
}
},
"name": "ConditionNode_CheckStatusCodeConditionNodeHandle0ToFlowOutputNode_NoItemFoundFlowOutputNode_NoItemFoundHeaderHandle",
"source": "ConditionNode_CheckStatusCode",
"target": "FlowOutputNode_NoItemFound",
"type": "Conditional"
},
{
"configuration": {
"data": {
"sourceOutput": "functionResponse",
"targetInput": "document"
}
},
"name": "LambdaFunctionNode_RetrieveRequestByIdLambdaFunctionNode0ToFlowOutputNode_NoItemFoundFlowOutputNode0",
"source": "LambdaFunctionNode_RetrieveRequestById",
"target": "FlowOutputNode_NoItemFound",
"type": "Data"
},
{
"configuration": {
"conditional": {
"condition": "default"
}
},
"name": "ConditionNode_CheckStatusCodeConditionNodeHandleDefaultConditionNode_CheckStatusCodeToPrompt_SummarizeResultPrompt_SummarizeResultHeaderHandle",
"source": "ConditionNode_CheckStatusCode",
"target": "Prompt_SummarizeResult",
"type": "Conditional"
},
{
"configuration": {
"data": {
"sourceOutput": "functionResponse",
"targetInput": "functionResponse"
}
},
"name": "LambdaFunctionNode_RetrieveRequestByIdLambdaFunctionNode0ToPrompt_SummarizeResultPromptsNode0",
"source": "LambdaFunctionNode_RetrieveRequestById",
"target": "Prompt_SummarizeResult",
"type": "Data"
}
],
"nodes": [
{
"configuration": {
"input": {}
},
"name": "FlowInputNode",
"outputs": [
{
"name": "document",
"type": "Object"
}
],
"type": "Input"
},
{
"configuration": {
"output": {}
},
"inputs": [
{
"expression": "$.data",
"name": "document",
"type": "String"
}
],
"name": "FlowOutputNode_ItemsExists",
"type": "Output"
},
{
"configuration": {
"lambdaFunction": {
"lambdaArn": "arn:aws:lambda:<region>:<account-id:function:retrieve-request-by-id:$LATEST"
}
},
"inputs": [
{
"expression": "$.data.event",
"name": "codeHookInput",
"type": "Object"
}
],
"name": "LambdaFunctionNode_RetrieveRequestById",
"outputs": [
{
"name": "functionResponse",
"type": "Object"
}
],
"type": "LambdaFunction"
},
{
"configuration": {
"prompt": {
"sourceConfiguration": {
"inline": {
"additionalModelRequestFields": {
"top_k": 250.0
},
"inferenceConfiguration": {
"text": {
"maxTokens": 2000,
"stopSequences": [],
"temperature": 1.0,
"topP": 0.9990000128746033
}
},
"modelId": "anthropic.claude-3-5-sonnet-20240620-v1:0",
"templateConfiguration": {
"text": {
"inputVariables": [
{
"name": "functionResponse"
}
],
"text": "You are an assistant that summarizes request details for users. Please take the following JSON response, which contains details about a SharePoint site access request, and format it in a user-friendly summary.\n\nJSON Data:\n{{functionResponse}}\n\nYour task:\n1. Summarize the SharePoint site access request by extracting the key details such as:\n - Request Title\n - Request ID\n - Requester's Name and Email\n - Approver's Name and Email\n - Status of the request\n - Comments provided by the requester\n - Business Justification\n - Site URL\n - Created Date and Modified Date\n\n2. Provide the summary in a well-structured format with a human-friendly tone.\n\nYour output should look like this:\n\nSummary:\nRequest Title: [Title]\nRequest ID: [RequestId]\nRequester: [Requester Name] ([Requester Email])\nApprover: [Approver Name] ([Approver Email])\nStatus: [Status]\nComments: [Comments]\nBusiness Justification: [Business Justification]\nSite URL: [Site URL]\nCreated Date: [Created Date]\nModified Date: [Modified Date]\n\nDon't include any other text.\n"
}
},
"templateType": "TEXT"
}
}
}
},
"inputs": [
{
"expression": "$.data",
"name": "functionResponse",
"type": "Object"
}
],
"name": "Prompt_SummarizeResult",
"outputs": [
{
"name": "modelCompletion",
"type": "String"
}
],
"type": "Prompt"
},
{
"configuration": {
"condition": {
"conditions": [
{
"expression": "(statusCode == 404)",
"name": "Condition"
},
{
"name": "default"
}
]
}
},
"inputs": [
{
"expression": "$.data.statusCode",
"name": "statusCode",
"type": "Number"
}
],
"name": "ConditionNode_CheckStatusCode",
"type": "Condition"
},
{
"configuration": {
"output": {}
},
"inputs": [
{
"expression": "$.data.body",
"name": "document",
"type": "String"
}
],
"name": "FlowOutputNode_NoItemFound",
"type": "Output"
}
]
}