Documentation
¶
Overview ¶
Package webhook provides HTTP webhook handling for Twilio and Telnyx callbacks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Port is the HTTP server port.
Port int
// TwilioAuthToken is used to validate Twilio webhook signatures.
TwilioAuthToken string
// TelnyxPublicKey is used to validate Telnyx webhook signatures (optional).
TelnyxPublicKey string
// Logger for server logging.
Logger *slog.Logger
}
Config configures the webhook server.
type SMSHandler ¶
type SMSHandler func(ctx context.Context, msg SMSMessage) error
SMSHandler is called when an SMS message is received.
type SMSMessage ¶
type SMSMessage struct {
ID string
From string
To string
Body string
Provider string // "twilio" or "telnyx"
Timestamp time.Time
RawPayload map[string]string
}
SMSMessage represents an incoming SMS message from a webhook.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server handles incoming webhooks from Twilio and Telnyx.
func (*Server) OnSMS ¶
func (s *Server) OnSMS(handler SMSHandler)
OnSMS registers a handler for incoming SMS messages.
func (*Server) OnVoice ¶
func (s *Server) OnVoice(handler VoiceHandler)
OnVoice registers a handler for voice events.
type VoiceEvent ¶
type VoiceEvent struct {
CallID string
Status string // "initiated", "ringing", "answered", "completed", "busy", "no-answer", "failed"
From string
To string
Direction string
Duration int // seconds, for completed calls
RecordingURL string
Provider string
Timestamp time.Time
RawPayload map[string]string
}
VoiceEvent represents a voice call status event.
type VoiceHandler ¶
type VoiceHandler func(ctx context.Context, event VoiceEvent) error
VoiceHandler is called when a voice event is received.
Click to show internal directories.
Click to hide internal directories.