{"id":18695790,"url":"https://github.com/docwho2/java-connect-lex-chatgpt","last_synced_at":"2026-03-12T05:41:20.285Z","repository":{"id":171989197,"uuid":"643671812","full_name":"docwho2/java-connect-lex-chatgpt","owner":"docwho2","description":"Amazon Connect Multi-Lingual ChatGPT Voice Bot via AWS Lex written in Java","archived":false,"fork":false,"pushed_at":"2025-11-27T12:30:48.000Z","size":4247,"stargazers_count":12,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-11-27T22:51:46.614Z","etag":null,"topics":["amazon-connect","aws-cloudformation","aws-dynamodb","aws-lambda-java","aws-lex","aws-sam","aws-serverless-application-model","chatbot","chatgpt","java-21","multilingual","openai-chatgpt","serverless","spanish","voice-assistant","voice-bot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/docwho2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-05-21T22:20:23.000Z","updated_at":"2025-11-27T12:30:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"8db75d83-1e86-4db3-9b8b-b55ac2894a70","html_url":"https://github.com/docwho2/java-connect-lex-chatgpt","commit_stats":null,"previous_names":["docwho2/java-connect-lex-chatgpt"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/docwho2/java-connect-lex-chatgpt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docwho2%2Fjava-connect-lex-chatgpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docwho2%2Fjava-connect-lex-chatgpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docwho2%2Fjava-connect-lex-chatgpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docwho2%2Fjava-connect-lex-chatgpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/docwho2","download_url":"https://codeload.github.com/docwho2/java-connect-lex-chatgpt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docwho2%2Fjava-connect-lex-chatgpt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30416356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T04:41:02.746Z","status":"ssl_error","status_checked_at":"2026-03-12T04:40:12.571Z","response_time":114,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon-connect","aws-cloudformation","aws-dynamodb","aws-lambda-java","aws-lex","aws-sam","aws-serverless-application-model","chatbot","chatgpt","java-21","multilingual","openai-chatgpt","serverless","spanish","voice-assistant","voice-bot"],"created_at":"2024-11-07T11:16:14.207Z","updated_at":"2026-03-12T05:41:20.273Z","avatar_url":"https://github.com/docwho2.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Amazon Connect ChatGPT Voice Bot via Lex\n\nIf you're looking for a more advanced use case of [OpenAI ChatGPT](https://openai.com/product/chatgpt) via voice interface, please also see [Amazon Chime SMA Spring AI IVR for Square Retail](https://github.com/docwho2/java-squareup-spring-ai-ivr).\n\n\n## Background\n\nThis project demonstrates an integration of [Amazon Connect](https://aws.amazon.com/pm/connect/) to [OpenAI ChatGPT](https://openai.com/product/chatgpt) in both English and Spanish via \nan [AWS Lex Bot](https://aws.amazon.com/pm/lex/).  There are some examples available in NodeJS and Python that demonstrate a basic integration with some screen shots, but there isn't a fully working example (with chat context) \nthat can be easily deployed via CloudFormation, including the call flow itself and the glue to bring it together with minimal console interaction.\n\nThe basic strategy is to deploy a normal LexV2 Bot with intents to handle a couple cases (like help, talk to someone, and hanging up on the caller) and use the \n[AMAZON.FallbackIntent](https://docs.aws.amazon.com/lexv2/latest/dg/built-in-intent-fallback.html) with a [Lambda CodeHook](https://docs.aws.amazon.com/lexv2/latest/dg/paths-code-hook.html) \nto send requests to ChatGPT and also maintain the Chat session so you can interact just like the web client.  For example, you can ask \"What is the biggest lake in MN\", then subsequently \nyou ask \"how deep is it\".  Because all your prompts are saved to a [Dynamo DB Table](https://aws.amazon.com/dynamodb/) as you interact, the context is maintained and ChatGPT knows the \ncontext of each question.  The project uses your callerID and today's date for session context.  So, you can ask a question, hang up, call back, and ChatGPT will still have the context \nof what you said in the prior call.  When you call the next day, you are starting with a fresh context.\n\nBecause tearing down and building Connect instances is rate-limited and can lock you out for 30 days, you will need to pass in an instance ID of an existing Amazon Connect instance to deploy \nthis project.  You will also need to allocate a phone number and associate it with the created call flow.  You can, of course, use an existing phone number in your instance and temporarily point \nit at the \"connect-chatgpt-gptflow\".  If you are deploying this, the assumption would be that you are familiar enough with Amazon Connect to bring up an instance and allocate a phone number or you \nalready have an existing instance.  You will also need an [OpenAI API key](https://platform.openai.com/account/api-keys) saved to [Parameter Store](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html) \n(OPENAI_API_KEY is the default in the template).\n\n\nOther features:\n- Use of [Static Prompts](https://docs.aws.amazon.com/connect/latest/adminguide/setup-prompts-s3.html) defined in the CloudFormation itself.  \n  Polly is fast inside Connect, but static prompts from S3 will provide lower latency for playback.\n- Background lookup of call data that doesn't block the call flow waiting on a result.\n- Multilingual support.  Spanish and English are supported, but another language supported by Lex and ChatGPT should be easy to implement.\n- Lex Intents:\n  - About/Help - A static prompt that describes the project.\n  - Transfer - Transfer the call to a person (or mention the first name configured in the template).\n  - Hang Up - Play a goodbye prompt and terminate the call when caller indicates they are done.\n\n\nOther goals of the project (technical focus):\n- SAM CloudFormation for all the components in play (`sam build` and then `sam deploy`) for simple deployment of the project.\n- Use of the to-be-released [V4 Java Event Objects](https://github.com/aws/aws-lambda-java-libs/tree/85837fa301a83f89bbb09683c35aa5df1077b7d4) instead of dealing with raw JSON for LexV2 Events.\n- Use of the [Dynamo DB Enhanced client](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/ddb-en-client-doc-api.html) to save Java objects.\n- Generate prompts with Polly and use SOX to convert them in a Lambda (a project in and of itself!).\n- Use of [SnapStart](https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html) to reduce latency (which is important for a voice interface) on Lambda Functions.\n- Dynamic creation of the Connect Flow based on CloudFormation.\n- To simply provide a fully working example in Java using the best available API's:\n  - [openai-java](https://github.com/TheoKanning/openai-java)\n\n## Architecture\n\n### High Level Components\n![Architecture Diagram](assets/arch.jpg)\n\n### CloudFormation Resources\n![Resource Diagram](assets/resources.png)\n\n### Call Flow\n![Call Flow](assets/flow.png)\n\n### Initial Call to Lambda\nWhen the call arrives at the Connect Call Flow we call a Lambda Function:\n- This lambda function simply takes the Connect Event payload and puts it onto an SNS Topic.\n- This is a short NodeJS code block that is intended to quickly return and not perform any business logic.\n  ```javascript\n  const {SNSClient, PublishCommand} = require(\"@aws-sdk/client-sns\");\n  const client = new SNSClient();\n        exports.handler = async function (event) {\n            const params = {\n                Message: JSON.stringify(event),\n                TopicArn: '${NewCallTopic}'\n            };\n            const response = await client.send(new PublishCommand(params));\n            return {status: 'OK'};\n        };\n  ```\n![Call Flow Part 1](assets/flowpart1.png)\n\n### Ask for Language then play conditional prompt\nChecking to see if background process has something we need to act on:\n- An initial welcome prompt is played (meanwhile, our backend logic is executing).\n- We then check for the language, in this case, if the caller wants to interact in Spanish by pressing 2.\n- By this time, (since several seconds have elapsed playing prompts) we check contact attributes that may have been set by the [NewCallLookup Lambda](NewCallLookup/src/main/java/cloud/cleo/connectgpt/NewCallLookup.java).\n- In this example if the contact attribute \"PlayPrompt\" has a value of \"true\", we proceed to play a prompt that was generated by the NewCallLookup Lambda by calling [UpdateContactAttributes](https://docs.aws.amazon.com/connect/latest/APIReference/API_UpdateContactAttributes.html).\n- Based on the Dynamo Query, if this is a first time call, nothing is set.  However if the caller has called before, an attribute is set with \"Welcome Back\".\n- This is just an example strategy to perform background work and later react to it.  I don't like a looping approach in the call flow waiting on a result, but rather check the result and if set, act upon it.  Of course, different use cases might require a result to proceed with the call.\n![Call Flow Part 2](assets/flowpart2.png)\n\n### Lex/ChatGPT and output intents\n\nAt this point in the call, the language is known and control is now with the Lex Bot:\n- Because the bot itself does not control the call, we need Lex intents that can transfer the call or hang up on the caller, which must be done by the Call Flow.\n  - The \"About\" intent will play a long prompt describing the project.\n  - The \"Quit\" intent will play a thank you prompt and disconnect the call.\n  - The \"Transfer\" intent in this case will transfer the call to an external number.\n- When the Lex Bot can't match the above intents, it sends the transcript (what the caller said) to the [FallBack Intent](https://docs.aws.amazon.com/lexv2/latest/dg/built-in-intent-fallback.html)  which is connected to the [ChatGPT Lambda](ChatGPT/src/main/java/cloud/cleo/connectgpt/ChatGPTLambda.java).\n  - The Lambda then sends the transcript to ChatGPT and returns the result to the Lex Bot with a dialog action of [ElicitIntent](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_runtime_DialogAction.html).\n  - The result is the ChatGPT response is played back to the caller and the LexBot is once again listening for the next Intent to match.\n  - The conversation can continue until the caller hangs up or matches the Quit intent (saying good bye, thanks, all done, etc.) or Transfer intent.\n- The Lambda can also tell the Lex Bot to fullfill another intent:\n  - After 2 subsequent silence timeouts the Lambda will respond with a Delegate to the \"Quit\" intent which will then disconnect the call.  This is needed because if someone calls and says nothing, we don't want to keep the call up consuming resources forever.\n  - Another possibility is to check the length of the chat history and disconnect the call for too many requests or check for profanity and also disconnect in that case.\n- Lambda Error Handling:\n  - A number of things can happen and go wrong and the Lambda has to respond properly.\n  - If you ask for something complicated or ChatGPT is just busy/slow at the moment, the API call will timeout, and the appropiate response (in the callers language) must be returned telling the caller to try again.\n  - If ChatGPT is down, or there is a network connectivity issue, any unhandled exception in the code is returned telling the caller something is down, try again later.\n![Call Flow Part 3](assets/flowpart3.png)\n\n\n## Contents\nThis project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders:\n\n- [ChatGPT](ChatGPT/src/main/java/cloud/cleo/connectgpt/) - Lambda fullfillment hook that calls out to OpenAI ChatGPT.\n- [PollyPromptCreation](PollyPromptCreation/src/main/java/cloud/cleo/connectgpt/)  - [Custom Resource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html) Lambda that does all of the static prompt creation.\n- [NewCallLookup](NewCallLookup/src/main/java/cloud/cleo/connectgpt/) - Lambda that is called for every incoming call that logs it to DyanmoDB and updates Contact Attributes to play a conditional prompt.\n- CloudFormation script for all AWS resources:\n\t- [template.yaml](template.yaml) - Creates all the SAM lambda functions and associated AWS resources.\n\n\n## Deploy the Project\n\nThe Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications.  Before proceeding, it is assumed you have valid AWS credentials setup with the AWS CLI and permissions to perform CloudFormation stack operations.\n\nTo use the SAM CLI, you need the following tools.\n\n* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)\n* Java21 - [Install Java 21](https://docs.aws.amazon.com/corretto/latest/corretto-21-ug/downloads-list.html)\n* Maven - [Install Maven](https://maven.apache.org/install.html)\n\nIf you have brew installed then\n```bash\nbrew install aws-sam-cli\nbrew install corretto@21\nbrew install maven\n```\n\nTo build and deploy, run the following in your shell after you have cloned the repo.  Note: it may be easier to edit the [template.yaml](template.yaml) and change the defaults for the parameteres to \ntaste before running the build like the Connect Instance ID, then you won't have to specify the \"--parameter-overrides\" indicated below.\n\n```bash\n./init.bash\nsam build\nsam deploy --parameter-overrides 'ParameterKey=CONNECTID,ParameterValue=\u003cyour connect instance ID\u003e'\n```\n\nThe first command will set up some required components like the V4 Java Events library that is not published yet (this is a sub-module) and install the parent POM used by Lambda functions.\nThe second command will build the source of the application. \nThe third command will package and deploy the project to AWS as a CloudFormation Stack. You must set the value of your Connect Instance ID (the UUID last of the ARN) or edit the default value in the template.\nYou will see the progress as the stack deploys.  As metntioned earlier, you will need to put your OpenAI API Key into parameter store or the deploy will error, but it will give you an error message \nthat tells you there is no value for \"OPENAI_API_KEY\" in the [Parameter Store](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html).\n\n\n`Do not forget to delete the stack or you will continue to incure AWS charges for the resources`.\n\n\n\n## Associate Phone number to the Connect Flow\n\nOnce you have deployed the project, in the Amazon Connect Console, you will need to associate the flow with a phone number.\n\n![Associate Flow to Phone Number](assets/phonenumber.png)\n\n\n## Fetch, tail, and filter Lambda function logs\n\nTo simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by the deployed Lambda functions from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly see what's going on with the demo.\n\n\n```bash\nsam logs --tail\n```\n\nExample:\n```\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:22.355000 RESTORE_START Runtime Version: java:11.v20\tRuntime Version ARN: arn:aws:lambda:us-east-1::runtime:b8b295733fb8ae6769e0fb039181ce76e1f54a4d04bb5ca7ded937bb0d839109\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:22.719000 RESTORE_REPORT Restore Duration: 398.97 ms\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:22.722000 START RequestId: 8c360c87-d4b7-4423-b5f3-af02be3c1763 Version: 72\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:22.974000 8c360c87-d4b7-4423-b5f3-af02be3c1763 DEBUG ChatGPTLambda:54 - {\"messageVersion\":\"1.0\",\"invocationSource\":\"FulfillmentCodeHook\",\"inputMode\":\"Speech\",\"responseContentType\":\"text/plain; charset=utf-8\",\"sessionId\":\"ecd79064-d807-4c2e-9bc6-a75a91284fdd\",\"inputTranscript\":\"largest lake in minnesota\",\"bot\":{\"id\":\"YWKVXZGMDJ\",\"name\":\"connect-chatgpt-Lex-Bot\",\"aliasId\":\"0OJEBBWKI2\",\"aliasName\":\"Latest\",\"localeId\":\"en_US\",\"version\":\"1\"},\"interpretations\":[{\"intent\":{\"confirmationState\":\"None\",\"name\":\"FallbackIntent\",\"slots\":{},\"state\":\"ReadyForFulfillment\",\"kendraResponse\":null},\"nluConfidence\":null,\"sentimentResponse\":null},{\"intent\":{\"confirmationState\":\"None\",\"name\":\"About\",\"slots\":{},\"state\":\"ReadyForFulfillment\",\"kendraResponse\":null},\"nluConfidence\":0.58,\"sentimentResponse\":null},{\"intent\":{\"confirmationState\":\"None\",\"name\":\"Steve\",\"slots\":{},\"state\":\"ReadyForFulfillment\",\"kendraResponse\":null},\"nluConfidence\":0.51,\"sentimentResponse\":null},{\"intent\":{\"confirmationState\":\"None\",\"name\":\"Quit\",\"slots\":{},\"state\":\"ReadyForFulfillment\",\"kendraResponse\":null},\"nluConfidence\":0.38,\"sentimentResponse\":null}],\"proposedNextState\":null,\"requestAttributes\":{\"x-amz-lex:accept-content-types\":\"PlainText,SSML\",\"x-amz-lex:channels:platform\":\"Connect\"},\"sessionState\":{\"activeContexts\":null,\"sessionAttributes\":{\"CustomerNumber\":\"+16128140714\",\"InstanceArn\":\"arn:aws:connect:us-east-1:364253738352:instance/f837ec93-b6e5-4429-acb7-f698fff0148c\"},\"runtimeHints\":null,\"dialogAction\":null,\"intent\":{\"confirmationState\":\"None\",\"name\":\"FallbackIntent\",\"slots\":{},\"state\":\"ReadyForFulfillment\",\"kendraResponse\":null},\"originatingRequestId\":\"33b39120-ccaf-4ca4-b5d0-4e4bc1c7b86d\"},\"transcriptions\":[{\"transcription\":\"largest lake in minnesota\",\"transcriptionConfidence\":0.92,\"resolvedContext\":{\"intent\":\"FallbackIntent\"},\"resolvedSlots\":{}},{\"transcription\":\"the largest lake in minnesota\",\"transcriptionConfidence\":0.82,\"resolvedContext\":{\"intent\":null},\"resolvedSlots\":{}},{\"transcription\":\"largest lake and minnesota\",\"transcriptionConfidence\":0.72,\"resolvedContext\":{\"intent\":null},\"resolvedSlots\":{}}]}\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:22.975000 8c360c87-d4b7-4423-b5f3-af02be3c1763 DEBUG ChatGPTLambda:56 - Intent: FallbackIntent\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:22.977000 8c360c87-d4b7-4423-b5f3-af02be3c1763 DEBUG ChatGPTLambda:71 - Java Locale is en_US\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:23.010000 8c360c87-d4b7-4423-b5f3-af02be3c1763 DEBUG ChatGPTLambda:99 - Start Retreiving Session State\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:23.656000 8c360c87-d4b7-4423-b5f3-af02be3c1763 DEBUG ChatGPTLambda:101 - End Retreiving Session State\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:23.672000 8c360c87-d4b7-4423-b5f3-af02be3c1763 DEBUG ChatGPTLambda:124 - Start API Call to ChatGPT\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:24.952000 8c360c87-d4b7-4423-b5f3-af02be3c1763 DEBUG ChatGPTLambda:126 - End API Call to ChatGPT\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:24.953000 8c360c87-d4b7-4423-b5f3-af02be3c1763 DEBUG ChatGPTLambda:127 - ChatCompletionResult(id=chatcmpl-7MxECAVkjCnZl8KDsZxPNZ5vJ264G, object=chat.completion, created=1685705244, model=gpt-3.5-turbo-0301, choices=[ChatCompletionChoice(index=0, message=ChatMessage(role=assistant, content=The largest lake in Minnesota is Lake Superior.), finishReason=stop)], usage=Usage(promptTokens=46, completionTokens=9, totalTokens=55))\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:24.954000 8c360c87-d4b7-4423-b5f3-af02be3c1763 DEBUG ChatGPTLambda:138 - Start Saving Session State\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:25.046000 8c360c87-d4b7-4423-b5f3-af02be3c1763 DEBUG ChatGPTLambda:141 - End Saving Session State\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:25.052000 8c360c87-d4b7-4423-b5f3-af02be3c1763 DEBUG ChatGPTLambda:202 - Response is {\"sessionState\":{\"activeContexts\":null,\"sessionAttributes\":{\"CustomerNumber\":\"+16128140714\",\"InstanceArn\":\"arn:aws:connect:us-east-1::instance/f837ec93-b6e5-4429-acb7-f698fff0148c\"},\"runtimeHints\":null,\"dialogAction\":{\"slotToElicit\":null,\"type\":\"ElicitIntent\"},\"intent\":null,\"originatingRequestId\":null},\"messages\":[{\"contentType\":\"PlainText\",\"content\":\"The largest lake in Minnesota is Lake Superior.  What else can I help you with?\",\"imageResponseCard\":null}],\"requestAttributes\":null}\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:25.060000 END RequestId: 8c360c87-d4b7-4423-b5f3-af02be3c1763\n2023/06/02/[72]88ab219a63d343d294d0a9947e8ab36a 2023-06-02T11:27:25.060000 REPORT RequestId: 8c360c87-d4b7-4423-b5f3-af02be3c1763\tDuration: 2338.66 ms\tBilled Duration: 2521 ms\tMemory Size: 3009 MB\tMax Memory Used: 173 MB\tRestore Duration: 398.97 ms\tBilled Restore Duration: 182 ms\t\n^C CTRL+C received, cancelling...                                              \n```\n\nYou can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html).\n\n\n## Cleanup\n\nTo delete the demo, use the SAM CLI. `DO NOT FORGET TO RUN THIS OR YOU WILL CONTINUE TO BE CHARGED FOR AWS RESOURCES`.\n\nPrior to deleting the stack, you should ensure you have disassociated any phone numbers pointing to the Connect Flow.\n\nYou can run the following:\n\n```bash\nsam delete\n```\n\n## Sample Deploy Output\n```\njava-connect-lex-chatgpt$ sam deploy\n\n\t\tManaged S3 bucket: aws-sam-cli-managed-default-samclisourcebucket\n\t\tA different default S3 bucket can be set in samconfig.toml\n\t\tOr by specifying --s3-bucket explicitly.\nFile with same data already exists at 80aa0fed5827b7a80fa780734e9c4c09, skipping upload                                                                                                            \nFile with same data already exists at 8a3b643e9487598224c935024ab7de90, skipping upload                                                                                                            \nFile with same data already exists at d6f1fe447c5e6b528ef821e8612cc5c3, skipping upload                                                                                                            \n\n\tDeploying with following values\n\t===============================\n\tStack name                   : connect-chatgpt\n\tRegion                       : us-east-1\n\tConfirm changeset            : True\n\tDisable rollback             : False\n\tDeployment s3 bucket         : aws-sam-cli-managed-default-samclisourcebucket\n\tCapabilities                 : [\"CAPABILITY_IAM\"]\n\tParameter overrides          : {}\n\tSigning Profiles             : {}\n\nInitiating deployment\n=====================\n\n\tUploading to f837836f7f1a4ab21d28677fcf6980e3.template  36058 / 36058  (100.00%)\n\n\nWaiting for changeset to be created..\n\nCloudFormation stack changeset\n---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\nOperation                                       LogicalResourceId                               ResourceType                                    Replacement                                   \n---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n+ Add                                           BotAlias                                        AWS::Lex::BotAlias                              N/A                                           \n+ Add                                           BotRuntimeRole                                  AWS::IAM::Role                                  N/A                                           \n+ Add                                           BotVersion                                      AWS::Lex::BotVersion                            N/A                                           \n+ Add                                           BucketKey                                       AWS::KMS::Key                                   N/A                                           \n+ Add                                           BucketPolicy                                    AWS::S3::BucketPolicy                           N/A                                           \n+ Add                                           CallTable                                       AWS::DynamoDB::Table                            N/A                                           \n+ Add                                           ChatGPTAliasSNAPSTART                           AWS::Lambda::Alias                              N/A                                           \n+ Add                                           ChatGPTRole                                     AWS::IAM::Role                                  N/A                                           \n+ Add                                           ChatGPTVersion5e83da0577                        AWS::Lambda::Version                            N/A                                           \n+ Add                                           ChatGPT                                         AWS::Lambda::Function                           N/A                                           \n+ Add                                           ClosingPromptEnglish                            Custom::PromptCreator                           N/A                                           \n+ Add                                           ClosingPromptSpanish                            Custom::PromptCreator                           N/A                                           \n+ Add                                           ConnectFlow                                     AWS::Connect::ContactFlow                       N/A                                           \n+ Add                                           ContactUpdatePolicy                             AWS::IAM::ManagedPolicy                         N/A                                           \n+ Add                                           ErrorPromptEnglish                              Custom::PromptCreator                           N/A                                           \n+ Add                                           ErrorPromptSpanish                              Custom::PromptCreator                           N/A                                           \n+ Add                                           HelpPromptEnglish                               Custom::PromptCreator                           N/A                                           \n+ Add                                           HelpPromptSpanish                               Custom::PromptCreator                           N/A                                           \n+ Add                                           LexBot                                          AWS::Lex::Bot                                   N/A                                           \n+ Add                                           LexPromptEnglish                                Custom::PromptCreator                           N/A                                           \n+ Add                                           LexPromptSpanish                                Custom::PromptCreator                           N/A                                           \n+ Add                                           LexToChatGPTPerm                                AWS::Lambda::Permission                         N/A                                           \n+ Add                                           LexToChatGPTSnapPerm                            AWS::Lambda::Permission                         N/A                                           \n+ Add                                           LexV2ConnectIntegration                         AWS::Connect::IntegrationAssociation            N/A                                           \n+ Add                                           MainPrompt                                      Custom::PromptCreator                           N/A                                           \n+ Add                                           NewCallLookupAliasSNAPSTART                     AWS::Lambda::Alias                              N/A                                           \n+ Add                                           NewCallLookupRole                               AWS::IAM::Role                                  N/A                                           \n+ Add                                           NewCallLookupSNSTriggerPermission               AWS::Lambda::Permission                         N/A                                           \n+ Add                                           NewCallLookupSNSTrigger                         AWS::SNS::Subscription                          N/A                                           \n+ Add                                           NewCallLookupVersion23a3112bb1                  AWS::Lambda::Version                            N/A                                           \n+ Add                                           NewCallLookup                                   AWS::Lambda::Function                           N/A                                           \n+ Add                                           NewCallTopic                                    AWS::SNS::Topic                                 N/A                                           \n+ Add                                           PromptBucket                                    AWS::S3::Bucket                                 N/A                                           \n+ Add                                           PromptCreatorRole                               AWS::IAM::Role                                  N/A                                           \n+ Add                                           PromptCreator                                   AWS::Lambda::Function                           N/A                                           \n+ Add                                           SendToSNSConnectIntegration                     AWS::Connect::IntegrationAssociation            N/A                                           \n+ Add                                           SendToSNSRole                                   AWS::IAM::Role                                  N/A                                           \n+ Add                                           SendToSNS                                       AWS::Lambda::Function                           N/A                                           \n+ Add                                           SessionTable                                    AWS::DynamoDB::Table                            N/A                                           \n+ Add                                           SpanishPrompt                                   Custom::PromptCreator                           N/A                                           \n+ Add                                           TransferPromptEnglish                           Custom::PromptCreator                           N/A                                           \n+ Add                                           TransferPromptSpanish                           Custom::PromptCreator                           N/A                                           \n---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\n\nChangeset created successfully. arn:aws:cloudformation:us-east-1::changeSet/samcli-deploy1685703701/579fda5c-92d1-4c8a-9032-547725a47612\n\n\nPreviewing CloudFormation changeset before deployment\n======================================================\nDeploy this changeset? [y/N]: y\n\n2023-06-02 06:02:07 - Waiting for stack create/update to complete\n\nCloudFormation events from stack operations (refresh every 5.0 seconds)\n---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\nResourceStatus                                  ResourceType                                    LogicalResourceId                               ResourceStatusReason                          \n---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\nCREATE_IN_PROGRESS                              AWS::IAM::ManagedPolicy                         ContactUpdatePolicy                             -                                             \nCREATE_IN_PROGRESS                              AWS::KMS::Key                                   BucketKey                                       -                                             \nCREATE_IN_PROGRESS                              AWS::DynamoDB::Table                            SessionTable                                    -                                             \nCREATE_IN_PROGRESS                              AWS::DynamoDB::Table                            CallTable                                       -                                             \nCREATE_IN_PROGRESS                              AWS::IAM::Role                                  BotRuntimeRole                                  -                                             \nCREATE_IN_PROGRESS                              AWS::SNS::Topic                                 NewCallTopic                                    -                                             \nCREATE_IN_PROGRESS                              AWS::IAM::ManagedPolicy                         ContactUpdatePolicy                             Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::IAM::Role                                  BotRuntimeRole                                  Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::DynamoDB::Table                            SessionTable                                    Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::DynamoDB::Table                            CallTable                                       Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::KMS::Key                                   BucketKey                                       Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::SNS::Topic                                 NewCallTopic                                    Resource creation Initiated                   \nCREATE_COMPLETE                                 AWS::SNS::Topic                                 NewCallTopic                                    -                                             \nCREATE_IN_PROGRESS                              AWS::IAM::Role                                  SendToSNSRole                                   -                                             \nCREATE_IN_PROGRESS                              AWS::IAM::Role                                  SendToSNSRole                                   Resource creation Initiated                   \nCREATE_COMPLETE                                 AWS::DynamoDB::Table                            SessionTable                                    -                                             \nCREATE_COMPLETE                                 AWS::DynamoDB::Table                            CallTable                                       -                                             \nCREATE_COMPLETE                                 AWS::IAM::ManagedPolicy                         ContactUpdatePolicy                             -                                             \nCREATE_IN_PROGRESS                              AWS::IAM::Role                                  ChatGPTRole                                     -                                             \nCREATE_IN_PROGRESS                              AWS::IAM::Role                                  ChatGPTRole                                     Resource creation Initiated                   \nCREATE_COMPLETE                                 AWS::IAM::Role                                  BotRuntimeRole                                  -                                             \nCREATE_IN_PROGRESS                              AWS::IAM::Role                                  NewCallLookupRole                               -                                             \nCREATE_IN_PROGRESS                              AWS::IAM::Role                                  NewCallLookupRole                               Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::Lex::Bot                                   LexBot                                          -                                             \nCREATE_COMPLETE                                 AWS::IAM::Role                                  SendToSNSRole                                   -                                             \nCREATE_IN_PROGRESS                              AWS::Lex::Bot                                   LexBot                                          Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::Lambda::Function                           SendToSNS                                       -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Function                           SendToSNS                                       Resource creation Initiated                   \nCREATE_COMPLETE                                 AWS::IAM::Role                                  ChatGPTRole                                     -                                             \nCREATE_COMPLETE                                 AWS::Lambda::Function                           SendToSNS                                       -                                             \nCREATE_COMPLETE                                 AWS::IAM::Role                                  NewCallLookupRole                               -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Function                           ChatGPT                                         -                                             \nCREATE_IN_PROGRESS                              AWS::Connect::IntegrationAssociation            SendToSNSConnectIntegration                     -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Function                           ChatGPT                                         Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::Lambda::Function                           NewCallLookup                                   -                                             \nCREATE_IN_PROGRESS                              AWS::Connect::IntegrationAssociation            SendToSNSConnectIntegration                     Resource creation Initiated                   \nCREATE_COMPLETE                                 AWS::Connect::IntegrationAssociation            SendToSNSConnectIntegration                     -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Function                           NewCallLookup                                   Resource creation Initiated                   \nCREATE_COMPLETE                                 AWS::Lambda::Function                           ChatGPT                                         -                                             \nCREATE_COMPLETE                                 AWS::Lex::Bot                                   LexBot                                          -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Permission                         LexToChatGPTPerm                                -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Version                            ChatGPTVersion5e83da0577                        -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Permission                         LexToChatGPTPerm                                Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::Lambda::Version                            ChatGPTVersion5e83da0577                        Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::Lex::BotVersion                            BotVersion                                      -                                             \nCREATE_COMPLETE                                 AWS::Lambda::Function                           NewCallLookup                                   -                                             \nCREATE_IN_PROGRESS                              AWS::Lex::BotVersion                            BotVersion                                      Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::Lambda::Version                            NewCallLookupVersion23a3112bb1                  -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Version                            NewCallLookupVersion23a3112bb1                  Resource creation Initiated                   \nCREATE_COMPLETE                                 AWS::Lambda::Permission                         LexToChatGPTPerm                                -                                             \nCREATE_COMPLETE                                 AWS::Lex::BotVersion                            BotVersion                                      -                                             \nCREATE_COMPLETE                                 AWS::KMS::Key                                   BucketKey                                       -                                             \nCREATE_IN_PROGRESS                              AWS::S3::Bucket                                 PromptBucket                                    -                                             \nCREATE_IN_PROGRESS                              AWS::S3::Bucket                                 PromptBucket                                    Resource creation Initiated                   \nCREATE_COMPLETE                                 AWS::S3::Bucket                                 PromptBucket                                    -                                             \nCREATE_IN_PROGRESS                              AWS::S3::BucketPolicy                           BucketPolicy                                    -                                             \nCREATE_IN_PROGRESS                              AWS::IAM::Role                                  PromptCreatorRole                               -                                             \nCREATE_IN_PROGRESS                              AWS::IAM::Role                                  PromptCreatorRole                               Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::S3::BucketPolicy                           BucketPolicy                                    Resource creation Initiated                   \nCREATE_COMPLETE                                 AWS::S3::BucketPolicy                           BucketPolicy                                    -                                             \nCREATE_COMPLETE                                 AWS::IAM::Role                                  PromptCreatorRole                               -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Function                           PromptCreator                                   -                                             \nCREATE_COMPLETE                                 AWS::Lambda::Version                            ChatGPTVersion5e83da0577                        -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Function                           PromptCreator                                   Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::Lambda::Alias                              ChatGPTAliasSNAPSTART                           -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Alias                              ChatGPTAliasSNAPSTART                           Resource creation Initiated                   \nCREATE_COMPLETE                                 AWS::Lambda::Alias                              ChatGPTAliasSNAPSTART                           -                                             \nCREATE_COMPLETE                                 AWS::Lambda::Version                            NewCallLookupVersion23a3112bb1                  -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Permission                         LexToChatGPTSnapPerm                            -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Permission                         LexToChatGPTSnapPerm                            Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::Lex::BotAlias                              BotAlias                                        -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Alias                              NewCallLookupAliasSNAPSTART                     -                                             \nCREATE_IN_PROGRESS                              AWS::Lex::BotAlias                              BotAlias                                        Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::Lambda::Alias                              NewCallLookupAliasSNAPSTART                     Resource creation Initiated                   \nCREATE_COMPLETE                                 AWS::Lambda::Alias                              NewCallLookupAliasSNAPSTART                     -                                             \nCREATE_COMPLETE                                 AWS::Lex::BotAlias                              BotAlias                                        -                                             \nCREATE_COMPLETE                                 AWS::Lambda::Function                           PromptCreator                                   -                                             \nCREATE_IN_PROGRESS                              AWS::SNS::Subscription                          NewCallLookupSNSTrigger                         -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Permission                         NewCallLookupSNSTriggerPermission               -                                             \nCREATE_IN_PROGRESS                              AWS::Connect::ContactFlow                       ConnectFlow                                     -                                             \nCREATE_IN_PROGRESS                              AWS::Lambda::Permission                         NewCallLookupSNSTriggerPermission               Resource creation Initiated                   \nCREATE_IN_PROGRESS                              AWS::Connect::IntegrationAssociation            LexV2ConnectIntegration                         -                                             \nCREATE_IN_PROGRESS                              AWS::SNS::Subscription                          NewCallLookupSNSTrigger                         Resource creation Initiated                   \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           LexPromptSpanish                                -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           ClosingPromptSpanish                            -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           TransferPromptEnglish                           -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           TransferPromptSpanish                           -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           ErrorPromptEnglish                              -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           ErrorPromptSpanish                              -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           ClosingPromptEnglish                            -                                             \nCREATE_COMPLETE                                 AWS::SNS::Subscription                          NewCallLookupSNSTrigger                         -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           HelpPromptEnglish                               -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           MainPrompt                                      -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           LexPromptEnglish                                -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           SpanishPrompt                                   -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           HelpPromptSpanish                               -                                             \nCREATE_IN_PROGRESS                              AWS::Connect::ContactFlow                       ConnectFlow                                     Resource creation Initiated                   \nCREATE_COMPLETE                                 AWS::Connect::ContactFlow                       ConnectFlow                                     -                                             \nCREATE_IN_PROGRESS                              AWS::Connect::IntegrationAssociation            LexV2ConnectIntegration                         Resource creation Initiated                   \nCREATE_COMPLETE                                 AWS::Connect::IntegrationAssociation            LexV2ConnectIntegration                         -                                             \nCREATE_COMPLETE                                 AWS::Lambda::Permission                         LexToChatGPTSnapPerm                            -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           ClosingPromptSpanish                            Resource creation Initiated                   \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           ClosingPromptEnglish                            Resource creation Initiated                   \nCREATE_COMPLETE                                 Custom::PromptCreator                           ClosingPromptSpanish                            -                                             \nCREATE_COMPLETE                                 Custom::PromptCreator                           ClosingPromptEnglish                            -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           SpanishPrompt                                   Resource creation Initiated                   \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           LexPromptSpanish                                Resource creation Initiated                   \nCREATE_COMPLETE                                 Custom::PromptCreator                           SpanishPrompt                                   -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           TransferPromptSpanish                           Resource creation Initiated                   \nCREATE_COMPLETE                                 Custom::PromptCreator                           LexPromptSpanish                                -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           ErrorPromptEnglish                              Resource creation Initiated                   \nCREATE_COMPLETE                                 Custom::PromptCreator                           TransferPromptSpanish                           -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           ErrorPromptSpanish                              Resource creation Initiated                   \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           HelpPromptEnglish                               Resource creation Initiated                   \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           TransferPromptEnglish                           Resource creation Initiated                   \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           MainPrompt                                      Resource creation Initiated                   \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           LexPromptEnglish                                Resource creation Initiated                   \nCREATE_COMPLETE                                 Custom::PromptCreator                           ErrorPromptEnglish                              -                                             \nCREATE_COMPLETE                                 Custom::PromptCreator                           ErrorPromptSpanish                              -                                             \nCREATE_IN_PROGRESS                              Custom::PromptCreator                           HelpPromptSpanish                               Resource creation Initiated                   \nCREATE_COMPLETE                                 Custom::PromptCreator                           HelpPromptEnglish                               -                                             \nCREATE_COMPLETE                                 Custom::PromptCreator                           TransferPromptEnglish                           -                                             \nCREATE_COMPLETE                                 Custom::PromptCreator                           MainPrompt                                      -                                             \nCREATE_COMPLETE                                 Custom::PromptCreator                           LexPromptEnglish                                -                                             \nCREATE_COMPLETE                                 Custom::PromptCreator                           HelpPromptSpanish                               -                                             \nCREATE_COMPLETE                                 AWS::Lambda::Permission                         NewCallLookupSNSTriggerPermission               -                                             \nCREATE_COMPLETE                                 AWS::CloudFormation::Stack                      connect-chatgpt                                 -                                             \n---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\n\nSuccessfully created/updated stack - connect-chatgpt in us-east-1\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdocwho2%2Fjava-connect-lex-chatgpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdocwho2%2Fjava-connect-lex-chatgpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdocwho2%2Fjava-connect-lex-chatgpt/lists"}