Skip to content

Add VoiceOps name mapping fields#3870

Open
toddtarsi wants to merge 2 commits into
segmentio:mainfrom
voiceopshq:agent/voiceops-name-mappings
Open

Add VoiceOps name mapping fields#3870
toddtarsi wants to merge 2 commits into
segmentio:mainfrom
voiceopshq:agent/voiceops-name-mappings

Conversation

@toddtarsi

Copy link
Copy Markdown

What changed

Adds explicit optional name mapping fields to the VoiceOps Send Call Completed action:

  • customer_first_name
  • customer_last_name
  • agent_first_name
  • agent_last_name
  • assign_first_last_name_by_splitting_email

When email splitting is enabled, missing primary agent and agent-leg names are derived from the email local-part before the request is sent to VoiceOps. For example, ava-agent@voiceops.com derives Ava / Agent.

Why

VoiceOps customers need clearer mapping controls for customer and agent names, plus a fallback for deriving agent names from email addresses when names are not provided by the source event.

Compatibility

  • No new required fields.
  • Scope is limited to the VoiceOps integration.
  • Existing required call fields and validation remain unchanged.

Validation

  • corepack yarn build
  • TZ=UTC ./node_modules/.bin/jest --testPathPattern=voiceops --runInBand -u
  • git diff --check

Note: the local pre-commit hook could not run because it invokes yarn directly and yarn is not on PATH in this shell; the equivalent build/test checks above were run manually.

Segment review note

Before marking this ready for review, attach an Action Tester video showing the new mapping fields and email-splitting behavior with a realistic Call Completed payload.

Copilot AI review requested due to automatic review settings July 9, 2026 20:26

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

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds explicit name-mapping fields and an optional “split agent names from email” fallback for the VoiceOps Send Call Completed action, so customers can control customer/agent naming and fill missing agent names when upstream events only contain emails.

Changes:

  • Introduces customer_* and agent_* mapping fields plus assign_first_last_name_by_splitting_email.
  • Implements derivation of missing agent + agent-leg names from email local-part before validation/request.
  • Updates generated payload types and expands Jest coverage + snapshots for the new behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/destination-actions/src/destinations/voiceops/sendCallCompleted/index.ts Adds new mapping fields, email-splitting name derivation, and uses derived payload during perform.
packages/destination-actions/src/destinations/voiceops/sendCallCompleted/generated-types.ts Updates Payload typings to include new fields and makes agent-leg names optional.
packages/destination-actions/src/destinations/voiceops/sendCallCompleted/tests/index.test.ts Adds tests for name forwarding and email-derived names; updates prior test naming/expectations.
packages/destination-actions/src/destinations/voiceops/sendCallCompleted/tests/snapshots/snapshot.test.ts.snap Updates action snapshot to reflect new fields.
packages/destination-actions/src/destinations/voiceops/tests/snapshots/snapshot.test.ts.snap Updates destination snapshot to reflect new fields.

Comment on lines +23 to +26
return {
first_name: titleCase(nameParts[0]),
last_name: nameParts.length > 1 ? nameParts.slice(1).map(titleCase).join(' ') : undefined
}
Comment on lines 279 to 288
first_name: {
label: 'First Name',
description: 'The first name of the agent for this call leg.',
type: 'string',
required: true
type: 'string'
},
last_name: {
label: 'Last Name',
description: 'The last name of the agent for this call leg.',
type: 'string',
required: true
type: 'string'
}
Copilot AI review requested due to automatic review settings July 10, 2026 11:44
@toddtarsi toddtarsi force-pushed the agent/voiceops-name-mappings branch from 798e726 to 5362ee8 Compare July 10, 2026 11:44

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

packages/destination-actions/src/destinations/voiceops/sendCallCompleted/index.ts:84

  • With the new assign_first_last_name_by_splitting_email feature, these validation errors can become less actionable when names are omitted intentionally (expecting derivation) but derivation fails (e.g., missing/invalid agent_email on a leg). Consider updating the error text to mention the derivation option and the requirement for a valid agent_email when names are not provided (e.g., 'Provide agentLegs.first_name or enable email splitting and supply agentLegs.agent_email').
  for (const agentLeg of payload.agentLegs ?? []) {
    if (!agentLeg.first_name?.trim()) {
      throw new PayloadValidationError('agentLegs.first_name is required for every agent leg entry.')
    }

    if (!agentLeg.last_name?.trim()) {
      throw new PayloadValidationError('agentLegs.last_name is required for every agent leg entry.')
    }
  }

Comment on lines +130 to +137
customer_first_name: {
label: 'Customer First Name',
description: 'The first name for the customer.',
type: 'string',
default: {
'@path': '$.properties.customer_first_name'
}
},
Comment on lines +146 to +161
agent_first_name: {
label: 'Agent First Name',
description: 'The first name for the primary handling agent.',
type: 'string',
default: {
'@path': '$.properties.first_name'
'@path': '$.properties.agent_first_name'
}
},
last_name: {
label: 'Last Name',
agent_last_name: {
label: 'Agent Last Name',
description: 'The last name for the primary handling agent.',
type: 'string',
default: {
'@path': '$.properties.last_name'
'@path': '$.properties.agent_last_name'
}
},
Comment on lines +15 to +21
function splitNameFromEmail(email?: string): { first_name?: string; last_name?: string } {
const localPart = email?.split('@')[0]?.split('+')[0]
const nameParts = localPart?.split(/[^a-zA-Z0-9]+/).filter(Boolean) ?? []

if (nameParts.length === 0) {
return {}
}
Comment on lines +11 to +13
function titleCase(value: string): string {
return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase()
}
Copilot AI review requested due to automatic review settings July 10, 2026 12:00

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment on lines +150 to +165
agent_first_name: {
label: 'Agent First Name',
description: 'The first name for the primary handling agent.',
type: 'string',
default: {
'@path': '$.properties.first_name'
'@path': '$.properties.agent_first_name'
}
},
last_name: {
label: 'Last Name',
agent_last_name: {
label: 'Agent Last Name',
description: 'The last name for the primary handling agent.',
type: 'string',
default: {
'@path': '$.properties.last_name'
'@path': '$.properties.agent_last_name'
}
},
Comment on lines +83 to 87
if (agentLeg.last_name === undefined || agentLeg.last_name === null) {
throw new PayloadValidationError(
'agentLegs.last_name is required for every agent leg entry. Provide first_name and last_name, or enable assign_first_last_name_by_splitting_email and provide an agent_email that can be split. Single-token email local-parts derive an empty last_name.'
)
}
Comment on lines +36 to +39
/**
* When enabled, missing agent first and last names are derived from agent email addresses by splitting the email local-part.
*/
assign_first_last_name_by_splitting_email?: boolean
@toddtarsi toddtarsi marked this pull request as ready for review July 10, 2026 12:38
@toddtarsi toddtarsi requested a review from a team as a code owner July 10, 2026 12:38
@toddtarsi

Copy link
Copy Markdown
Author

Video of test:

bf1496384aac109e26b89d1ab0529d13.webm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants