Skip to content

refactor(channels): return uppercase Twilio channel type from get_channel_name#83

Open
xinghaohuang91 wants to merge 1 commit into
mainfrom
feat/uppercase-channel-type
Open

refactor(channels): return uppercase Twilio channel type from get_channel_name#83
xinghaohuang91 wants to merge 1 commit into
mainfrom
feat/uppercase-channel-type

Conversation

@xinghaohuang91

Copy link
Copy Markdown
Contributor

Summary

get_channel_name() now returns the uppercase ChannelType Literal ("SMS", "VOICE", "RCS", "WHATSAPP", "CHAT") that matches Twilio's channel enum, instead of a lowercase str. This lets the channel string flow through webhook filtering, API payloads, and session storage in a single consistent form — no more .upper()/.lower() juggling and no type-checker friction at ParticipantAddress(channel=...).

What changed:

  • Removed get_channel_type_upper() and every .upper()/.lower() conversion on the channel name.
  • Centralized the channel-type Literal, previously duplicated across 5 model fields, into one shared ChannelType alias in models/conversation.py.
  • Typed ConversationSession.channel and get_channel_name() as ChannelType.
  • Simplified the dashboard example (session.channel is now always populated, so the lowercase fallback helper was dead code).

⚠️ Breaking change: ConversationSession.channel and get_channel_name() now return uppercase (e.g. "SMS" not "sms"). Consumers comparing session.channel == "voice" must switch to "VOICE".

Type of Change

  • Breaking change
  • Refactoring

Checklist

  • Tests added/updated
  • Documentation updated
  • Tested E2E

SDK Parity

This is the Python SDK. This change affects shared channel-type behavior — the TypeScript SDK should be reviewed for parity.

  • Change is Python-specific (no TypeScript update needed)
  • TypeScript SDK PR created:

…nnel_name

get_channel_name() now returns the uppercase ChannelType Literal ("SMS",
"VOICE", etc.) matching Twilio's channel enum, instead of a lowercase str.
This removes the get_channel_type_upper() method and all the .upper()/.lower()
conversions scattered across webhook filtering, API payloads, and session
storage — the channel string now speaks one consistent form end to end.

- Centralize the duplicated channel Literal into a shared ChannelType alias
- Type session.channel and get_channel_name() as ChannelType
- BREAKING: ConversationSession.channel is now uppercase (e.g. "SMS" not "sms")
Copilot AI review requested due to automatic review settings July 10, 2026 21:31

Copilot AI left a comment

Copy link
Copy Markdown

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.

This PR standardizes channel identifiers across the Python SDK by having get_channel_name() and ConversationSession.channel use Twilio’s uppercase channel enum (via a shared ChannelType Literal), removing ad-hoc casing conversions and a now-redundant helper.

Changes:

  • Introduced a shared ChannelType alias and updated models to use it for channel fields.
  • Refactored channels to have get_channel_name() return uppercase ChannelType and removed get_channel_type_upper().
  • Updated tests and the dashboard example to expect/use uppercase channel strings consistently.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/tac/models/conversation.py Adds shared ChannelType Literal and reuses it in multiple model fields.
src/tac/models/session.py Types ConversationSession.channel as ChannelType with uppercase examples.
src/tac/models/memory.py Replaces duplicated channel Literal[...] with shared ChannelType.
src/tac/models/tac.py Replaces duplicated channel Literal[...] with shared ChannelType.
src/tac/channels/base.py Makes get_channel_name() return ChannelType and removes .upper() usage for filtering/logging.
src/tac/channels/messaging.py Removes get_channel_type_upper() and uses get_channel_name() for initiation.
src/tac/channels/{sms,rcs,whatsapp,chat}.py Updates get_channel_name() implementations to return uppercase ChannelType.
src/tac/channels/voice/channel.py Updates get_channel_name() to return "VOICE" as ChannelType.
src/tac/tools/handoff.py Updates voice channel comparison to "VOICE".
getting_started/examples/features/dashboard/dashboard.py Removes dead channel fallback and directly returns session.channel.
tests/* Updates expectations/fixtures from lowercase to uppercase channel strings and removes get_channel_type_upper() assertions.
Comments suppressed due to low confidence (1)

src/tac/channels/messaging.py:1

  • The class docstring still states get_channel_name() returns a lowercase channel name, but the refactor changes it to return uppercase Twilio channel types via ChannelType (e.g., "SMS", "RCS", "WHATSAPP", "CHAT"). Update this bullet (and any similar doc text in this file) to match the new contract so developers don’t implement/compare against lowercase values.
"""MessagingChannel base class for messaging channels (SMS, RCS, WhatsApp, Chat)."""

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants