CHI-3915-sms_post_call_survey_poc#4478
Open
stephenhand wants to merge 35 commits into
Open
Conversation
…ce and using Twilml
…ce and using Twilml
…ID and task SID in sync doc keyed by phone number
…Response Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
…te conferenceStatusCallbackEvent assertion Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
…an endpoint to start post surveys
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a proof-of-concept “post contact” (voice/chat) survey flow, introducing new service configuration attributes and new account-scoped lambda handlers/listeners to trigger Studio flows and persist survey answers to Insights + HRM.
Changes:
- Add
postStudioFlowsconfiguration and wire it into Flex conferencing behavior (endConferenceOnExit) to support post-call flows. - Introduce new account-scoped endpoints/listeners for starting post-survey capture and saving post-survey answers into Insights/HRM.
- Refactor/reuse conference participant classification logic (
isAgentInConference) across conference event handlers.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| twilio-iac/helplines/as/configs/service-configuration/production.json | Updates service configuration (currently introduces invalid JSON that must be fixed). |
| twilio-iac/helplines/as/configs/service-configuration/development.json | Enables postStudioFlows.voice in dev config for the POC. |
| plugin-hrm-form/src/types/twilio.ts | Adds a StudioFlowSID type. |
| plugin-hrm-form/src/hrmConfig.ts | Reads postStudioFlows from service configuration into HRM config. |
| plugin-hrm-form/src/conference/setUpConferenceActions.tsx | Adjusts conference options before accepting a task (callback + end-on-exit behavior). |
| plugin-hrm-form/src/components/Conference/ConferenceMonitor/index.tsx | Updates endConferenceOnExit monitoring logic to account for post-studio-flow behavior. |
| plugin-hrm-form/src/_tests/conference/setUpConferenceActions.test.ts | Updates tests for new conference option behavior/config fields. |
| lambdas/account-scoped/tests/unit/taskrouter/taskrouterEventHandler.test.ts | Extends Twilio mock to include twiml.VoiceResponse for new listener codepaths. |
| lambdas/account-scoped/src/taskrouter/index.ts | Registers the new post-studio-flow TaskRouter listener. |
| lambdas/account-scoped/src/router.ts | Adds new routes for saving post survey and starting post-survey chatbot. |
| lambdas/account-scoped/src/hrm/savePostSurvey.ts | New handler/utilities to persist post-survey answers to Insights + HRM. |
| lambdas/account-scoped/src/conference/stopRecordingWhenLastAgentLeaves.ts | Refactors agent-detection helper usage + renames conference event registration API. |
| lambdas/account-scoped/src/conference/setEndConferenceOnExit.ts | New conference join handler to adjust participant endConferenceOnExit when post flows are enabled. |
| lambdas/account-scoped/src/conference/isAgentInConference.ts | Extracted helper to identify agent participants. |
| lambdas/account-scoped/src/conference/conferenceStatusCallback.ts | Renames registration function and improves conference event logging. |
| lambdas/account-scoped/src/channelCapture/postSurveyListener.ts | Enhances post-survey trigger/init and adds an HTTP handler to start the chatbot. |
| lambdas/account-scoped/src/channelCapture/postStudioFlowTaskRouterListener.ts | New voice wrapup listener to kick off post-call Studio flow + stash context in Sync. |
| lambdas/account-scoped/src/channelCapture/hrmDataManipulation.ts | Deletes now-redundant HRM post-survey data manipulation helpers (moved to savePostSurvey). |
| lambdas/account-scoped/src/channelCapture/channelCaptureHandlers.ts | Switches post-survey completion handling to reuse savePostSurvey. |
| lambdas/account-scoped/src/channelCapture/captureChannelWithBot.ts | Updates to use getWorkspaceSid (renamed helper). |
| aselo-webchat-react-app/public/index.html | Removes local stylesheet include (currently likely breaks styling). |
Comment on lines
20
to
+22
| "permissionConfig": "demo", | ||
| "resources_base_url": "https://hrm-production.tl.techmatters.org" | ||
| "resources_base_url": "https://hrm-production.tl.techmatters.org", | ||
| "" |
| export type AccountSID =`AC${string}`; | ||
| export type WorkerSID = `WK${string}`; | ||
| export type TaskSID = typeof standaloneTaskSid | `${'WT'|'offline-contact-task'}${string}`; | ||
| export type StudioFlowSID = `FW${string}` |
| enableClientProfiles, | ||
| enableConferencing, | ||
| hideAddToNewCaseButton, | ||
| postStudioFlows: (postStudioFlows ?? {}) as { [key in 'voice' | 'chat']?: StudioFlowSID }, |
Comment on lines
+78
to
80
| import { handleSavePostSurvey } from './hrm/savePostSurvey'; | ||
| import {startPostSurveyChatbotHandler} from "./channelCapture/postSurveyListener"; | ||
|
|
| */ | ||
|
|
||
| import { AccountScopedHandler, HttpError } from '../httpTypes'; | ||
| import { newOk, Result } from '../Result'; |
Comment on lines
+42
to
+51
| if ( | ||
| isAgentInConference({ callSid, customerCallSid, participant }) && | ||
| participant.endConferenceOnExit | ||
| ) { | ||
| console.info( | ||
| `Post studio flows set up for voice on ${accountSid}, and ${callSid} is an agent in ${conferenceSid} with endConferenceOnExit set true so setting endConferenceOnExit to false for them`, | ||
| ); | ||
| await participant.update({ endConferenceOnExit: false }); | ||
| } else { | ||
| } |
Comment on lines
+72
to
+76
| // 1. Fetch all active participants in the conference | ||
| const { conference, contactId } = taskAttributes; | ||
| const conferenceContext = client.conferences.get(conference.sid); | ||
| if (taskChannelUniqueName === 'voice' && conference) { | ||
| // This task is a candidate to trigger post survey. Check feature flags for the account. |
Comment on lines
+39
to
+50
| const isTriggerPostStudioFlow = ({ | ||
| taskAttributes, | ||
| }: { | ||
| eventType: EventType; | ||
| taskChannelUniqueName: string; | ||
| taskAttributes: { | ||
| transferMeta?: TransferMeta; | ||
| isChatCaptureControl?: boolean; | ||
| }; | ||
| }) => { | ||
| return !isChatCaptureControlTask(taskAttributes); | ||
| }; |
| } | ||
| }; | ||
|
|
||
| registerTaskRouterEventHandler([TASK_WRAPUP], triggerPostStudioFlowTaskRouterListener); |
Comment on lines
28
to
31
| <link rel="shortcut icon" href="https://media.twiliocdn.com/sdk/js/webchat-v3/assets/favicon.ico"> | ||
| <title>Twilio Webchat React App</title> | ||
| <link rel="stylesheet" href="./app.css"> | ||
| <script defer src="./app.js"></script> | ||
| </head> |
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.
Description
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