twiml

package
v0.0.0-...-030a493 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package twiml provides Twilio Markup Language support for building web services with instructions for twilio how to handle incoming call or message.

Index

Constants

View Source
const (
	TwiMan     = "man"
	TwiWoman   = "woman"
	TwiEnglish = "en"
	TwiBritish = "en-gb"
	TwiSpanish = "es"
	TwiFrench  = "fr"
	TwiGerman  = "de"
	// --------------------------
	TwiAlice              = "alice"
	TwiDanishDenmark      = "da-DK"
	TwiGermanGermany      = "de-DE"
	TwiEnglishAustralia   = "en-AU"
	TwiEnglishCanada      = "en-CA"
	TwiEnglishUK          = "en-UK"
	TwiEnglishIndia       = "en-IN"
	TwiEnglishUSA         = "en-US"
	TwiSpanishCatalan     = "ca-ES"
	TwiSpanishSpain       = "es-ES"
	TwiSpanishMexico      = "es-MX"
	TwiFinishFinland      = "fi-FI"
	TwiFrenchCanada       = "fr-CA"
	TwiFrenchFrance       = "fr-FR"
	TwiItalianItaly       = "it-IT"
	TwiJapaneseJapan      = "ja-JP"
	TwiKoreanKorea        = "ko-KR"
	TwiNorwegianNorway    = "nb-NO"
	TwiDutchNetherlands   = "nl-NL"
	TwiPolishPoland       = "pl-PL"
	TwiPortugueseBrazil   = "pt-BR"
	TwiPortuguesePortugal = "pt-PT"
	TwiRussianRussia      = "ru-RU"
	TwiSwedishSweden      = "sv-SE"
	TwiChineseMandarin    = "zh-CH"
	TwiChineseCantonese   = "zh-HK"
	TwiChineseTaiwanese   = "zh-TW"
)
View Source
const (
	TwiCallSid       = "CallSid"
	TwiAccountSid    = "AccountSid"
	TwiFrom          = "From"
	TwiTo            = "To"
	TwiCallStatus    = "CallStatus"
	TwiApiVersion    = "ApiVersion"
	TwiDirection     = "Direction"
	TwiForwardedFrom = "ForwardedFrom"
	TwiCallerName    = "CallerName"
	// Geographic data
	TwiFromCity    = "FromCity"
	TwiFromState   = "FromState"
	TwiFromZip     = "FromZip"
	TwiFromCountry = "FromCountry"
	TwiToCity      = "ToCity"
	TwiToState     = "ToState"
	TwiToZip       = "ToZip"
	TwiToCountry   = "Tocountry"
	//  Status callback
	TwiCallDuration      = "CallDuration"
	TwiRecordingUrl      = "RecordingUrl"
	TwiRecordingSid      = "RecordingSid"
	TwiRecordingDuration = "RecordingDuration"
	// Below parameters are included in AddCallerId request response
	TwiVerificationStatus  = "VerificationStatus"
	TwiOutgoingCallerIdSid = "OutgoingCallerIdSid"
)

Twilio callback status parameters for: Call End Callback (StatusCallback), Voice Request

View Source
const (
	TwiQueued     = "queued"
	TwiRinging    = "ringing"
	TwiInProgress = "in-progress"
	TwiCompleted  = "completed"
	TwiBusy       = "busy"
	TwiFailed     = "failed"
	TwiNoAnswer   = "no-answer"
	TwiCanceled   = "canceled"
)

Call status

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	XMLName        xml.Name `xml:"Client"`
	Method         string   `xml:"method,attr,omitempty"`
	Url            string   `xml:"URL,omitempty"`
	StatusCallback string   `xml:"statusCallback,attr,omitempty"`
	Name           string   `xml:",chardata"`
}

type Conference

type Conference struct {
	XMLName                xml.Name `xml:"Conference"`
	Muted                  bool     `xml:"muted,attr,omitempty"`
	Beep                   string   `xml:"beep,attr,omitempty"`
	StartConferenceOnEnter bool     `xml:"startConferenceOnEnter,attr,omitempty"`
	EndConferenceOnExit    bool     `xml:"endConferenceOnExit,attr,omitempty"`
	WaitUrl                string   `xml:"waitUrl,attr,omitempty"`
	WaitMethod             string   `xml:"waitMethod,attr,omitempty"`
	MaxParticipants        int      `xml:"maxParticipants,attr,omitempty"`
	Name                   string   `xml:",chardata"`
}

type Dial

type Dial struct {
	XMLName        xml.Name `xml:"Dial"`
	Action         string   `xml:"action,attr,omitempty"`
	Method         string   `xml:"method,attr,omitempty"`
	Timeout        int      `xml:"timeout,attr,omitempty"`
	HangupOnStar   bool     `xml:"hangupOnStar,attr,omitempty"`
	TimeLimit      int      `xml:"timeLimit,attr,omitempty"`
	CallerId       string   `xml:"callerId,attr,omitempty"`
	Record         bool     `xml:"record,attr,omitempty"`
	AnswerOnBridge bool     `xml:"answerOnBridge,attr,omitempty"`
	Number         string   `xml:",chardata"`
	Nested         []interface{}
}

type Enqueue

type Enqueue struct {
	XMLName       xml.Name `xml:"Enqueue"`
	Action        string   `xml:"action,attr,omitempty"`
	Method        string   `xml:"method,attr,omitempty"`
	WaitUrl       string   `xml:"waitUrl,attr,omitempty"`
	WaitUrlMethod string   `xml:"waitUrlMethod,attr,omitempty"`
	Name          string   `xml:",chardata"`
}

type Gather

type Gather struct {
	XMLName             xml.Name `xml:"Gather"`
	Action              string   `xml:"action,attr,omitempty"`
	Method              string   `xml:"method,attr,omitempty"`
	Timeout             int      `xml:"timeout,attr,omitempty"`
	FinishOnKey         string   `xml:"finishOnKey,attr,omitempty"`
	NumDigits           int      `xml:"numDigits,attr,omitempty"`
	ActionOnEmptyResult bool     `xml:"actionOnEmptyResult,attr,omitempty"`
	Nested              []interface{}
}

type Hangup

type Hangup struct {
	XMLName xml.Name `xml:"Hangup"`
}

type Leave

type Leave struct {
	XMLName xml.Name `xml:"Leave"`
}

type Message

type Message struct {
	XMLName        xml.Name `xml:"Message"`
	To             string   `xml:"to,attr,omitempty"`
	From           string   `xml:"from,attr,omitempty"`
	Action         string   `xml:"action,attr,omitempty"`
	Method         string   `xml:"method,attr,omitempty"`
	StatusCallback string   `xml:"statusCallback,attr,omitempty"`
	Body           string   `xml:"Body,omitempty"`
	Media          string   `xml:"Media,omitempty"`
}

type Number

type Number struct {
	XMLName              xml.Name `xml:"Number"`
	SendDigits           string   `xml:"sendDigits,attr,omitempty"`
	Url                  string   `xml:"url,attr,omitempty"`
	Method               string   `xml:"method,attr,omitempty"`
	Number               string   `xml:",chardata"`
	StatusCallback       string   `xml:"statusCallback,attr,omitempty"`
	StatusCallbackEvent  string   `xml:"statusCallbackEvent,attr,omitempty"`
	StatusCallbackMethod string   `xml:"statusCallbackMethod,attr,omitempty"`
}

type Pause

type Pause struct {
	XMLName xml.Name `xml:"Pause"`
	Length  int      `xml:"length,attr,omitempty"`
}

type Pay

type Pay struct {
	XMLName          xml.Name `xml:"Pay"`
	Input            string   `xml:"input,attr,omitempty"`
	Action           string   `xml:"action,attr,omitempty"`
	StatusCallback   string   `xml:"statusCallback,attr,omitempty"`
	Timeout          int      `xml:"timeout,attr,omitempty"`
	MaxAttempts      int      `xml:"maxAttempts,attr,omitempty"`
	SecurityCode     string   `xml:"securityCode,attr,omitempty"`
	PostalCode       string   `xml:"postalCode,attr,omitempty"`
	PaymentConnector string   `xml:"paymentConnector,attr,omitempty"`
	TokenType        string   `xml:"tokenType,attr,omitempty"`
	ChargeAmount     string   `xml:"chargeAmount,attr,omitempty"`
	Currency         string   `xml:"currency,attr,omitempty"`
	Description      string   `xml:"description,attr,omitempty"`
	ValidCardTypes   string   `xml:"validCardTypes,attr,omitempty"`
}

type Play

type Play struct {
	XMLName xml.Name `xml:"Play"`
	Loop    int      `xml:"loop,attr,omitempty"`
	Digits  int      `xml:"digits,attr,omitempty"`
	Url     string   `xml:",chardata"`
}

type Queue

type Queue struct {
	XMLName xml.Name `xml:"Queue"`
	Url     string   `xml:"url,attr,omitempty"`
	Method  string   `xml:"method,attr,omitempty"`
	Name    string   `xml:",chardata"`
}

type Record

type Record struct {
	XMLName            xml.Name `xml:"Record"`
	Action             string   `xml:"action,attr,omitempty"`
	Method             string   `xml:"method,attr,omitempty"`
	Timeout            int      `xml:"timeout,attr,omitempty"`
	FinishOnKey        string   `xml:"finishOnKey,attr,omitempty"`
	MaxLength          int      `xml:"maxLength,attr,omitempty"`
	Transcribe         bool     `xml:"transcribe,attr,omitempty"`
	TranscribeCallback string   `xml:"transcribeCallback,attr,omitempty"`
	PlayBeep           bool     `xml:"playBeep,attr,omitempty"`
}

type Redirect

type Redirect struct {
	XMLName xml.Name `xml:"Redirect"`
	Method  string   `xml:"method,attr,omitempty"`
	Url     string   `xml:",chardata"`
}

type Reject

type Reject struct {
	XMLName xml.Name `xml:"Reject"`
	Reason  string   `xml:"reason,attr,omitempty"`
}

type Response

type Response struct {
	XMLName  xml.Name `xml:"Response"`
	Response []interface{}
}

func NewResponse

func NewResponse() *Response

Create new response

func (*Response) Action

func (r *Response) Action(structs ...interface{}) error

Action appends action verb structs to response. Valid verbs: Enqueue, Say, Leave, Message, Pause, Play, Record, Redirect, Reject, Hangup, Pay

func (*Response) Dial

func (r *Response) Dial(structs ...interface{}) error

Dial appends dial action verb and noun structs to respose Valid verb: Dial. Valid nouns: Client, Conference, Number, Queue, Sip

func (*Response) Gather

func (r *Response) Gather(structs ...interface{}) error

Gather collects digits a caller enter by pressing the keypad Valid verb: Gather. Valid nested verbs: Say, Pause, Play

func (Response) Send

func (r Response) Send(w io.Writer) (err error)

Send sends xml encoded response to writer

func (Response) String

func (r Response) String() string

String returns a formatted xml response

type Say

type Say struct {
	XMLName  xml.Name `xml:"Say"`
	Voice    string   `xml:"voice,attr,omitempty"`
	Language string   `xml:"language,attr,omitempty"`
	Loop     int      `xml:"loop,attr,omitempty"`
	Text     string   `xml:",chardata"`
}

type Sip

type Sip struct {
	XMLName  xml.Name `xml:"Sip"`
	Username string   `xml:"username,attr,omitempty"`
	Password string   `xml:"password,attr,omitempty"`
	Url      string   `xml:"url,attr,omitempty"`
	Method   string   `xml:"method,attr,omitempty"`
	Address  string   `xml:",chardata"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL