Add optional twilio-call-format config option

To be able to set custom TwiML send to the Call API.
This commit is contained in:
Michael Nowak
2025-03-11 09:45:32 +00:00
parent 630f2957de
commit 950ba1e2e1
5 changed files with 96 additions and 1 deletions

View File

@@ -14,7 +14,7 @@ import (
)
const (
twilioCallFormat = `
defaultTwilioCallFormat = `
<Response>
<Pause length="1"/>
<Say loop="3">
@@ -65,6 +65,10 @@ func (s *Server) callPhone(v *visitor, r *http.Request, m *message, to string) {
if u != nil {
sender = u.Name
}
twilioCallFormat := defaultTwilioCallFormat
if len(s.config.TwilioCallFormat) > 0 {
twilioCallFormat = s.config.TwilioCallFormat
}
body := fmt.Sprintf(twilioCallFormat, xmlEscapeText(m.Topic), xmlEscapeText(m.Message), xmlEscapeText(sender))
data := url.Values{}
data.Set("From", s.config.TwilioPhoneNumber)