Skip to content

Is it possible to get real-time voice from a call with just a lambda?

0

I want to know if it's possible to obtain the voice of the person calling the contact center using only a lambda.

The idea is to capture the voice, transcribe it, and send it to an external bot, which should respond each time the message is sent.

I want to know if there's any other way than a "GetCustomerInput" block with an associated Lex.

asked a year ago384 views

3 Answers
1
Accepted Answer

The problem with not using the best practice of GetCustomerInput/Lex (fallback intent to external bot/api) is that you lose the capability to detect the end of the utterance as either CL KDS or Voice KVS is one way only. And there is no "interrupt" in Connect flow to immediately pause the waiting to say something back.

If your desire is to integrate with external bot, I recommend using GetCustomerInput/Lex technique. Or leverage the new Amazon Connect External Voice transfer (Connect intake the call, SIP conference to your bot, bot disconnect and call continue in Connect flow) if you have a lot of calls that justify it, https://docs.aws.amazon.com/connect/latest/adminguide/external-voice-transfer.html

answered a year ago

  • Is it possible to process the client's voice with KVS and then reinject it into the channel?

    Example: KVS > Lambda > Transcribe > Lambda > Request from API Bot > Response from API > TTS proccess > Reinject into Call Is there a way to do this? I've seen this type of processing done using streams-api and connect-rtc.js, but I don't know if this type of solution is recommended for production or if there is another one.

  • that is not possible as mentioned with the "intercept" concept which you mentioned as "reinject". The closest you get is a loop for 2-3 seconds and poll to see if there is something to say, not good experience in general. So handling this by Connect/Lex is your best bet as mentioned.

    Steam and connect-rtc js are all for Agent/Client side development, not for bot interactions.

1

It’s a great question and one that comes up often when teams start exploring deeper integration between Amazon Connect and conversational AI systems. The short answer is that a single AWS Lambda function by itself cannot directly capture or stream real-time audio from a Connect call. Lambda isn’t designed for continuous, low-latency audio streaming; it’s stateless and short-lived by nature. However, you can absolutely achieve your goal with the right combination of AWS services.

Here’s the breakdown of what’s actually possible:

  1. Real-time audio access To access live voice from a Connect call, you’ll need to use Amazon Connect Contact Lens real-time streaming or Amazon Kinesis Video Streams. Contact Lens provides transcription and sentiment analysis in near real-time, while Kinesis lets you stream the raw audio for custom processing or integration with external services. Lambda can be part of the pipeline but not the streaming endpoint.

Contact Lens real-time streaming : https://docs.aws.amazon.com/connect/latest/adminguide/analyze-realtime.html

Kinesis Video Streams with Connect : https://docs.aws.amazon.com/connect/latest/adminguide/contact-center-streaming.html

  1. Transcription and processing Once you have audio flowing through Kinesis, you can use Amazon Transcribe Streaming to convert speech to text in real-time. From there, your Lambda function can process each transcription event, call your external bot API, and optionally send the response back into Connect using a custom flow or an Amazon Lex integration.

Amazon Transcribe Streaming API : https://docs.aws.amazon.com/transcribe/latest/dg/API_streaming_StartStreamTranscription.html

  1. Response and integration loop For two-way interaction (your bot responding dynamically during the call), Connect flows can invoke Lambda for each conversational turn using a PlayPrompt or GetCustomerInput block, but this adds latency because flows wait for Lambda to complete before continuing. If you want a more seamless “real-time” conversation, a better architecture is to deploy a lightweight WebSocket or API Gateway layer that stays open throughout the call. Lambda can still process logic behind that layer, but the persistent connection allows faster round trips to your bot.

  2. Simpler alternative using Amazon Lex If your main goal is to transcribe caller input and respond intelligently, consider leveraging Amazon Lex v2 directly within Connect. It provides built-in ASR (Automatic Speech Recognition) and NLP capabilities without needing to handle audio capture, transcription, or round-trip latency manually. You can still route Lex responses through your own Lambda for business logic or external API calls.

Integrating Lex with Connect : https://docs.aws.amazon.com/connect/latest/adminguide/amazon-lex.html

Recommendation If you want to handle every part of the pipeline yourself, you’ll need more than Lambda: Connect audio streaming (via Kinesis), real-time transcription (via Transcribe Streaming), and response orchestration (via API Gateway or Lex). Lambda plays a central role in coordinating events, but it won’t handle the voice stream directly.

A good way to start is by setting up a proof-of-concept using Contact Lens or Kinesis Audio Streaming and experimenting with how fast your external bot can respond within acceptable latency for a real-time experience.

For reference, the official AWS docs cover these building blocks in detail:

Amazon Connect Streams and APIs : https://docs.aws.amazon.com/connect/latest/adminguide/amazon-connect-streams.html

Building real-time analytics and transcription with Connect : https://docs.aws.amazon.com/connect/latest/adminguide/amazon-connect-contact-lens.html

answered a year ago

1

Great question, and I get where you’re coming from with trying to capture and reinject audio in real time using just Lambda and KVS.

Here’s the deal: Lambda by itself can’t handle real-time streaming audio capture or injection because it’s not built for continuous, low-latency media streams. You can definitely use Kinesis Video Streams to get the caller’s voice and process it, but sending that processed audio back into the call isn’t something Connect supports natively right now.

If you want two-way real-time conversation with an external bot, the usual recommendation is to use the GetCustomerInput block with Amazon Lex, or fallback to your own bot via Lambda. This lets Connect handle the audio capture and playback, and you handle the logic. It’s not perfectly real-time but works solid in production.

Another option, if you have a high call volume, is the External Voice Transfer feature. This basically lets Connect SIP conference the call with your bot, so your bot handles the media, and Connect stays in control of the call. It’s a bit more complex to set up but works well for heavier use cases. Here’s the link for that: https://docs.aws.amazon.com/connect/latest/adminguide/external-voice-transfer.html

About connect-rtc.js and the streams API — those tools are great for custom web or softphone setups but aren’t really meant for server-side production voice manipulation inside Connect flows.

So, to sum up:

You can grab the audio with KVS and do your transcription and bot calls in Lambda.

But sending audio back into the call? Not really supported directly.

For real-time two-way bot conversations, stick with Lex or the External Voice Transfer.

If you want deep custom media control, expect a more complex setup involving SIP bots or media servers.

Check these docs for more details:

External Voice Transfer: https://docs.aws.amazon.com/connect/latest/adminguide/external-voice-transfer.html Amazon Lex with Connect: https://docs.aws.amazon.com/connect/latest/adminguide/amazon-lex.html Contact Lens Real-Time Streaming: https://docs.aws.amazon.com/connect/latest/adminguide/analyze-realtime.html Kinesis Video Streams with Connect: https://docs.aws.amazon.com/connect/latest/adminguide/contact-center-streaming.html

If you want to dive deeper or brainstorm some architecture options, happy to chat more.

Cheers

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.