-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Context
The current SmsService trait abstracts sending SMS messages to phone numbers:
trait SmsService {
def sendMessage(recipients: Seq[PhoneNumber], message: String): Task[Unit]
}For Entrance Group, this means every outbound message creates a new "manual campaign" via the Create Campaign API. This is a workaround — Entrance Group's API is designed around channels, not phone numbers. The intended flow is:
- A conversation happens on a channel (identified by
channel_id) - You send replies to that channel, not by specifying a phone number
When we receive an incoming webhook, the payload includes channel_id (see #69 for full payload documentation). We should be able to reply on that same channel.
Proposal
Make the message target generic so it can be a phone number, a channel ID, or other identifiers. This could work several ways:
Option A: Generic target type
trait MessagingService[Target] {
def sendMessage(recipients: Seq[Target], message: String): Task[Unit]
}
// Phone-number based (Twilio, current Entrance Group workaround)
type SmsService = MessagingService[PhoneNumber]
// Channel-based (Entrance Group proper API)
type ChannelMessagingService = MessagingService[ChannelId]This is also forward-looking: the same pattern could support email addresses, WhatsApp group IDs, GroupMe member/group IDs, etc.
Option B: Entrance Group-specific channel send
Add a channel-based send method to the Entrance Group implementation specifically, alongside the existing phone-number based API.
Motivation
- Avoids creating a new campaign for every single outbound message
- Aligns with how Entrance Group's API is intended to be used
- Opens the door for other messaging targets (email, WhatsApp, GroupMe)
- The
channel_idis already available in the incoming webhook payload (Document Entrance Group webhook payload and add incoming message support #69)