Skip to content

Migrate send message serverless endpoints into lambdas/account-scoped#3973

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/migrate-send-message-endpoints
Draft

Migrate send message serverless endpoints into lambdas/account-scoped#3973
Copilot wants to merge 3 commits intomasterfrom
copilot/migrate-send-message-endpoints

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

Ports three Twilio Serverless functions (sendSystemMessage, sendStudioMessage, sendMessageAndRunJanitor) into lambdas/account-scoped/src/conversation/, following the same migration patterns as getTaskAndReservations.

Changes

  • conversation/sendSystemMessage.ts — Sends a system message to a conversation, chat channel, or a task's associated channel. Replaces context.* env vars with getChatServiceSid/getWorkspaceSid lookups; returns Result<HttpError, any> instead of serverless callback. Registered with validateFlexTokenRequest({ tokenMode: 'agent' }) (was TokenValidator-wrapped).

  • conversation/sendStudioMessage.ts — Removes the studio webhook on a channel before calling sendSystemMessage to prevent Studio re-triggering. Registered with validateWebhookRequest (was .protected.ts).

  • conversation/sendMessageAndRunJanitor.ts — Removes studio webhooks, sends a system message, then runs chatChannelJanitor to close the conversation/channel. Supports both conversationSid and channelSid paths. Registered with validateWebhookRequest (was .protected.ts).

  • router.ts — Adds three new routes under conversation/sendSystemMessage, conversation/sendStudioMessage, and conversation/sendMessageAndRunJanitor.

  • Unit tests added for all three handlers covering validation errors, happy paths, and error propagation.

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

Deploy and invoke each endpoint via the account-scoped Lambda path:

  • POST /lambda/twilio/account-scoped/{accountSid}/conversation/sendSystemMessage with a valid Flex token and a conversationSid/channelSid/taskSid + message
  • POST /lambda/twilio/account-scoped/{accountSid}/conversation/sendStudioMessage with a Twilio-signed request and a channelSid + message
  • POST /lambda/twilio/account-scoped/{accountSid}/conversation/sendMessageAndRunJanitor with a Twilio-signed request and a conversationSid or channelSid + message — verify the conversation/channel is deactivated after the call

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 the send message serverless endpoints into the lambdas/account-scoped</issue_title>
<issue_description>## Description

Migrate the following 3 twilio serverless endpoints into the lambdas/account-scoped

https://github.com/techmatters/serverless/blob/master/functions/sendMessageAndRunJanitor.ts
https://github.com/techmatters/serverless/blob/master/functions/sendStudioMessage.ts
https://github.com/techmatters/serverless/blob/master/functions/sendSystemMessage.ts

Place these in the conversation folder

Additional context

Follow the same patterns as for other endpoints that have been migrated

For example, https://github.com/techmatters/serverless/blob/master/functions/getTaskAndReservations.ts was recently migrated to https://github.com/techmatters/flex-plugins/blob/master/lambdas/account-scoped/src/task/getTaskAndReservations.ts

Note how when a TokenValidator wrapper is used in the serverless version, a validateFlexTokenRequest item needs to be added to the request pipeline for the route in account-scoped
</issue_description>

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


🔒 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.

…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
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.

Fix the linter error raised in the last CI run

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

Copilot AI commented Feb 27, 2026

Fix the linter error raised in the last CI run

Fixed in commit 1640356. Prettier required a line break in the long error message string in sendSystemMessage.ts.

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 the send message serverless endpoints into the lambdas/account-scoped

2 participants