Migrate getExternalRecordingS3Location and getMediaUrl serverless endpoints to lambdas/account-scoped#3991
Conversation
…points to lambdas/account-scoped/conversation Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
stephenhand
left a comment
There was a problem hiding this comment.
Add a feature flag to plugin-hrm-form called use_twilio_lambda_for_recordings_lookup
Use this flag to determine whether the getMediaUrl and getExternalRecordingS3Location methods in ServerlessService.ts should send to the legacy endpoint or the migrated endpoint. It should send to the migrated endpoint if set
Consolidate these two methods and the contents of the getExternalRecordingS3Location.ts files into a new recordingsService module. The getExternalRecordingS3Location migrated from serverless service will no longer need to be exported from the module
…rding logic into recordingsService Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Done in commit 5d24b05:
|
# Conflicts: # lambdas/account-scoped/src/router.ts # plugin-hrm-form/src/types/FeatureFlags.ts
stephenhand
left a comment
There was a problem hiding this comment.
The following unit test is failing :
handleTwilioTask() (externalRecording) should return conversationMedia with correct data if external recording is enabled
…e when no conference Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Fixed in commit 3b5ad6c. The mock for |
Migrates two asset download Twilio serverless functions into
lambdas/account-scoped/src/conversation/, following the same pattern established by other recent migrations (e.g.getTaskAndReservations). Also adds a feature flag and a newrecordingsServicemodule inplugin-hrm-formto support gradual rollout of the migrated endpoints.Description
lambdas/account-scoped@tech-matters/twilio-configuration: AddedgetDocsBucketName(accountSid)— retrieves S3 docs bucket name from SSM at/${NODE_ENV}/s3/${accountSid}/docs_bucket_nameconversation/getExternalRecordingS3Location: Lists Twilio recordings for acallSid; returns{ recordingSid, key, bucket }wherekey = voice-recordings/${accountSid}/${recordingSid}. Returns 404/409 for missing or ambiguous recordings.conversation/getMediaUrl: Authenticates against the Twilio MCS API using account SID + auth token (Basic Auth) and returns thecontent_direct_temporaryURL for a givenserviceSid/mediaSid.router.ts: Both routes registered underconversation/withvalidateFlexTokenRequest({ tokenMode: 'agent' })— matching theTokenValidatorwrapper in the original serverless versions.Unit tests added for both handlers.
plugin-hrm-formFeatureFlags.ts: Addeduse_twilio_lambda_for_recordings_lookupboolean flag.services/recordingsService.ts(new module, consolidatesgetExternalRecordingInfo.ts+ recording API calls): ContainsgetMediaUrl, internalgetExternalRecordingS3Location, and all logic previously ingetExternalRecordingInfo.ts. Both API functions route to the migrated lambda endpoints (/conversation/getMediaUrl,/conversation/getExternalRecordingS3Location) whenuse_twilio_lambda_for_recordings_lookupis enabled, or to the legacy serverless endpoints otherwise.services/ServerlessService.ts: RemovedgetExternalRecordingS3LocationandgetMediaUrl(moved torecordingsService).services/getExternalRecordingInfo.ts: Deleted — contents consolidated intorecordingsService.ts.Updated all callers (
ContactService.ts,InsightsService.ts,formSubmissionHelpers.ts,MessageItem.tsx) to import fromrecordingsService.ts.Unit tests added for feature-flag routing of both
getMediaUrlandgetExternalRecordingS3Location(viagetExternalRecordingInfo).ContactService.test.ts: Fixed therecordingsServicemock so thatgetExternalRecordingInforeturns a failure result when the task has no conference attribute, restoring the behaviour the test relied on before the refactor.Checklist
Other Related Issues
None
Verification steps
POST /lambda/twilio/account-scoped/{accountSid}/conversation/getExternalRecordingS3Locationwith a validcallSid(and a Flex token) — expect{ recordingSid, key, bucket }.POST /lambda/twilio/account-scoped/{accountSid}/conversation/getMediaUrlwith validserviceSid+mediaSid— expect a temporary direct media URL string.use_twilio_lambda_for_recordings_lookupfeature flag and verify that voice recording lookups and media URLs in the plugin resolve correctly via the new lambda endpoints.AFTER YOU MERGE
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
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.