Skip to content

CHI-3915-sms_post_call_survey_poc#4478

Open
stephenhand wants to merge 35 commits into
masterfrom
CHI-3915-sms_post_call_survey_poc
Open

CHI-3915-sms_post_call_survey_poc#4478
stephenhand wants to merge 35 commits into
masterfrom
CHI-3915-sms_post_call_survey_poc

Conversation

@stephenhand

Copy link
Copy Markdown
Collaborator

Description

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

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

stephenhand and others added 30 commits June 11, 2026 11:50
…ID and task SID in sync doc keyed by phone number
…Response

Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 19, 2026 15:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 postStudioFlows configuration 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>
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.

3 participants