Skip to content

feat(event_sources): add support for Amazon Connect Outbound Campaigns - #8702

Open
ASHMEET555 wants to merge 1 commit into
aws-powertools:developfrom
ASHMEET555:feat/connect-outbound-campaigns
Open

ASHMEET555 wants to merge 1 commit into
aws-powertools:developfrom
ASHMEET555:feat/connect-outbound-campaigns

Conversation

@ASHMEET555

Copy link
Copy Markdown
Contributor

Issue number: closes #7976

Summary

Adds support for Amazon Connect Outbound Campaigns custom action block triggers, achieving feature parity with TypeScript implementation (aws-powertools/powertools-lambda-typescript#5502).

Changes

Event Source Data Classes

  • Added ConnectOutboundCampaignsEvent in aws_lambda_powertools/utilities/data_classes/connect_campaign_event.py with typed sub-wrappers:
    • ConnectOutboundCampaignInvocationMetadata & ConnectOutboundCampaignContext (CampaignId, RunId, ActionId, CampaignName).
    • ConnectOutboundCampaignItems & ConnectOutboundCampaignCustomerProfile (ProfileId, CustomerData, IdempotencyToken).
  • Added cached_property json_customer_data to automatically deserialize the embedded campaign JSON string.
  • Added convenience accessor event.customer_profiles to iterate directly over profiles.
  • Re-exported all new classes in aws_lambda_powertools/utilities/data_classes/__init__.py.

Parser (Pydantic v2)

  • Added built-in event model ConnectOutboundCampaignsEventModel in aws_lambda_powertools/utilities/parser/models/connect_campaign.py.
  • Added models ConnectInvocationMetadataModel, ConnectCampaignContextModel, ConnectItemsModel, and ConnectCustomerProfileModel.
  • CustomerData is typed Any by default, allowing developers to extend ConnectCustomerProfileModel with custom Pydantic schemas for campaign payloads.
  • Registered models for lazy-loading in aws_lambda_powertools/utilities/parser/models/__init__.py.

Documentation & Examples

  • Added Amazon Connect Outbound Campaigns entry and code sample in docs/utilities/data_classes.md.
  • Added standalone runnable example in examples/event_sources/src/connect_outbound_campaigns.py.
  • Added ConnectOutboundCampaignsEventModel to the built-in models reference table in docs/utilities/parser.md.

Tests & Fixtures

  • Added canonical event fixture in tests/events/connectOutboundCampaignsEvent.json (matches AWS documentation and TS fixture).
  • Added comprehensive unit tests for data classes in tests/unit/data_classes/required_dependencies/test_connect_campaign_event.py.
  • Added unit tests for parser models (valid parsing, missing fields validation, and custom schema extension) in tests/unit/parser/_pydantic/test_connect_campaign.py.

User experience

1. With Event Source Data Classes:

from aws_lambda_powertools.utilities.data_classes import (
    ConnectOutboundCampaignsEvent,
    event_source,
)
from aws_lambda_powertools.utilities.typing import LambdaContext

@event_source(data_class=ConnectOutboundCampaignsEvent)
def handler(event: ConnectOutboundCampaignsEvent, context: LambdaContext):
    campaign = event.invocation_metadata.campaign_context
    print(f"Processing {campaign.campaign_name} (ID: {campaign.campaign_id})")

    for profile in event.customer_profiles:
        # Access raw or auto-parsed customer data
        print(profile.profile_id, profile.json_customer_data)

2. With Parser:

from aws_lambda_powertools.utilities.parser import parse
from aws_lambda_powertools.utilities.parser.models import ConnectOutboundCampaignsEventModel

def handler(event: dict, context):
    parsed: ConnectOutboundCampaignsEventModel = parse(event=event, model=ConnectOutboundCampaignsEventModel)
    for profile in parsed.items.customer_profiles:
        print(profile.profile_id, profile.idempotency_token)

Verification

  • uv run pytest tests/unit/data_classes/required_dependencies/test_connect_campaign_event.py tests/unit/parser/_pydantic/test_connect_campaign.py --cov=aws_lambda_powertools.utilities.data_classes.connect_campaign_event --cov=aws_lambda_powertools.utilities.parser.models.connect_campaign — 4 passed, 100% test coverage.
  • uv run ruff check aws_lambda_powertools/ docs/ examples/ tests/ — Passed.
  • uv run ruff format --check — Passed.
  • uv run mypy aws_lambda_powertools/utilities/data_classes/ aws_lambda_powertools/utilities/parser/ — Success: no issues found in 98 source files.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@ASHMEET555
ASHMEET555 requested a review from a team as a code owner October 29, 2026 14:19
@ASHMEET555
ASHMEET555 requested a review from hjgraca October 29, 2026 14:19
@boring-cyborg boring-cyborg Bot added documentation Improvements or additions to documentation tests labels Oct 29, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 29, 2026
@sonarqubecloud

Copy link
Copy Markdown

@ASHMEET555

Copy link
Copy Markdown
Contributor Author

Hi @leandrodamascena , PR is ready for review!

Includes Event Source Data Classes, Pydantic v2 Parser models, documentation, and 100% test coverage matching the TypeScript reference implementation.

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.00%. Comparing base (486e484) to head (c15ad67).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8702      +/-   ##
===========================================
+ Coverage    96.99%   97.00%   +0.01%     
===========================================
  Files          321      323       +2     
  Lines        16332    16401      +69     
  Branches      1473     1474       +1     
===========================================
+ Hits         15841    15910      +69     
  Misses         350      350              
  Partials       141      141              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Add support for Connect Outbound Campaigns

1 participant