ivr

package
v0.0.194 Latest Latest
Warning

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

Go to latest
Published: May 7, 2019 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NilCallID     = CallID("")
	NilAttachment = utils.Attachment("")

	// ErrorMessage that is spoken to an IVR user if an error occurs
	ErrorMessage = "An error has occurred, please try again later."
)

Variables

View Source
var CallEndedError = fmt.Errorf("call ended")

CallEndedError is our constant error for when a call has ended

View Source
var WriteAttachments = true

WriteAttachments controls whether we write attachments, used during unit testing

Functions

func HandleFlowStartBatch added in v0.0.74

func HandleFlowStartBatch(bg context.Context, config *config.Config, db *sqlx.DB, rp *redis.Pool, batch *models.FlowStartBatch) error

HandleFlowStartBatch starts a batch of contacts in an IVR flow

func HandleIVRStatus added in v0.0.74

func HandleIVRStatus(ctx context.Context, db *sqlx.DB, rp *redis.Pool, org *models.OrgAssets, client Client, conn *models.ChannelConnection, r *http.Request, w http.ResponseWriter) error

HandleIVRStatus is called on status callbacks for an IVR call. We let the client decide whether the call has ended for some reason and update the state of the call and session if so

func HangupCall added in v0.0.74

func HangupCall(ctx context.Context, config *config.Config, db *sqlx.DB, conn *models.ChannelConnection) error

HangupCall hangs up the passed in call also taking care of updating the status of our call in the process

func RegisterClientType

func RegisterClientType(channelType models.ChannelType, constructor ClientConstructor)

RegisterClientType registers the passed in channel type with the passed in constructor

func RequestCallStart

func RequestCallStart(ctx context.Context, config *config.Config, db *sqlx.DB, org *models.OrgAssets, start *models.FlowStartBatch, contact *models.Contact) (*models.ChannelConnection, error)

RequestCallStart creates a new ChannelSession for the passed in flow start and contact, returning the created session

func RequestCallStartForConnection added in v0.0.74

func RequestCallStartForConnection(ctx context.Context, config *config.Config, db *sqlx.DB, channel *models.Channel, telURN urns.URN, conn *models.ChannelConnection) error

func ResumeIVRFlow added in v0.0.74

func ResumeIVRFlow(
	ctx context.Context, config *config.Config, db *sqlx.DB, rp *redis.Pool, s3Client s3iface.S3API,
	resumeURL string, client Client,
	org *models.OrgAssets, channel *models.Channel, conn *models.ChannelConnection, c *models.Contact, urn urns.URN,
	r *http.Request, w http.ResponseWriter) error

ResumeIVRFlow takes care of resuming the flow in the passed in start for the passed in contact and URN

func StartIVRCron added in v0.0.74

func StartIVRCron(mr *mailroom.Mailroom) error

StartIVRCron starts our cron job of retrying errored calls

func StartIVRFlow added in v0.0.74

func StartIVRFlow(
	ctx context.Context, db *sqlx.DB, rp *redis.Pool, client Client, resumeURL string, org *models.OrgAssets,
	channel *models.Channel, conn *models.ChannelConnection, c *models.Contact, urn urns.URN, startID models.StartID,
	r *http.Request, w http.ResponseWriter) error

StartIVRFlow takes care of starting the flow in the passed in start for the passed in contact and URN

func WriteErrorResponse added in v0.0.74

func WriteErrorResponse(ctx context.Context, db *sqlx.DB, client Client, conn *models.ChannelConnection, w http.ResponseWriter, rootErr error) error

WriteErrorResponse marks the passed in connection as errored and writes the appropriate error response to our writer

Types

type CallID

type CallID string

type Client added in v0.0.74

type Client interface {
	RequestCall(client *http.Client, number urns.URN, handleURL string, statusURL string) (CallID, error)

	HangupCall(client *http.Client, externalID string) error

	WriteSessionResponse(session *models.Session, resumeURL string, req *http.Request, w http.ResponseWriter) error

	WriteErrorResponse(w http.ResponseWriter, err error) error

	WriteEmptyResponse(w http.ResponseWriter, msg string) error

	InputForRequest(r *http.Request) (string, utils.Attachment, error)

	StatusForRequest(r *http.Request) (models.ConnectionStatus, int)

	PreprocessResume(ctx context.Context, db *sqlx.DB, rp *redis.Pool, conn *models.ChannelConnection, r *http.Request) ([]byte, error)

	ValidateRequestSignature(r *http.Request) error

	DownloadMedia(url string) (*http.Response, error)

	URNForRequest(r *http.Request) (urns.URN, error)

	CallIDForRequest(r *http.Request) (string, error)
}

Client defines the interface IVR clients must satisfy

func GetClient

func GetClient(channel *models.Channel) (Client, error)

GetClient creates the right kind of IVRClient for the passed in channel

type ClientConstructor

type ClientConstructor func(c *models.Channel) (Client, error)

ClientConstructor defines our signature for creating a new IVR client from a channel

type RunExpiration added in v0.0.74

type RunExpiration struct {
	OrgID        models.OrgID        `db:"org_id"`
	FlowID       models.FlowID       `db:"flow_id"`
	ContactID    flows.ContactID     `db:"contact_id"`
	RunID        models.FlowRunID    `db:"run_id"`
	SessionID    models.SessionID    `db:"session_id"`
	ExpiresOn    time.Time           `db:"expires_on"`
	ConnectionID models.ConnectionID `db:"connection_id"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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