Skip to content

Comments

Migrate IWF endpoint clients to account-scoped lambda with feature flag toggle#3938

Open
Copilot wants to merge 3 commits intomasterfrom
copilot/migrate-iwf-endpoints-to-lambda
Open

Migrate IWF endpoint clients to account-scoped lambda with feature flag toggle#3938
Copilot wants to merge 3 commits intomasterfrom
copilot/migrate-iwf-endpoints-to-lambda

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

Migrates reportToIWF and selfReportToIWF from ServerlessService.ts into a dedicated iwfService.ts, adding a use_twilio_lambda_for_iwf_reporting flag to route calls to either the legacy serverless endpoints or the new account-scoped lambda (/integrations/iwf/reportToIWF, /integrations/iwf/selfReportToIWF).

Description

Key changes

  • FeatureFlags.ts — New flag use_twilio_lambda_for_iwf_reporting following the established use_twilio_lambda_* convention.
  • iwfService.ts (new) — Houses reportToIWF and selfReportToIWF. When the flag is on, routes to the lambda endpoints with useTwilioLambda: true. Normalises the reportToIWF lambda response ({ status, data } wrapper → unwrap to data) so callers are unaffected. selfReportToIWF needs no normalisation — the lambda already returns { reportUrl, status } directly.
  • ServerlessService.ts — IWF functions and their now-unused type imports removed.
  • csamReportApi.ts — Import updated from ServerlessServiceiwfService.
  • csamReportApi.test.ts — Updated import and jest.mock references from ServerlessService to iwfService so the existing tests correctly mock the new service location.
// iwfService.ts (reportToIWF, abridged)
const useTwilioLambda = getAseloFeatureFlags().use_twilio_lambda_for_iwf_reporting;
const response = await fetchProtectedApi(
  useTwilioLambda ? '/integrations/iwf/reportToIWF' : '/reportToIWF',
  body,
  { useTwilioLambda },
);
return useTwilioLambda ? response.data : response;

Checklist

  • Corresponding issue has been opened
  • New tests added
  • Feature flags added
  • Strings are localized
  • Tested for chat contacts
  • Tested for call contacts

Other Related Issues

None

Verification steps

  1. Set use_twilio_lambda_for_iwf_reporting: false — confirm CSAM counsellor and child self-report flows hit the serverless endpoints as before.
  2. Set use_twilio_lambda_for_iwf_reporting: true — confirm the same flows route to the account-scoped lambda (/integrations/iwf/reportToIWF, /integrations/iwf/selfReportToIWF) and complete successfully.

AFTER YOU MERGE

  1. Cut a release tag using the Github workflow. Wait for it to complete and notify in the #aselo-deploys Slack channel.
  2. Comment on the ticket with the release tag version AND any additional instructions required to configure an environment to test the changes.
  3. Only then move the ticket into the QA column in JIRA

You are responsible for ensuring the above steps are completed. If you move a ticket into QA without advising what version to test, the QA team will assume the latest tag has the changes. If it does not, the following confusion is on you! :-P

Original prompt

This section details on the original issue you should resolve

<issue_title>Migrate client code calling IWF endpoints in plugin-hrm-form to call the versions in account-scoped lambda</issue_title>
<issue_description>## Description

  • Create a feature flag to toggle whether to point to the legacy serverless endpoint or the new account-scoped lambda endpoint
  • Update the code to use this flag to change the URL used in the http call to the /reportToIWF and /selfReportToIWF endpoints
  • Migrate the clients from ServerlessService.ts to a new iwfService.ts file in the same directory

Additional context

The new endpoints are implemented in /lambda/account-scoped/integrations/iwf and routed to in /lambda/account-scoped/router.ts

Follow the same naming convention for the feature flags as other functionality being migrated to the account-scoped lambda, i.e. use_twilio_lambda_*</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…h account-scoped lambda support

Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate client code to account-scoped lambda endpoints Migrate IWF endpoint clients to account-scoped lambda with feature flag toggle Feb 19, 2026
Copilot AI requested a review from stephenhand February 19, 2026 23:10
@stephenhand stephenhand marked this pull request as ready for review February 19, 2026 23:22
Copy link
Collaborator

@stephenhand stephenhand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot import references in the unit tests for the iwf endpoints are still pointing at their old location in ServerlessService.ts, causing them to fail

Update the import directives to point to the new location

…erlessService

Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 20, 2026

@copilot import references in the unit tests for the iwf endpoints are still pointing at their old location in ServerlessService.ts, causing them to fail

Update the import directives to point to the ...

Fixed in 5a534f1 — updated the import and jest.mock in csamReportApi.test.ts to point to '../../../services/iwfService' instead of '../../../services/ServerlessService'. All 42 tests pass.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate client code calling IWF endpoints in plugin-hrm-form to call the versions in account-scoped lambda

2 participants