Migrate Telegram, Modica, and Line custom channels to account-scoped lambda#3962
Migrate Telegram, Modica, and Line custom channels to account-scoped lambda#3962
Conversation
…lambda Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
stephenhand
left a comment
There was a problem hiding this comment.
Add extra logging to each of these channels to assist debugging
| accountSid: AccountSID, | ||
| ) => { | ||
| console.info('==== FlexToLine handler ===='); | ||
| console.info('Received event:', event); |
There was a problem hiding this comment.
Should be a debug log
| accountSid: AccountSID, | ||
| ) => { | ||
| console.info('==== FlexToModica handler ===='); | ||
| console.info('Received event:', event); |
There was a problem hiding this comment.
Should be a debug log
| accountSid: AccountSID, | ||
| ) => { | ||
| console.info('==== ModicaToFlex handler ===='); | ||
| console.info('Received event:', body); |
There was a problem hiding this comment.
Should be a debug log
| accountSid: AccountSID, | ||
| ) => { | ||
| console.info('==== FlexToTelegram handler ===='); | ||
| console.info('Received event:', event); |
There was a problem hiding this comment.
Should be a debug log
…ed event logs to debug level Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Added extra |
| getSsmParameter( | ||
| `/${process.env.NODE_ENV}/twilio/${accountSid}/${channelName}_studio_flow_sid`, | ||
| ); | ||
|
|
There was a problem hiding this comment.
These SSM parameter names are all wrong, see https://github.com/techmatters/serverless/blob/master/.github/actions/custom-actions/aselo_development_custom/action.yml for examples of correct naming for these parameters
There was a problem hiding this comment.
Fixed in 6d0d0b1. The SSM paths now use the channel name as the service segment (e.g. /development/telegram/{accountSid}/bot_api_secret_token, /development/modica/{accountSid}/app_name, /development/line/{accountSid}/channel_secret) matching the pattern in the serverless action.yml.
…tch serverless naming convention Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
stephenhand
left a comment
There was a problem hiding this comment.
Fix the linter errors from the last run
Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Fixed in 03aa1df. The CI's prettier (printWidth: 90) wanted the 3 functions with shorter SSM paths ( |
stephenhand
left a comment
There was a problem hiding this comment.
include the same support for testSessionId that the instagram custom channel supports in the 3 channels being migrated in this PR
Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Done in 2c8a806. Changes made:
|
Migrates Telegram, Modica, and Line custom channel webhook handlers from the serverless repo into the account-scoped lambda, following the existing Instagram pattern. Only Twilio Conversations API is supported (no Programmable Chat).
Description
New channel handlers (
src/customChannels/{telegram,modica,line}/):telegramToFlex/flexToTelegram— validatesX-Telegram-Bot-Api-Secret-Tokenheader; sends via Telegram Bot APImodicaToFlex/flexToModica— no inbound auth (Modica doesn't provide one); sends via Basic Auth REST API with E.164 phone number sanitizationlineToFlex/flexToLine— validatesx-line-signatureHMAC SHA256 (with emoji Unicode escaping); handles batched events; sends via Line Messaging API withBearertoken + per-messageX-Line-Retry-KeyConfiguration (
configuration.ts):/${NODE_ENV}/{channel}/${accountSid}/<param>(e.g./development/telegram/{accountSid}/bot_api_secret_token,/development/modica/{accountSid}/app_name,/development/line/{accountSid}/channel_secret)Router (
router.ts):validateWebhookRequest— same pattern as InstagramTests: Unit tests for all 6 handlers covering auth validation, missing parameters, ignored events, correct external API calls, and
testSessionIdrouting behaviour.Logging: Added
console.debuglogging at key processing points in all 6 handlers (validated event body, computed identifiers, result status). "Received event" logs are atdebuglevel to avoid noise ininfologs.Integration test support (
testSessionId): All 3 migrated channels now include the sametestSessionIdsupport as the Instagram channel:telegramToFlex,modicaToFlex,lineToFlex):testSessionIdis accepted in the request body and forwarded tosendConversationMessageToFlex, where it is stored in conversation attributes and used to redirect outbound messages during integration tests.flexToTelegram,flexToLine): already supportedtestSessionIdvia the sharedredirectConversationMessageToExternalChathelper.flexToModica: updatedsendModicaMessageto accepttestSessionId; when set, messages are redirected toTEST_SEND_URLand thex-webhook-receiver-session-idheader is included.Checklist
Other Related Issues
None
Verification steps
Deploy the account-scoped lambda and configure SSM parameters for each channel using the channel-scoped path convention:
/{env}/telegram/{accountSid}/bot_api_secret_token,/{env}/telegram/{accountSid}/flex_bot_token/{env}/modica/{accountSid}/app_name,/{env}/modica/{accountSid}/app_password/{env}/line/{accountSid}/channel_secret,/{env}/line/{accountSid}/channel_access_tokenPoint each channel's webhook URL at the corresponding
customChannels/{channel}/{channel}ToFlexendpoint and verify end-to-end message flow.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.