Skip to content

Issue with IdempotencyException Handling in StartOutboundVoiceContact API

0

I am using Amazon Connect and calling the StartOutboundVoiceContact API multiple times with the same ClientToken="abc" and the same PhoneNumber="123". In the first few attempts, I received an IdempotencyException, but after re-testing, I started receiving the contact ID without any exception. When testing with a different PhoneNumber, I no longer receive the IdempotencyException. I have searched the documentation for StartOutboundVoiceContact but did not find any mention of IdempotencyException. Could you explain why this is happening and provide documentation related to IdempotencyException for StartOutboundVoiceContact?

asked a year ago181 views

1 Answer
0

An IdempotencyException occurs when attempting to create an entity that already exists [1]. To resolve this issue, you should ensure that you are not trying to create duplicate outbound voice contacts with the same parameters. When using the StartOutboundVoiceContact API, the operation has a 60-second dialing timeout, and if the call is not connected within this timeframe, it will fail [1].

To verify if your API request is reaching Amazon Connect successfully, you can check the AWS CloudTrail events on the CloudTrail console for the StartOutboundVoiceContact API event name. If you encounter issues with outbound calls, you can use the describe-contact command to determine whether the call was successful for a specific contact ID [2].

Best Practices:

  1. Always use unique ClientTokens for each call. It isn't required parameter so you can leave it to the AWS SDK to generate one.
  2. If you decide to provide a client token, store and track used ClientTokens if needed.
  3. Implement proper error handling
  4. Consider implementing a retry mechanism
  5. Use meaningful ClientToken patterns (e.g., including timestamp or request ID)

Additional Considerations:

Example with more robust token generation

def generate_client_token(prefix="call"):
    timestamp = int(time.time())
    unique_id = str(uuid.uuid4())[:8]
    return f"{prefix}-{timestamp}-{unique_id}"

Error Handling Pattern:

def safe_outbound_call(connect_client, params):
    try:
        return connect_client.start_outbound_voice_contact(**params)
    except connect_client.exceptions.IdempotencyException as e:
        logger.warning(f"Idempotency exception: {str(e)}")
        # Generate new token and retry
        params['ClientToken'] = generate_client_token()
        return connect_client.start_outbound_voice_contact(**params)
    except ClientError as e:
        logger.error(f"AWS error: {str(e)}")
        raise

Remember that ClientTokens must be unique within the 7-day window. If you need to make the same call again within this period, you must use a different ClientToken.

This approach ensures reliable outbound calling while maintaining idempotency protection.

References:

[1] StartOutboundVoiceContact https://docs.aws.amazon.com/connect/latest/APIReference/API_StartOutboundVoiceContact.html

[2] How do I troubleshoot issues with outbound campaigns in Amazon Connect? https://repost.aws/knowledge-center/connect-troubleshoot-outbound-campaigns

AWS
SUPPORT ENGINEER

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.