Migrate conversation/transitionAgentParticipants endpoint into lambdas/account-scoped#3987
Conversation
…ation folder 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_to_transition_participants
Use this flag to determine whether the wrapupConversationTask and completeConversationTask methods in twilioTaskService.ts should send to the legacy endpoint or the migrated endpoint. It should send to the migrated endpoint if set
Update the transferChattStart method in ServerlessService.ts to use the existing use_twilio_lambda_transfers flag to control if it points to the legacy transferChatStart or the migrated transferChat endpoint. Move this method into twilioTaskService
…e transferChatStart to twilioTaskService Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
…ents Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Done in commit
|
stephenhand
left a comment
There was a problem hiding this comment.
The transitionAgentParticipantHandler hasn't been implemented correctly. It should take a task SID and look up the task object, and check permissions based on user role and whether they have a reservation on the task, like the original implementation does
… check permissions Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Fixed in commit
The |
Migrates the
transitionAgentParticipantsserverless function intolambdas/account-scoped/src/conversation/and extracts the shared logic fromtransfersTaskRouterListener.tsinto a reusable module. Also adds feature flag support inplugin-hrm-formto routewrapupConversationTask,completeConversationTask, andtransferChatStartto the migrated lambda endpoints.Description
lambdas/account-scoped changes
src/conversation/interactionChannelParticipants.ts(new) — ExtractedtransitionAgentParticipantsfromtransfersTaskRouterListener.tsinto a shared module; lists Flex interaction channel participants and transitions agent participants to a target statussrc/conversation/transitionAgentParticipants.ts(new) — HTTP handler for the migrated endpoint; acceptstaskSid,targetStatus(required) andinteractionChannelParticipantSid(optional); looks up the task viagetTaskAndReservations, checks that the calling worker is a supervisor or holds a valid reservation on the task, extractsflexInteractionSid/flexInteractionChannelSidfrom the task attributes, then delegates to the shared functionsrc/transfer/transfersTaskRouterListener.ts(modified) — Removed privatetransitionAgentParticipantsfunction; now imports from shared modulesrc/router.ts(modified) — Registersconversation/transitionAgentParticipantsroute withvalidateFlexTokenRequest({ tokenMode: 'agent' })pipeline, matching the TokenValidator used in the original serverless versioninteractionChannelParticipants.tsand the new handler, including task-not-found (404), unauthorized (403), supervisor bypass, agent with valid reservation, and error propagation casesplugin-hrm-form changes
src/types/FeatureFlags.ts(modified) — Addeduse_twilio_lambda_to_transition_participantsflag; activateduse_twilio_lambda_transfersflag (previously commented out)src/services/twilioTaskService.ts(modified) —wrapupConversationTaskandcompleteConversationTasknow checkuse_twilio_lambda_to_transition_participants: when set, they call the new lambda/conversation/transitionAgentParticipantsendpoint withtaskSid/targetStatus; otherwise fall back to the legacy serverless endpoint.transferChatStartmoved here fromServerlessService.tswithuse_twilio_lambda_transfersflag routing to/transfer/transferStart(lambda) or/transferChatStart(legacy)src/services/ServerlessService.ts(modified) —transferChatStartremoved (moved totwilioTaskService.ts)src/transfer/setUpTransferActions.tsx(modified) — Updated import oftransferChatStartto use new location intwilioTaskServiceChecklist
Other Related Issues
None
Verification steps
use_twilio_lambda_to_transition_participantsfeature flag totrue.POST /lambda/twilio/account-scoped/{accountSid}/conversation/transitionAgentParticipantsendpoint transitions the specified agent participants in a Flex interaction channel to the requested status, with a valid agent Flex token that has a reservation on the task.wrapupConversationTaskandcompleteConversationTaskroute to the new lambda endpoint when the flag is enabled, and fall back to the legacy serverless endpoint when disabled.use_twilio_lambda_transfersfeature flag totrueand verify thattransferChatStartroutes to/transfer/transferStarton the lambda; confirm fallback to/transferChatStartwhen disabled.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
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.