Migrate send message serverless endpoints into lambdas/account-scoped#3973
Draft
Migrate send message serverless endpoints into lambdas/account-scoped#3973
Conversation
…onversation folder Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Migrate send message serverless endpoints into lambdas
Migrate send message serverless endpoints into lambdas/account-scoped
Feb 27, 2026
stephenhand
requested changes
Feb 27, 2026
Collaborator
stephenhand
left a comment
There was a problem hiding this comment.
Fix the linter error raised in the last CI run
Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Contributor
Author
Fixed in commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports three Twilio Serverless functions (
sendSystemMessage,sendStudioMessage,sendMessageAndRunJanitor) intolambdas/account-scoped/src/conversation/, following the same migration patterns asgetTaskAndReservations.Changes
conversation/sendSystemMessage.ts— Sends a system message to a conversation, chat channel, or a task's associated channel. Replacescontext.*env vars withgetChatServiceSid/getWorkspaceSidlookups; returnsResult<HttpError, any>instead of serverless callback. Registered withvalidateFlexTokenRequest({ tokenMode: 'agent' })(wasTokenValidator-wrapped).conversation/sendStudioMessage.ts— Removes the studio webhook on a channel before callingsendSystemMessageto prevent Studio re-triggering. Registered withvalidateWebhookRequest(was.protected.ts).conversation/sendMessageAndRunJanitor.ts— Removes studio webhooks, sends a system message, then runschatChannelJanitorto close the conversation/channel. Supports bothconversationSidandchannelSidpaths. Registered withvalidateWebhookRequest(was.protected.ts).router.ts— Adds three new routes underconversation/sendSystemMessage,conversation/sendStudioMessage, andconversation/sendMessageAndRunJanitor.Unit tests added for all three handlers covering validation errors, happy paths, and error propagation.
Checklist
Other Related Issues
None
Verification steps
Deploy and invoke each endpoint via the account-scoped Lambda path:
POST /lambda/twilio/account-scoped/{accountSid}/conversation/sendSystemMessagewith a valid Flex token and aconversationSid/channelSid/taskSid+messagePOST /lambda/twilio/account-scoped/{accountSid}/conversation/sendStudioMessagewith a Twilio-signed request and achannelSid+messagePOST /lambda/twilio/account-scoped/{accountSid}/conversation/sendMessageAndRunJanitorwith a Twilio-signed request and aconversationSidorchannelSid+message— verify the conversation/channel is deactivated after the callAFTER 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
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.