0

I'm working on a Java-based project involving Amazon Connect and AWS Lambda. I want to achieve the following scenario:

  1. After a call ends in Amazon Connect (either by the user or normally), I want to invoke a Java-based AWS Lambda function to process and collect call-related data.

I've already set up an AWS Lambda function in Java that handles data processing, but I'm unsure about the best way to trigger this function after a call ends. Here's what I'm looking for:

  1. Call Termination: How can I detect when a call ends in Amazon Connect? Is there an event or mechanism I can use to determine if a call has ended, either by the user or in a normal manner?

  2. Lambda Invocation: Once a call ends, how can I programmatically trigger my Java-based AWS Lambda function? Are there specific settings I need to configure within Amazon Connect or the Lambda function itself to achieve this?

  3. Data Collection: Additionally, how can I collect relevant data from the call, such as call duration, caller ID, and any custom attributes that were set during the call?

If anyone has experience with Amazon Connect and Lambda integrations, especially in a Java environment, I'd greatly appreciate your guidance on how to set up this workflow effectively. Any Java-specific code examples or step-by-step instructions would be incredibly helpful.

Thank you in advance for your assistance. I'm looking forward to learning from your expertise!

Best regards, Shafin

1 Answers1

0

To capture disconnection events for all calls you will need to subscribe to Amazon Connect events via EventBridge. There is documentation around this here. That documentation has step by step instructions for setting up the event bridge. Note that this will capture all events. you could change the event pattern to...

{
  "source": ["aws.connect"],
  "detail-type": ["Amazon Connect Contact Event"],
  "detail": {
    "eventType": ["DISCONNECTED"]
  }
}

...so you only capture the disconnect events.

You can then set the target of this EventBridge rule to your lambda.

The event includes useful information, like connectedToSystemTimestamp, connectedToAgentTimestamp and disconnectTimestamp which you can use to calculate call duration.

You can also use the included details.contactId from the event in your lambda to get additional information from Connect. Use the Connect API GetContactAttributes action to rertrieve these. Note that there is no way to get the CallerID directly via the Connect API, so if you want that you'll need to attached the callers phone number as an attribute in your Connect contact flows, you can then get that information from the data returned by GetContactAttributes.

ledge
  • 359
  • 1
  • 6