CHI-3711: POC for voice and sms E2E tests - CI only - #4547
Conversation
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
…nt/AsyncIterable pattern Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
…basic-sms-test-methods
- Add SMS channel to twilio-iac/helplines/e2e/development.hcl using the messaging-lex-v3-blocking-lambda.tftpl template (same as aselo_webchat) and an empty contact_identity (conversations address managed separately) - Create twilio-iac/helplines/e2e/files/additional.configure.tf that uses a Twilio data source to look up the only phone number attached to the account at apply time and creates the SMS conversations address linked to the SMS studio flow - Guard twilio_conversations_configuration_addresses_v1 in channels/v1/main.tf so channels with an empty contact_identity skip automatic address creation (allowing helpline-specific additional.tf to manage it instead) Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
…basic-sms-test-methods
- Replace dynamic phone number lookup with hardcoded +12607821891 in both development.hcl and additional.configure.tf - Remove data source that previously scraped the phone number from the Twilio account - Set contact_identity to the hardcoded phone number in the SMS channel configuration Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
The twilio-iac/terraform-modules/channels/v1/main.tf module now automatically creates the SMS conversations address since contact_identity is no longer empty. The separate additional.configure.tf file is no longer needed. Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
- Add voice channel using voice-no-chatbot-operating-hours-blocking-lambda template - Use the same phone number (+12607821891) as the SMS channel - Include voice_ivr_greeting_message, voice_ivr_blocked_message, and voice_ivr_language - Follows established patterns used in other helplines for voice configurations Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
… CHI-3711-voice_test_poc
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
…nt/AsyncIterable pattern Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
- Add SMS channel to twilio-iac/helplines/e2e/development.hcl using the messaging-lex-v3-blocking-lambda.tftpl template (same as aselo_webchat) and an empty contact_identity (conversations address managed separately) - Create twilio-iac/helplines/e2e/files/additional.configure.tf that uses a Twilio data source to look up the only phone number attached to the account at apply time and creates the SMS conversations address linked to the SMS studio flow - Guard twilio_conversations_configuration_addresses_v1 in channels/v1/main.tf so channels with an empty contact_identity skip automatic address creation (allowing helpline-specific additional.tf to manage it instead) Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
- Add voice channel using voice-no-chatbot-operating-hours-blocking-lambda template - Use the same phone number (+12607821891) as the SMS channel - Include voice_ivr_greeting_message, voice_ivr_blocked_message, and voice_ivr_language - Follows established patterns used in other helplines for voice configurations Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
…I-3711-voice_test_poc # Conflicts: # e2e-tests/tests/offlineContact.spec.ts
… CHI-3711-voice_test_poc
There was a problem hiding this comment.
Pull request overview
Adds WIP support for voice end-to-end testing by extending Twilio TaskRouter/IaC configuration, adding a new voice filtering lambda, and expanding Playwright E2E utilities/tests to cover voice and SMS via Conversations.
Changes:
- Add a new TaskRouter workflow filter + queue for “Voice E2E Test” routing.
- Introduce
voice/filterCountryOrVoIPaccount-scoped lambda (with unit tests) and route wiring. - Add/adjust Playwright E2E helpers and specs for voice calling, SMS Conversations flow, and more reusable contact form filling.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| twilio-iac/helplines/templates/workflows/master.tftpl | Adds a new “Voice E2E Test” routing filter targeting a new queue |
| twilio-iac/helplines/e2e/development.hcl | Expands E2E routing filter expression to include voice and SMS |
| twilio-iac/helplines/e2e/common.hcl | Adds e2e_test_voice task queue for the E2E helpline config |
| twilio-iac/helplines/defaults.hcl | Adds e2e_test_voice task queue to global defaults |
| lambdas/account-scoped/tests/unit/voice/filterCountryOrVoIP.test.ts | Unit tests for the new voice filtering handler |
| lambdas/account-scoped/src/voice/filterCountryOrVoIP.ts | New handler to block non-US and VoIP/blocked-carrier callers via Twilio Lookups |
| lambdas/account-scoped/src/router.ts | Wires the new voice/filterCountryOrVoIP route into the router |
| e2e-tests/workerStatus.ts | Improves worker status-setting robustness and logging |
| e2e-tests/twilio/voice.ts | Adds helper to initiate a voice call into the service under test |
| e2e-tests/twilio/sms.ts | Reworks SMS E2E to use Twilio Conversations (stateful conversation SID) |
| e2e-tests/twilio/channels.ts | Adds cleanup utilities for SMS conversations and migrates chat cleanup to Conversations APIs |
| e2e-tests/tests/voice.spec.ts | New Playwright voice E2E spec that accepts a task and submits a contact form |
| e2e-tests/tests/sms.spec.ts | Updates SMS spec to use new contact-form helper + conversation cleanup |
| e2e-tests/tests/offlineContact.spec.ts | Refactors offline-contact spec to reuse form content helpers |
| e2e-tests/tests/aseloWebchat.spec.ts | Refactors webchat spec to reuse contact-form helper |
| e2e-tests/playwright.config.ts | Adds fake media-stream args for local runs and deduplicates args setup |
| e2e-tests/package.json | Updates scripts for conversation cleanup and local retry behavior |
| e2e-tests/formContentsByHelpline.ts | Adjusts form content and introduces an “empty form” variant map |
| e2e-tests/deleteConversations.ts | Updates cleanup script to delete both chat and SMS conversations |
| e2e-tests/contactForm.ts | Adds fillWithContent helper to reuse a consistent tab-filling sequence |
| "filter_friendly_name": "Voice E2E Test", | ||
| "expression": "channelType=='voice' AND name=='+12064083885'", | ||
| "targets": [ | ||
| { | ||
| "expression": "(worker.waitingOfflineContact != true AND ((task.channelType == 'voice' AND worker.channel.chat.assigned_tasks == 0) OR (task.channelType != 'voice' AND worker.channel.voice.assigned_tasks == 0)) AND ((task.transferTargetType == 'worker' AND task.targetSid == worker.sid) OR (task.transferTargetType != 'worker' AND worker.sid != task.ignoreAgent))) OR (worker.waitingOfflineContact == true AND task.targetSid == worker.sid AND task.isContactlessTask == true)", |
| export const makeCallToService = async () => { | ||
| const clientAccountSid = getConfigValue('clientTwilioAccountSid') as string; | ||
| const authToken = getConfigValue('clientTwilioAuthToken') as string; | ||
| const from = getConfigValue('clientSmsPhoneNumber') as string; |
| participants.some((participant) => { | ||
| return ( | ||
| participant.messagingBinding?.address === fromNumber && | ||
| participant.messagingBinding?.proxy_address === toNumber | ||
| ); | ||
| }) |
| // Tracks the start of the current SMS test session so we only check messages received after this time | ||
| let sessionStartTime: Date | undefined; | ||
|
|
||
| let clientConversationSid: string; |
| const helpline = getConfigValue('helplineShortCode') as keyof typeof formContentsByHelpline; | ||
| const formContent = formContentsByHelplineForEmptyForm[helpline]; | ||
|
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…I-3711-voice_test_poc
gpaoloni
left a comment
There was a problem hiding this comment.
LGTM 🚀
Do we have documentation on how to setup/configure the e2e tests for accounts somewhere? If so, could that be linked somewhere in the 2e README?
| // Delete conversations from service Twilio account | ||
| await deleteSmsConversationFromOneEnd( | ||
| serviceAccountSid, | ||
| serviceAuthToken, | ||
| senderSmsNumber, | ||
| serviceSmsNumber, | ||
| ); | ||
|
|
||
| // Delete conversations from sender Twilio account | ||
| await deleteSmsConversationFromOneEnd( | ||
| senderAccountSid, | ||
| senderAuthToken, | ||
| serviceSmsNumber, | ||
| senderSmsNumber, | ||
| ); |
There was a problem hiding this comment.
About this, I understand the "client account" is the one we use to send SMS messages. I see that is defined via config but in practice what account will be used for this?
There was a problem hiding this comment.
I'm just using AS_DEV for now
Description
This creates a POC for testing SMS and Voice calls with E2E tests
Checklist
Other Related Issues
None
Verification steps
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