Help us shape the future of Go! Take the 2026 Go Developer Survey

flows

package
v0.278.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 33 Imported by: 75

Documentation

Index

Constants

View Source
const (
	MaxNodesPerFlow        = 1000 // max number of nodes in a flow
	MaxActionsPerNode      = 100  // max number of actions in a node
	MaxExitsPerNode        = 100  // max number of exits in a node
	MaxCategoriesPerRouter = 100  // max number of categories a router can have
	MaxCasesPerRouter      = 100  // max number of categories a switch router can have
	MaxArgumentsPerCase    = 10   // max number of test arguments a switch router case can have
)
View Source
const (
	LocationLevelState    = envs.LocationLevel(1)
	LocationLevelDistrict = envs.LocationLevel(2)
	LocationLevelWard     = envs.LocationLevel(3)
)

location levels which can be field types

View Source
const MaxContactURNs = 50

MaxContactURNs is maximum number of URNs a contact can have

Variables

View Source
var RunContextTopLevels = []string{
	"child",
	"contact",
	"fields",
	"globals",
	"input",
	"legacy_extra",
	"node",
	"parent",
	"locals",
	"results",
	"resume",
	"run",
	"ticket",
	"trigger",
	"urns",
	"webhook",
}

RunContextTopLevels are the allowed top-level variables for expression evaluations

Functions

func ContactQueryEscaping added in v0.55.0

func ContactQueryEscaping(s string) string

ContactQueryEscaping is the escaping function used for expressions in contact queries

func Context

func Context(env envs.Environment, contextable Contextable) types.XValue

Context generates a lazy object for use in expressions

func ContextFunc added in v0.33.8

func ContextFunc(env envs.Environment, fn func(envs.Environment) map[string]types.XValue) *types.XObject

ContextFunc generates a lazy object for use in expressions

func ExtractJSON added in v0.236.0

func ExtractJSON(body []byte) []byte

func GroupReferences added in v0.278.0

func GroupReferences(groups []*Group) []*assets.GroupReference

GroupReferences converts a slice of groups to a slice of references

func LabelReferences added in v0.278.0

func LabelReferences(labels []*Label) []*assets.LabelReference

LabelReferences converts a slice of labels to a slice of references

func NewAssetsEnvironment added in v0.190.1

func NewAssetsEnvironment(base envs.Environment, sa SessionAssets) envs.Environment

NewAssetsEnvironment creates a new environment that has access to assets which can be used for resolving locations.

func NewChildHistory added in v0.96.0

func NewChildHistory(parent Session) *core.SessionHistory

NewChildHistory creates a new history for a child of the given session

func NewNodeUUID added in v0.251.6

func NewNodeUUID() core.NodeUUID

NewNodeUUID generates a new UUID for a node

func NewSessionEnvironment added in v0.190.1

func NewSessionEnvironment(s Session) envs.Environment

NewSessionEnvironment creates a new environment from a session's base environment that merges some properties with those from the contact.

func TranslationsForContact added in v0.278.0

func TranslationsForContact(e envs.Environment, b core.BroadcastTranslations, c *Contact, baseLanguage i18n.Language) (*core.MsgContent, i18n.Locale)

TranslationsForContact is a utility to help callers get the message content for a contact

func ValidateURN added in v0.4.0

func ValidateURN(fl validator.FieldLevel) bool

ValidateURN validates whether the field value is a valid URN

func ValidateURNScheme added in v0.4.0

func ValidateURNScheme(fl validator.FieldLevel) bool

ValidateURNScheme validates whether the field value is a valid URN scheme

Types

type Action

type Action interface {
	utils.Typed
	Localizable
	FlowTypeRestricted

	UUID() ActionUUID
	Execute(context.Context, Run, Step, events.EventLogger) error
	Validate() error
	Inspect(func(assets.Reference), func(string), func(*ResultInfo))
}

Action is an action within a flow node

type ActionUUID

type ActionUUID uuids.UUID

ActionUUID is the UUID of an action

func NewActionUUID added in v0.251.6

func NewActionUUID() ActionUUID

NewActionUUID generates a new UUID for an action

type AirtimeService added in v0.48.0

type AirtimeService interface {
	// Create initiates a new airtime transfer to the given URN. For providers with a two-step lifecycle,
	// this submits the transaction in an unconfirmed state and returns its identifier in ExternalID; the
	// host then calls Confirm to actually trigger the send. For providers that initiate immediately, this
	// method does the send and Confirm is a no-op.
	//
	// transferUUID is pre-allocated by the caller and is the UUID that will be assigned to the resulting
	// airtime_created event; implementations may pass it to the provider as their own reference (e.g.
	// DT One's external_id field) so that subsequent provider callbacks can be correlated back to the
	// event/transfer by the host without needing the provider's transaction id.
	Create(ctx context.Context, transferUUID events.EventUUID, sender urns.URN, recipient urns.URN, amounts map[string]decimal.Decimal, logHTTP core.HTTPLogCallback) (*core.AirtimeTransfer, error)

	// Confirm completes initiation of a transfer previously surfaced by Create. Hosts typically call
	// Confirm after the session commits, so the airtime is only actually sent once the surrounding work
	// is durably recorded. Implementations whose Create already triggers the send should make Confirm a
	// no-op.
	//
	// The transfer argument is the value Create returned. Implementations are expected to use whichever
	// fields they need (typically ExternalID) to address the provider transaction. Confirm should only be
	// invoked for transfers that Create returned without error; hosts should not call Confirm on a
	// partially-populated transfer left over from a failed Create.
	//
	// Confirm is not required to be idempotent — implementations may return an error on a duplicate
	// confirmation. Hosts that need at-most-once delivery semantics should ensure Confirm is called at
	// most once per transfer. On error, the airtime was not sent; hosts are responsible for surfacing
	// that to their users.
	Confirm(ctx context.Context, transfer *core.AirtimeTransfer, logHTTP core.HTTPLogCallback) error
}

AirtimeService provides airtime functionality to the engine

type Call added in v0.171.0

type Call struct {
	// contains filtered or unexported fields
}

Call represents a call over a specific channel and URN

func NewCall added in v0.171.0

func NewCall(uuid core.CallUUID, channel *Channel, urn urns.URN) *Call

NewCall creates a new call

func ReadCall added in v0.278.0

func ReadCall(sa SessionAssets, e *core.CallEnvelope, missing assets.MissingCallback) *Call

ReadCall reads a call from the passed in envelope.

func (*Call) Channel added in v0.171.0

func (c *Call) Channel() *Channel

func (*Call) Marshal added in v0.247.8

func (c *Call) Marshal() *core.CallEnvelope

Marshal marshals a call into an envelope.

func (*Call) URN added in v0.171.0

func (c *Call) URN() urns.URN

func (*Call) UUID added in v0.247.8

func (c *Call) UUID() core.CallUUID

type Campaign added in v0.247.5

type Campaign struct {
	assets.Campaign
}

Campaign adds some functionality to campaign assets.

func NewCampaign added in v0.247.5

func NewCampaign(asset assets.Campaign) *Campaign

NewCampaign returns a new campaign object from the given campaign asset

func (*Campaign) Asset added in v0.247.5

func (c *Campaign) Asset() assets.Campaign

Asset returns the underlying asset

func (*Campaign) Context added in v0.247.5

func (c *Campaign) Context(env envs.Environment) map[string]types.XValue

Context returns the properties available in expressions

uuid:text -> the UUID of the campaign
name:text -> the name of the campaign

@context campaign

func (*Campaign) Reference added in v0.247.5

func (c *Campaign) Reference() *assets.CampaignReference

Reference returns a reference to this campaign

type CampaignAssets added in v0.247.5

type CampaignAssets struct {
	// contains filtered or unexported fields
}

CampaignAssets provides access to all campaign assets

func NewCampaignAssets added in v0.247.5

func NewCampaignAssets(campaigns []assets.Campaign) *CampaignAssets

NewCampaignAssets creates a new set of campaign assets

func (*CampaignAssets) Get added in v0.247.5

Get finds the campaign with the given UUID

type Category added in v0.79.0

type Category interface {
	Localizable

	UUID() CategoryUUID
	Name() string
	ExitUUID() ExitUUID
}

Category is how routers map results to exits

type CategoryUUID added in v0.30.2

type CategoryUUID uuids.UUID

CategoryUUID is the UUID of a node category

type Channel

type Channel struct {
	assets.Channel
}

Channel represents a means for sending and receiving input during a flow run

func NewChannel added in v0.6.0

func NewChannel(asset assets.Channel) *Channel

NewChannel creates a new channenl

func (*Channel) Asset added in v0.15.0

func (c *Channel) Asset() assets.Channel

Asset returns the underlying asset

func (*Channel) Context added in v0.33.8

func (c *Channel) Context(env envs.Environment) map[string]types.XValue

Context returns the properties available in expressions

__default__:text -> the name
uuid:text -> the UUID of the channel
name:text -> the name of the channel
address:text -> the address of the channel

@context channel

func (*Channel) HasFeature added in v0.195.0

func (c *Channel) HasFeature(feat assets.ChannelFeature) bool

HasFeature returns whether this channel has the given feature

func (*Channel) HasRole added in v0.6.0

func (c *Channel) HasRole(role assets.ChannelRole) bool

HasRole returns whether this channel has the given role

func (*Channel) Reference added in v0.5.0

func (c *Channel) Reference() *assets.ChannelReference

Reference returns a reference to this channel

func (*Channel) String

func (c *Channel) String() string

func (*Channel) SupportsScheme added in v0.6.0

func (c *Channel) SupportsScheme(scheme string) bool

SupportsScheme returns whether this channel supports the given URN scheme

type ChannelAssets added in v0.15.0

type ChannelAssets struct {
	// contains filtered or unexported fields
}

ChannelAssets provides access to all channel assets

func NewChannelAssets added in v0.15.0

func NewChannelAssets(channels []assets.Channel) *ChannelAssets

NewChannelAssets creates a new set of channel assets

func (*ChannelAssets) Get added in v0.15.0

func (s *ChannelAssets) Get(uuid assets.ChannelUUID) *Channel

Get returns the channel with the given UUID

func (*ChannelAssets) GetForURN added in v0.15.0

func (s *ChannelAssets) GetForURN(urn *URN, role assets.ChannelRole) *Channel

GetForURN returns the best channel for the given URN

type CheckSendableCallback added in v0.257.3

type CheckSendableCallback func(context.Context, SessionAssets, *Contact, *core.MsgContent) (core.UnsendableReason, error)

type ClaimURNCallback added in v0.263.0

type ClaimURNCallback func(context.Context, SessionAssets, *Contact, urns.URN) (bool, error)

type Contact

type Contact struct {
	// contains filtered or unexported fields
}

Contact represents a person who is interacting with the flow

func NewContact added in v0.5.1

func NewContact(
	sa SessionAssets,
	uuid core.ContactUUID,
	id ContactID,
	name string,
	language i18n.Language,
	status core.ContactStatus,
	timezone *time.Location,
	createdOn time.Time,
	lastSeenOn *time.Time,
	urns []urns.URN,
	groups []*assets.GroupReference,
	fields map[string]*core.Value,
	tickets []*Ticket,
	missing assets.MissingCallback) (*Contact, error)

NewContact creates a new contact with the passed in attributes

func NewEmptyContact added in v0.14.7

func NewEmptyContact(sa SessionAssets, name string, language i18n.Language, timezone *time.Location) *Contact

NewEmptyContact creates a new empy contact with the passed in name, language and location

func ReadContact

func ReadContact(sa SessionAssets, data []byte, missing assets.MissingCallback) (*Contact, error)

ReadContact decodes a contact from the passed in JSON

func (*Contact) AddRoute added in v0.273.0

func (c *Contact) AddRoute(urn urns.URN, channel *Channel) bool

AddRoute adds a new URN to this contact with optional channel affinity. Returns whether the contact was changed. If the URN is already on the contact this is a no-op - to update channel affinity use SetAffinity or SetRoutes.

func (*Contact) Clone added in v0.4.0

func (c *Contact) Clone() *Contact

Clone clones this contact when we need to snapshot as part of parent run summary.

func (*Contact) Context added in v0.33.8

func (c *Contact) Context(env envs.Environment) map[string]types.XValue

Context returns the properties available in expressions

__default__:text -> the name or URN
uuid:text -> the UUID of the contact
ref:text -> the reference identifier of the contact
first_name:text -> the first name of the contact
name:text -> the name of the contact
language:text -> the language of the contact as 3-letter ISO code
status:text -> the status of the contact
created_on:datetime -> the creation date of the contact
last_seen_on:any -> the last seen date of the contact
urns:[]text -> the URNs belonging to the contact
urn:text -> the preferred URN of the contact
groups:[]group -> the groups the contact belongs to
fields:fields -> the custom field values of the contact
channel:channel -> the preferred channel of the contact

@context contact

func (*Contact) Country added in v0.89.0

func (c *Contact) Country() i18n.Country

Country gets the country for this contact..

TODO: currently this is derived from their preferred channel or any tel URNs but probably should become an explicit field at some point

func (*Contact) CreatedOn added in v0.10.15

func (c *Contact) CreatedOn() time.Time

CreatedOn returns the created on time of this contact

func (*Contact) Fields

func (c *Contact) Fields() FieldValues

Fields returns this contact's field values

func (*Contact) Format added in v0.10.18

func (c *Contact) Format(env envs.Environment) string

Format returns a friendly string version of this contact depending on what fields are set

func (*Contact) Groups

func (c *Contact) Groups() *GroupList

Groups returns the groups that this contact belongs to

func (*Contact) HasURN added in v0.6.1

func (c *Contact) HasURN(urn urns.URN) bool

func (*Contact) ID added in v0.10.5

func (c *Contact) ID() ContactID

ID returns the numeric ID of this contact

func (*Contact) Language

func (c *Contact) Language() i18n.Language

Language gets the language for this contact

func (*Contact) LastSeenOn added in v0.100.0

func (c *Contact) LastSeenOn() *time.Time

LastSeenOn returns the last seen on time of this contact

func (*Contact) Locale added in v0.89.0

func (c *Contact) Locale(env envs.Environment) i18n.Locale

Locale gets the locale for this contact, using the environment country if contact doesn't have one

func (*Contact) Marshal added in v0.248.3

func (c *Contact) Marshal() *ContactEnvelope

func (*Contact) MarshalJSON

func (c *Contact) MarshalJSON() ([]byte, error)

MarshalJSON marshals this contact into JSON

func (*Contact) Name

func (c *Contact) Name() string

Name returns the name of this contact

func (*Contact) PreferredChannel added in v0.11.0

func (c *Contact) PreferredChannel() *Channel

PreferredChannel gets the preferred channel for this contact, i.e. the channel we would use for sending

func (*Contact) PreferredURN added in v0.27.5

func (c *Contact) PreferredURN() *URN

PreferredURN gets the preferred URN for this contact, i.e. the URN we would use for sending

func (*Contact) QueryProperty added in v0.45.1

func (c *Contact) QueryProperty(env envs.Environment, key string, propType contactql.PropertyType) []any

QueryProperty resolves a contact query search key for this contact

Note that this method excludes id, ref, group and flow search attributes as those are disallowed query based groups.

func (*Contact) ReevaluateQueryBasedGroups added in v0.103.0

func (c *Contact) ReevaluateQueryBasedGroups(env envs.Environment) ([]*Group, []*Group)

ReevaluateQueryBasedGroups reevaluates membership of all query based groups for this contact

func (*Contact) Reference added in v0.4.0

func (c *Contact) Reference() *core.ContactReference

Reference returns a reference to this contact

func (*Contact) RemoveURN added in v0.74.0

func (c *Contact) RemoveURN(urn urns.URN) bool

RemoveURN removes an existing URN from this contact

func (*Contact) ResolveRoutes added in v0.273.0

func (c *Contact) ResolveRoutes(all bool) []Route

ResolveRoutes resolves possible URN/channel routes for sending

func (*Contact) SetAffinity added in v0.266.0

func (c *Contact) SetAffinity(urn urns.URN, ch *Channel) bool

SetAffinity sets the preferred URN/channel for this contact by moving it to the front of the list and returns whether any change was made. If the URN is not already associated with the contact then this is a no-op and returns false.

func (*Contact) SetLanguage

func (c *Contact) SetLanguage(lang i18n.Language)

SetLanguage sets the language for this contact

func (*Contact) SetLastSeenOn added in v0.100.0

func (c *Contact) SetLastSeenOn(t time.Time)

SetLastSeenOn sets the last seen on time of this contact

func (*Contact) SetName

func (c *Contact) SetName(name string)

SetName sets the name of this contact

func (*Contact) SetRoutes added in v0.273.0

func (c *Contact) SetRoutes(routes []Route) bool

SetRoutes replaces this contact's URNs with the given routes, each carrying optional channel affinity.

func (*Contact) SetStatus added in v0.84.0

func (c *Contact) SetStatus(status core.ContactStatus)

SetStatus sets the status of this contact (blocked, stopped or active)

func (*Contact) SetTimezone

func (c *Contact) SetTimezone(tz *time.Location)

SetTimezone sets the timezone of this contact

func (*Contact) Status added in v0.84.0

func (c *Contact) Status() core.ContactStatus

Status returns the contact status

func (*Contact) Tickets added in v0.118.0

func (c *Contact) Tickets() *TicketList

Tickets returns the tickets for this contact

func (*Contact) Timezone

func (c *Contact) Timezone() *time.Location

Timezone returns the timezone of this contact

func (*Contact) URNs

func (c *Contact) URNs() URNList

URNs returns the URNs of this contact

func (*Contact) UUID

func (c *Contact) UUID() core.ContactUUID

UUID returns the UUID of this contact

func (*Contact) UpdatePreferredChannel added in v0.6.0

func (c *Contact) UpdatePreferredChannel(channel *Channel) bool

UpdatePreferredChannel updates the preferred channel and returns whether any change was made

type ContactEnvelope added in v0.248.3

type ContactEnvelope struct {
	UUID       core.ContactUUID         `json:"uuid"                validate:"required,uuid"`
	ID         ContactID                `json:"id,omitempty"`
	Name       string                   `json:"name,omitempty"`
	Language   i18n.Language            `json:"language,omitempty"`
	Status     core.ContactStatus       `json:"status,omitempty"    validate:"required,contact_status"`
	Timezone   string                   `json:"timezone,omitempty"`
	CreatedOn  time.Time                `json:"created_on"          validate:"required"`
	LastSeenOn *time.Time               `json:"last_seen_on,omitempty"`
	URNs       []urns.URN               `json:"urns,omitempty"      validate:"dive,urn"`
	Groups     []*assets.GroupReference `json:"groups,omitempty"    validate:"dive"`
	Fields     map[string]*core.Value   `json:"fields,omitempty"`
	Tickets    []*core.TicketEnvelope   `json:"tickets,omitempty"`
}

func (*ContactEnvelope) Unmarshal added in v0.248.3

func (e *ContactEnvelope) Unmarshal(sa SessionAssets, missing assets.MissingCallback) (*Contact, error)

type ContactID added in v0.15.0

type ContactID int64

ContactID is the ID of a contact

type Contextable added in v0.33.8

type Contextable interface {
	Context(env envs.Environment) map[string]types.XValue
}

Contextable is an object that can accessed in expressions as a object with properties

type Dependency added in v0.68.0

type Dependency interface {
	Reference() assets.Reference
	Type() string
	Missing() bool
}

type EmailService added in v0.61.0

type EmailService interface {
	Send(addresses []string, subject, body string) error
}

EmailService provides email functionality to the engine

type Engine added in v0.27.4

type Engine interface {
	NewSession(context.Context, SessionAssets, envs.Environment, *Contact, Trigger, *Call) (Session, Sprint, error)
	ReadSession(SessionAssets, []byte, envs.Environment, *Contact, *Call, assets.MissingCallback) (Session, error)

	Evaluator() *excellent.Evaluator
	Services() Services
	Options() *EngineOptions
}

Engine provides callers with session starting and resuming

type EngineOptions added in v0.190.0

type EngineOptions struct {
	MaxStepsPerSprint    int
	MaxSprintsPerSession int
	MaxTemplateChars     int
	MaxFieldChars        int
	MaxResultChars       int
	LLMPrompts           map[string]*template.Template
	CheckSendable        CheckSendableCallback
	ClaimURN             ClaimURNCallback
}

type Exit

type Exit interface {
	UUID() ExitUUID
	DestinationUUID() core.NodeUUID
}

Exit is a route out of a node and optionally to another node

type ExitUUID

type ExitUUID uuids.UUID

ExitUUID is the UUID of a node exit

type ExtractedReference added in v0.71.2

type ExtractedReference struct {
	Reference assets.Reference
	// contains filtered or unexported fields
}

ExtractedReference is a reference and its location in a flow

func NewExtractedReference added in v0.74.0

func NewExtractedReference(n Node, a Action, r Router, l i18n.Language, ref assets.Reference) ExtractedReference

NewExtractedReference creates a new extracted reference

type ExtractedResult added in v0.71.3

type ExtractedResult struct {
	Node   Node
	Action Action
	Router Router
	Info   *ResultInfo
}

type ExtractedTemplate added in v0.74.0

type ExtractedTemplate struct {
	Template string
	// contains filtered or unexported fields
}

ExtractedTemplate is a template and its location in a flow

func NewExtractedTemplate added in v0.74.0

func NewExtractedTemplate(n Node, a Action, r Router, l i18n.Language, t string) ExtractedTemplate

NewExtractedTemplate creates a new extracted template

type Field

type Field struct {
	assets.Field
}

Field represents a contact field

func NewField added in v0.4.0

func NewField(asset assets.Field) *Field

NewField creates a new field from the given asset

func (*Field) Asset added in v0.15.0

func (f *Field) Asset() assets.Field

Asset returns the underlying asset

func (*Field) Reference added in v0.24.0

func (f *Field) Reference() *assets.FieldReference

Reference returns a reference to this field

type FieldAssets added in v0.15.0

type FieldAssets struct {
	// contains filtered or unexported fields
}

FieldAssets provides access to all field assets

func NewFieldAssets added in v0.15.0

func NewFieldAssets(fields []assets.Field) *FieldAssets

NewFieldAssets creates a new set of field assets

func (*FieldAssets) All added in v0.15.0

func (s *FieldAssets) All() []*Field

All returns all the fields in this set

func (*FieldAssets) FirstOfType added in v0.15.0

func (s *FieldAssets) FirstOfType(valueType assets.FieldType) *Field

FirstOfType returns the first field in this set with the given value type

func (*FieldAssets) Get added in v0.15.0

func (s *FieldAssets) Get(key string) *Field

Get returns the contact field with the given key

func (*FieldAssets) ResolveField added in v0.78.0

func (s *FieldAssets) ResolveField(key string) assets.Field

func (*FieldAssets) ResolveFlow added in v0.151.0

func (s *FieldAssets) ResolveFlow(name string) assets.Flow

func (*FieldAssets) ResolveGroup added in v0.78.0

func (s *FieldAssets) ResolveGroup(name string) assets.Group

type FieldValue added in v0.4.0

type FieldValue struct {
	*core.Value
	// contains filtered or unexported fields
}

FieldValue represents a field and a set of values for that field

func NewFieldValue added in v0.4.0

func NewFieldValue(field *Field, value *core.Value) *FieldValue

NewFieldValue creates a new field value

func (*FieldValue) QueryValue added in v0.32.0

func (v *FieldValue) QueryValue() any

QueryValue returns the value for use in contact queries

func (*FieldValue) ToXValue added in v0.32.0

func (v *FieldValue) ToXValue(env envs.Environment) types.XValue

ToXValue returns a representation of this object for use in expressions

type FieldValues added in v0.4.0

type FieldValues map[string]*FieldValue

FieldValues is the set of all field values for a contact

func NewFieldValues added in v0.15.2

func NewFieldValues(a SessionAssets, values map[string]*core.Value, missing assets.MissingCallback) FieldValues

NewFieldValues creates a new field value map

func (FieldValues) Context added in v0.30.4

func (f FieldValues) Context(env envs.Environment) map[string]types.XValue

Context returns the properties available in expressions

func (FieldValues) Get added in v0.19.2

func (f FieldValues) Get(field *Field) *core.Value

Get gets the value set for the given field

func (FieldValues) Parse added in v0.24.0

func (f FieldValues) Parse(env envs.Environment, fields *FieldAssets, field *Field, rawValue string) *core.Value

Parse parses a raw string field value into the different possible types

func (FieldValues) Set added in v0.19.2

func (f FieldValues) Set(field *Field, value *core.Value)

Set sets the value for the given field (can be null to clear it)

type Flow

type Flow interface {
	Contextable

	// spec properties
	UUID() assets.FlowUUID
	Name() string
	Revision() int
	Language() i18n.Language
	Type() FlowType
	ExpireAfter() time.Duration
	Localization() Localization
	UI() json.RawMessage
	Nodes() []Node
	GetNode(uuid core.NodeUUID) Node

	Asset() assets.Flow
	Reference(bool) *assets.FlowReference

	Inspect(sa SessionAssets) *Info
	ExtractTemplates() []string
	ExtractLocalizables() []string
	ChangeLanguage(i18n.Language) (Flow, error)
}

Flow describes the ordered logic of actions and routers

type FlowAssets added in v0.15.0

type FlowAssets interface {
	Get(assets.FlowUUID) (Flow, error)
	FindByName(string) (Flow, error)
}

FlowAssets provides access to flow assets

type FlowType added in v0.14.0

type FlowType string

FlowType represents the different types of flows

const (
	// FlowTypeMessaging is a flow that is run over a messaging channel
	FlowTypeMessaging FlowType = "messaging"

	// FlowTypeMessagingBackground is a non-interactive messaging flow (i.e. never waits for input)
	FlowTypeMessagingBackground FlowType = "messaging_background"

	// FlowTypeMessagingOffline is a flow which is run over an offline messaging client like Surveyor
	FlowTypeMessagingOffline FlowType = "messaging_offline"

	// FlowTypeVoice is a flow which is run over IVR
	FlowTypeVoice FlowType = "voice"
)

func (FlowType) Allows added in v0.107.0

func (t FlowType) Allows(r FlowTypeRestricted) bool

Allows returns whether this flow type allows the given item

type FlowTypeRestricted added in v0.107.0

type FlowTypeRestricted interface {
	AllowedFlowTypes() []FlowType
}

FlowTypeRestricted is a part of a flow which can be restricted to certain flow types

type Global added in v0.57.0

type Global struct {
	assets.Global
}

Global represents a constant value available in expressions.

func NewGlobal added in v0.57.0

func NewGlobal(asset assets.Global) *Global

NewGlobal returns a new global object from the given global asset

func (*Global) Asset added in v0.57.0

func (g *Global) Asset() assets.Global

Asset returns the underlying asset

func (*Global) Reference added in v0.57.0

func (g *Global) Reference() *assets.GlobalReference

Reference returns a reference to this global

type GlobalAssets added in v0.57.0

type GlobalAssets struct {
	// contains filtered or unexported fields
}

GlobalAssets provides access to all global assets

func NewGlobalAssets added in v0.57.0

func NewGlobalAssets(globals []assets.Global) *GlobalAssets

NewGlobalAssets creates a new set of global assets

func (*GlobalAssets) Context added in v0.57.0

func (s *GlobalAssets) Context(env envs.Environment) map[string]types.XValue

Context returns the properties available in expressions

func (*GlobalAssets) Get added in v0.57.0

func (s *GlobalAssets) Get(key string) *Global

Get returns the global with the given key

type Group

type Group struct {
	assets.Group
	// contains filtered or unexported fields
}

Group adds some functionality to group assets.

func NewGroup

func NewGroup(env envs.Environment, fields *FieldAssets, asset assets.Group) (*Group, error)

NewGroup returns a new group object from the given group asset

func (*Group) Asset added in v0.15.0

func (g *Group) Asset() assets.Group

Asset returns the underlying asset

func (*Group) CheckQueryBasedMembership added in v0.103.0

func (g *Group) CheckQueryBasedMembership(env envs.Environment, contact *Contact) bool

CheckQueryBasedMembership returns whether the given contact belongs in a query based group

func (*Group) Reference added in v0.4.0

func (g *Group) Reference() *assets.GroupReference

Reference returns a reference to this group

func (*Group) ToXValue added in v0.32.0

func (g *Group) ToXValue(env envs.Environment) types.XValue

ToXValue returns a representation of this object for use in expressions

uuid:text -> the UUID of the group
name:text -> the name of the group

@context group

func (*Group) UsesQuery added in v0.103.0

func (g *Group) UsesQuery() bool

UsesQuery returns whether this group is query based

type GroupAssets added in v0.15.0

type GroupAssets struct {
	// contains filtered or unexported fields
}

GroupAssets provides access to all group assets

func NewGroupAssets added in v0.15.0

func NewGroupAssets(env envs.Environment, fields *FieldAssets, groups []assets.Group) (*GroupAssets, []assets.Group)

NewGroupAssets creates a new set of group assets

func (*GroupAssets) All added in v0.15.0

func (s *GroupAssets) All() []*Group

All returns all the groups

func (*GroupAssets) FindByName added in v0.15.0

func (s *GroupAssets) FindByName(name string) *Group

FindByName looks for a group with the given name (case-insensitive)

func (*GroupAssets) Get added in v0.15.0

func (s *GroupAssets) Get(uuid assets.GroupUUID) *Group

Get returns the group with the given UUID

type GroupList

type GroupList struct {
	// contains filtered or unexported fields
}

GroupList defines a contact's list of groups

func NewGroupList added in v0.4.0

func NewGroupList(a SessionAssets, refs []*assets.GroupReference, missing assets.MissingCallback) *GroupList

NewGroupList creates a new group list

func (*GroupList) Add added in v0.4.0

func (l *GroupList) Add(group *Group) bool

Add adds the given group to this group list

func (*GroupList) All added in v0.4.0

func (l *GroupList) All() []*Group

All returns all groups in this group list

func (*GroupList) Clear added in v0.150.1

func (l *GroupList) Clear()

Clear clears this group list

func (*GroupList) Count added in v0.4.0

func (l *GroupList) Count() int

Count returns the number of groups in this group list

func (*GroupList) FindByUUID added in v0.4.0

func (l *GroupList) FindByUUID(uuid assets.GroupUUID) *Group

FindByUUID returns the group with the passed in UUID or nil if not found

func (*GroupList) Remove added in v0.4.0

func (l *GroupList) Remove(group *Group) bool

Remove removes the given group from this group list

func (*GroupList) ToXValue added in v0.32.0

func (l *GroupList) ToXValue(env envs.Environment) types.XValue

ToXValue returns a representation of this object for use in expressions

type Info added in v0.240.2

type Info struct {
	Counts       map[string]int `json:"counts"`
	Dependencies []Dependency   `json:"dependencies"`
	Locals       []string       `json:"locals"`
	Results      []*ResultSpec  `json:"results"`
	ParentRefs   []string       `json:"parent_refs"`
	Issues       []Issue        `json:"issues"`
}

Info contains the results of flow inspection

type Input

type Input interface {
	utils.Typed
	Contextable

	UUID() core.InputUUID
	CreatedOn() time.Time
	Channel() *Channel
}

Input describes input from the contact and currently we only support one type of input: `msg`

type Issue added in v0.72.0

type Issue interface {
	utils.Typed

	NodeUUID() core.NodeUUID
	ActionUUID() ActionUUID
	Language() i18n.Language
	Description() string
}

Issue is a problem found during flow inspection

type LLM added in v0.232.0

type LLM struct {
	assets.LLM
}

LLM represents a large language model.

func NewLLM added in v0.232.0

func NewLLM(asset assets.LLM) *LLM

NewLLM returns a new LLM object from the given LLM asset

func (*LLM) Asset added in v0.232.0

func (l *LLM) Asset() assets.LLM

Asset returns the underlying asset

func (*LLM) HasRole added in v0.273.10

func (l *LLM) HasRole(role assets.LLMRole) bool

HasRole returns whether this LLM has the given role

func (*LLM) Reference added in v0.232.0

func (l *LLM) Reference() *assets.LLMReference

Reference returns a reference to this LLM

type LLMAssets added in v0.232.0

type LLMAssets struct {
	// contains filtered or unexported fields
}

LLMAssets provides access to all LLM assets

func NewLLMAssets added in v0.232.0

func NewLLMAssets(llms []assets.LLM) *LLMAssets

NewLLMAssets creates a new set of LLM assets

func (*LLMAssets) Get added in v0.232.0

func (s *LLMAssets) Get(uuid assets.LLMUUID) *LLM

Get returns the LLM with the given UUID

type LLMService added in v0.232.1

type LLMService interface {
	Response(ctx context.Context, instructions, input string, maxTokens int) (*core.LLMResponse, error)
}

LLMService provides LLM functionality to the engine

type Label

type Label struct {
	assets.Label
}

Label represents a message label

func NewLabel

func NewLabel(asset assets.Label) *Label

NewLabel creates a new label from the given asset

func (*Label) Asset added in v0.15.0

func (l *Label) Asset() assets.Label

Asset returns the underlying asset

func (*Label) Reference added in v0.4.0

func (l *Label) Reference() *assets.LabelReference

Reference returns a reference to this label

type LabelAssets added in v0.15.0

type LabelAssets struct {
	// contains filtered or unexported fields
}

LabelAssets provides access to all label assets

func NewLabelAssets added in v0.15.0

func NewLabelAssets(labels []assets.Label) *LabelAssets

NewLabelAssets creates a new set of label assets

func (*LabelAssets) All added in v0.15.0

func (s *LabelAssets) All() []*Label

All returns all the labels

func (*LabelAssets) FindByName added in v0.15.0

func (s *LabelAssets) FindByName(name string) *Label

FindByName looks for a label with the given name (case-insensitive)

func (*LabelAssets) Get added in v0.15.0

func (s *LabelAssets) Get(uuid assets.LabelUUID) *Label

Get returns the label with the given UUID

type LegacyExtraContributor added in v0.21.3

type LegacyExtraContributor interface {
	LegacyExtra() Results
}

LegacyExtraContributor is something which contributes results for constructing @legacy_extra

type Localizable added in v0.29.0

type Localizable interface {
	LocalizationUUID() uuids.UUID
}

Localizable is anything in the flow definition which can be localized and therefore needs a UUID

type Localization added in v0.6.2

type Localization interface {
	Validate() error
	GetItemTranslation(i18n.Language, uuids.UUID, string) []string
	SetItemTranslation(i18n.Language, uuids.UUID, string, []string)
	Languages() []i18n.Language
}

Localization provide a way to get the translations for a specific language

type Locals added in v0.235.0

type Locals struct {
	// contains filtered or unexported fields
}

Locals is a map of local variables for a run

func NewLocals added in v0.235.0

func NewLocals() *Locals

NewLocals creates a new empty locals instance

func (*Locals) Clear added in v0.235.0

func (l *Locals) Clear(key string)

func (*Locals) Context added in v0.235.0

func (l *Locals) Context(env envs.Environment) map[string]types.XValue

Context returns the properties available in expressions

func (*Locals) Get added in v0.235.0

func (l *Locals) Get(key string) string

func (*Locals) IsZero added in v0.235.0

func (l *Locals) IsZero() bool

func (*Locals) MarshalJSON added in v0.235.0

func (l *Locals) MarshalJSON() ([]byte, error)

func (*Locals) Set added in v0.235.0

func (l *Locals) Set(key string, value string)

func (*Locals) UnmarshalJSON added in v0.235.0

func (l *Locals) UnmarshalJSON(data []byte) error

type LocationAssets added in v0.15.0

type LocationAssets struct {
	// contains filtered or unexported fields
}

LocationAssets provides access to location assets and implements envs.LocationResolver

func NewLocationAssets added in v0.15.0

func NewLocationAssets(hierarchies []assets.LocationHierarchy) *LocationAssets

NewLocationAssets creates a new set of location assets

func (*LocationAssets) FindLocations added in v0.235.0

func (s *LocationAssets) FindLocations(env envs.Environment, name string, level envs.LocationLevel, parent *envs.Location) []*envs.Location

FindLocations returns locations with the matching name (case-insensitive), level and parent (optional)

func (*LocationAssets) FindLocationsFuzzy added in v0.235.0

func (s *LocationAssets) FindLocationsFuzzy(env envs.Environment, text string, level envs.LocationLevel, parent *envs.Location) []*envs.Location

FindLocationsFuzzy returns matching locations like FindLocations but attempts the following strategies to find locations:

  1. Exact match
  2. Match with punctuation removed
  3. Split input into words and try to match each word
  4. Try to match pairs of words

func (*LocationAssets) LookupLocation added in v0.235.0

func (s *LocationAssets) LookupLocation(path envs.LocationPath) *envs.Location

type Modifier added in v0.24.0

Modifier is something which can modify a contact

type Node

type Node interface {
	UUID() core.NodeUUID
	Actions() []Action
	Router() Router
	Exits() []Exit

	Validate(Flow, map[uuids.UUID]bool) error
	Inspect(func(Action, Router, assets.Reference), func(Action, Router, string), func(Action, Router, *ResultInfo))
	EnumerateTemplates(Localization, func(Action, Router, i18n.Language, string))
	EnumerateLocalizables(func(uuids.UUID, string, []string, func([]string)))
}

Node is a single node in a flow

type OptIn added in v0.195.0

type OptIn struct {
	assets.OptIn
}

OptIn adds some functionality to optin assets.

func NewOptIn added in v0.195.0

func NewOptIn(asset assets.OptIn) *OptIn

NewOptIn returns a new optin object from the given optin asset

func (*OptIn) Asset added in v0.195.0

func (o *OptIn) Asset() assets.OptIn

Asset returns the underlying asset

func (*OptIn) Context added in v0.195.0

func (o *OptIn) Context(env envs.Environment) map[string]types.XValue

Context returns the properties available in expressions

uuid:text -> the UUID of the optin
name:text -> the name of the optin

@context optin

func (*OptIn) Reference added in v0.195.0

func (o *OptIn) Reference() *assets.OptInReference

Reference returns a reference to this optin

type OptInAssets added in v0.195.0

type OptInAssets struct {
	// contains filtered or unexported fields
}

OptInAssets provides access to all optin assets

func NewOptInAssets added in v0.195.0

func NewOptInAssets(optins []assets.OptIn) *OptInAssets

NewOptInAssets creates a new set of optin assets

func (*OptInAssets) Get added in v0.195.0

func (s *OptInAssets) Get(uuid assets.OptInUUID) *OptIn

Get finds the optin with the given UUID

type Resthook added in v0.10.20

type Resthook struct {
	assets.Resthook
}

Resthook represents a named event and a set of subscribers

func NewResthook added in v0.10.20

func NewResthook(asset assets.Resthook) *Resthook

NewResthook returns a new resthook object

func (*Resthook) Asset added in v0.15.0

func (r *Resthook) Asset() assets.Resthook

Asset returns the underlying asset

type ResthookAssets added in v0.15.0

type ResthookAssets struct {
	// contains filtered or unexported fields
}

ResthookAssets provides access to all resthook assets

func NewResthookAssets added in v0.15.0

func NewResthookAssets(resthooks []assets.Resthook) *ResthookAssets

NewResthookAssets creates a new set of resthook assets

func (*ResthookAssets) FindBySlug added in v0.15.0

func (s *ResthookAssets) FindBySlug(slug string) *Resthook

FindBySlug finds the group with the given UUID

type ResultInfo added in v0.40.0

type ResultInfo struct {
	Key        string   `json:"key"`
	Name       string   `json:"name"`
	Categories []string `json:"categories"`
}

ResultInfo is possible result that a flow might generate

func NewResultInfo added in v0.40.0

func NewResultInfo(name string, categories []string) *ResultInfo

NewResultInfo creates a new result spec

func (*ResultInfo) String added in v0.40.0

func (r *ResultInfo) String() string

type ResultSpec added in v0.30.2

type ResultSpec struct {
	ResultInfo
	NodeUUIDs []string `json:"node_uuids"`
}

func NewResultSpecs added in v0.71.3

func NewResultSpecs(results []ExtractedResult) []*ResultSpec

NewResultSpecs merges extracted results based on key

type Results

type Results map[string]*core.Result

Results is our wrapper around a map of snakified result names to result objects

func NewResults

func NewResults() Results

NewResults creates a new empty set of results

func (Results) Clone added in v0.4.0

func (r Results) Clone() Results

Clone returns a clone of this results set

func (Results) Context added in v0.33.8

func (r Results) Context(env envs.Environment) map[string]types.XValue

Context returns the properties available in expressions

func (Results) Get added in v0.9.10

func (r Results) Get(key string) *core.Result

Get returns the result with the given key

func (Results) Save

func (r Results) Save(result *core.Result) (*core.Result, bool)

Save saves a new result in our map using the snakified name as the key. Returns the old result if it existed.

func (*Results) UnmarshalJSON

func (r *Results) UnmarshalJSON(data []byte) error

type Resume added in v0.20.0

type Resume interface {
	utils.Typed
	Contextable

	Event() events.Event
	ResumedOn() time.Time

	Input(SessionAssets) Input
}

Resume represents something which can resume a session with the flow engine

type Route

type Route struct {
	URN     urns.URN
	Channel *Channel
}

Route is a URN paired with the channel that should handle it

type Router

type Router interface {
	utils.Typed

	Wait() Wait
	Categories() []Category
	ResultName() string

	AllowTimeout() bool
	Route(Run, Step, events.EventLogger) (ExitUUID, string, error)
	RouteTimeout(Run, Step, events.EventLogger) (ExitUUID, error)

	Validate(Flow, []Exit) error
	Inspect(func(*ResultInfo), func(assets.Reference))
	EnumerateTemplates(Localization, func(i18n.Language, string))
	EnumerateLocalizables(func(uuids.UUID, string, []string, func([]string)))
}

Router is a router on a note which can pick an exit

type Run added in v0.146.0

type Run interface {
	Contextable
	RunSummary
	FlowReference() *assets.FlowReference

	Session() Session
	Locals() *Locals
	SetResult(*core.Result) (*core.Result, bool)
	Webhook() *WebhookCall
	SetWebhook(*WebhookCall)

	CreateStep(Node) Step
	Path() []Step
	PathLocation() (Step, Node, error)
	HadInput() bool

	EvaluateTemplateValue(string, events.EventLogger) (types.XValue, bool)
	EvaluateTemplateText(string, excellent.Escaping, bool, events.EventLogger) (string, bool)
	EvaluateTemplate(string, events.EventLogger) (string, bool)
	RootContext(envs.Environment) map[string]types.XValue

	GetText(uuids.UUID, string, string) (string, i18n.Language)
	GetTextArray(uuids.UUID, string, []string, []i18n.Language) ([]string, i18n.Language)

	Snapshot() RunSummary
	Parent() RunSummary
	Ancestors() []Run

	CreatedOn() time.Time
	ModifiedOn() time.Time
	ExitedOn() *time.Time
	Exit(core.RunStatus)
}

Run is a single contact's journey through a flow. It records the path they have taken, and the results that have been collected.

type RunSummary added in v0.4.0

type RunSummary interface {
	UUID() core.RunUUID
	Contact() *Contact
	Flow() Flow
	Status() core.RunStatus
	Results() Results
}

RunSummary represents the minimum information available about all runs (current or related) and is the representation of runs made accessible to router tests.

type Segment added in v0.142.0

type Segment interface {
	Flow() Flow
	Node() Node
	Exit() Exit
	Operand() string
	Destination() Node
	Time() time.Time
}

Segment is a movement on the flow graph from an exit to another node

type Services added in v0.48.0

type Services interface {
	Email(SessionAssets) (EmailService, error)
	Webhook(SessionAssets) (WebhookService, error)
	LLM(*LLM) (LLMService, error)
	Airtime(SessionAssets) (AirtimeService, error)
}

Services groups together interfaces for several services whose implementation is provided outside of the flow engine.

type Session

type Session interface {
	Assets() SessionAssets

	UUID() core.SessionUUID
	Type() FlowType
	CreatedOn() time.Time

	Environment() envs.Environment
	MergedEnvironment() envs.Environment
	Contact() *Contact
	Call() *Call
	Input() Input
	Sprints() int
	Status() SessionStatus
	Trigger() Trigger
	CurrentResume() Resume
	BatchStart() bool
	PushFlow(Flow, Run, bool)

	Resume(context.Context, Resume) (Sprint, error)
	Runs() []Run
	ParentRun() RunSummary
	CurrentContext() *types.XObject
	History() *core.SessionHistory

	Engine() Engine
}

Session represents the session of a flow run which may contain many runs

type SessionAssets added in v0.4.0

type SessionAssets interface {
	contactql.Resolver

	Source() assets.Source

	Campaigns() *CampaignAssets
	Channels() *ChannelAssets
	Fields() *FieldAssets
	Flows() FlowAssets
	Globals() *GlobalAssets
	Groups() *GroupAssets
	Labels() *LabelAssets
	LLMs() *LLMAssets
	Locations() *LocationAssets
	OptIns() *OptInAssets
	Resthooks() *ResthookAssets
	Templates() *TemplateAssets
	Topics() *TopicAssets
	Users() *UserAssets
}

SessionAssets is the assets available to a session

type SessionStatus added in v0.4.0

type SessionStatus string

SessionStatus represents the current status of the engine session

const (
	// SessionStatusActive represents a session that is still active
	SessionStatusActive SessionStatus = "active"

	// SessionStatusCompleted represents a session that has run to completion
	SessionStatusCompleted SessionStatus = "completed"

	// SessionStatusWaiting represents a session which is waiting for something from the caller
	SessionStatusWaiting SessionStatus = "waiting"

	// SessionStatusFailed represents a session that encountered an unrecoverable error
	SessionStatusFailed SessionStatus = "failed"

	// SessionStatusExpired is never used by the engine but callers may put sessions into this state
	SessionStatusExpired SessionStatus = "expired"

	// SessionStatusInterrupted is never used by the engine but callers may put sessions into this state
	SessionStatusInterrupted SessionStatus = "interrupted"
)

type Sprint added in v0.24.0

type Sprint interface {
	UUID() SprintUUID
	IsInitial() bool
	Events() []events.Event
	Segments() []Segment
	Flows() []Flow
}

Sprint is an interaction with the engine - i.e. a start or resume of a session

type SprintUUID added in v0.228.1

type SprintUUID uuids.UUID

SprintUUID is the UUID of a sprint

type Step

type Step interface {
	Contextable

	UUID() StepUUID
	NodeUUID() core.NodeUUID
	ExitUUID() ExitUUID
	ArrivedOn() time.Time

	Leave(ExitUUID)
	Run() Run
}

Step is a single step in the path thru a flow

type StepUUID

type StepUUID uuids.UUID

StepUUID is the UUID of a run step

type Template added in v0.32.0

type Template struct {
	assets.Template
}

Template represents messaging templates used by channels types such as WhatsApp

func NewTemplate added in v0.32.0

func NewTemplate(t assets.Template) *Template

NewTemplate returns a new template objects based on the passed in asset

func (*Template) Asset added in v0.32.0

func (t *Template) Asset() assets.Template

Asset returns the underlying asset

func (*Template) FindTranslation added in v0.32.0

func (t *Template) FindTranslation(channel *Channel, locales []i18n.Locale) *TemplateTranslation

FindTranslation finds the matching translation for the passed in channel and languages (in priority order)

func (*Template) Reference added in v0.38.1

func (t *Template) Reference() *assets.TemplateReference

Reference returns the reference for this template

func (*Template) Templating added in v0.218.2

func (t *Template) Templating(tt *TemplateTranslation, vars []string) *core.MsgTemplating

Templating generates a templating object for the passed in translation and variables

type TemplateAssets added in v0.32.0

type TemplateAssets struct {
	// contains filtered or unexported fields
}

TemplateAssets is our type for all the templates in an environment

func NewTemplateAssets added in v0.32.0

func NewTemplateAssets(ts []assets.Template) *TemplateAssets

NewTemplateAssets creates a new template list

func (*TemplateAssets) Get added in v0.38.1

Get returns the template with the passed in UUID if any

type TemplateEnumerator added in v0.200.1

type TemplateEnumerator interface {
	EnumerateTemplates(Localization, func(i18n.Language, string))
}

type TemplateTranslation added in v0.32.0

type TemplateTranslation struct {
	assets.TemplateTranslation
}

TemplateTranslation represents a single translation for a template

func NewTemplateTranslation added in v0.32.0

func NewTemplateTranslation(t assets.TemplateTranslation) *TemplateTranslation

NewTemplateTranslation returns a new TemplateTranslation for the passed in asset

func (*TemplateTranslation) Asset added in v0.32.0

Asset returns the underlying asset

func (*TemplateTranslation) Preview added in v0.201.0

Preview returns message content which will act as a preview of a message sent with this template

type Ticket added in v0.86.0

type Ticket struct {
	// contains filtered or unexported fields
}

Ticket is a ticket in a ticketing system

func NewTicket added in v0.86.0

func NewTicket(uuid core.TicketUUID, status core.TicketStatus, topic *Topic, assignee *User) *Ticket

NewTicket creates a new ticket

func OpenTicket added in v0.122.0

func OpenTicket(topic *Topic, assignee *User) *Ticket

OpenTicket creates a new ticket. Used by ticketing services to open a new ticket.

func ReadTicket added in v0.122.0

func ReadTicket(sa SessionAssets, e *core.TicketEnvelope, missing assets.MissingCallback) *Ticket

ReadTicket reads a ticket from the passed in envelope. If the topic or assigned user can't be found in the assets, we report the missing asset and return ticket without those.

func (*Ticket) Assignee added in v0.124.0

func (t *Ticket) Assignee() *User

func (*Ticket) Context added in v0.118.2

func (t *Ticket) Context(env envs.Environment) map[string]types.XValue

Context returns the properties available in expressions

uuid:text -> the UUID of the ticket
topic:any -> the topic of the ticket
assignee:any -> the assignee of the ticket

@context ticket

func (*Ticket) Marshal added in v0.247.3

func (t *Ticket) Marshal() *core.TicketEnvelope

Marshal marshals a ticket into an envelope.

func (*Ticket) SetAssignee added in v0.256.0

func (t *Ticket) SetAssignee(user *User)

func (*Ticket) SetStatus added in v0.256.0

func (t *Ticket) SetStatus(status core.TicketStatus)

func (*Ticket) SetTopic added in v0.256.0

func (t *Ticket) SetTopic(topic *Topic)

func (*Ticket) Status added in v0.256.0

func (t *Ticket) Status() core.TicketStatus

func (*Ticket) Topic added in v0.132.0

func (t *Ticket) Topic() *Topic

func (*Ticket) UUID added in v0.86.0

func (t *Ticket) UUID() core.TicketUUID

type TicketList added in v0.118.0

type TicketList struct {
	// contains filtered or unexported fields
}

func NewTicketList added in v0.118.0

func NewTicketList(tickets []*Ticket) *TicketList

func (*TicketList) Add added in v0.118.0

func (l *TicketList) Add(t *Ticket)

func (*TicketList) All added in v0.118.0

func (l *TicketList) All() []*Ticket

func (*TicketList) Count added in v0.118.0

func (l *TicketList) Count() int

func (*TicketList) Find added in v0.256.8

func (l *TicketList) Find(uuid core.TicketUUID) *Ticket

func (*TicketList) LastOpen added in v0.256.3

func (l *TicketList) LastOpen() *Ticket

func (*TicketList) Marshal added in v0.256.3

func (l *TicketList) Marshal() []*core.TicketEnvelope

func (*TicketList) Open added in v0.256.6

func (l *TicketList) Open() *TicketList

func (*TicketList) ToXValue added in v0.118.0

func (l *TicketList) ToXValue(env envs.Environment) types.XValue

ToXValue returns a representation of this object for use in expressions

type Timeout added in v0.33.0

type Timeout interface {
	Seconds() int
	CategoryUUID() CategoryUUID
}

Timeout is a way to skip a wait after X amount of time

type Topic added in v0.132.0

type Topic struct {
	assets.Topic
}

Topic represents a ticket topic

func NewTopic added in v0.132.0

func NewTopic(asset assets.Topic) *Topic

NewTopic creates a new topic from the given asset

func (*Topic) Asset added in v0.132.0

func (t *Topic) Asset() assets.Topic

Asset returns the underlying asset

func (*Topic) Context added in v0.133.0

func (t *Topic) Context(env envs.Environment) map[string]types.XValue

Context returns the properties available in expressions

__default__:text -> the name
uuid:text -> the UUID of the topic
name:text -> the name of the topic

@context topic

func (*Topic) Reference added in v0.132.0

func (t *Topic) Reference() *assets.TopicReference

Reference returns a reference to this topic

type TopicAssets added in v0.132.0

type TopicAssets struct {
	// contains filtered or unexported fields
}

TopicAssets provides access to all topic assets

func NewTopicAssets added in v0.132.0

func NewTopicAssets(topics []assets.Topic) *TopicAssets

NewTopicAssets creates a new set of topic assets

func (*TopicAssets) FindByName added in v0.133.0

func (s *TopicAssets) FindByName(name string) *Topic

FindByName looks for a topic with the given name (case-insensitive)

func (*TopicAssets) Get added in v0.132.0

func (s *TopicAssets) Get(uuid assets.TopicUUID) *Topic

Get returns the topic with the given UUID

type Trigger added in v0.4.0

type Trigger interface {
	utils.Typed
	Contextable

	Event() events.Event
	Flow() *assets.FlowReference
	Batch() bool
	Params() *types.XObject
	History() *core.SessionHistory
	TriggeredOn() time.Time

	Input(SessionAssets) Input
}

Trigger represents something which can initiate a session with the flow engine

type TriggerWithRun added in v0.24.0

type TriggerWithRun interface {
	Trigger

	RunSummary() []byte
}

TriggerWithRun is special case of trigger that provides a parent run to the session

type URN

type URN struct {
	Scheme  string
	Path    string
	Display string
	Channel *Channel
}

URN adds additional functionality around urns.URN such as channel affinity.

func NewURN added in v0.260.0

func NewURN(scheme, path, display string, channel *Channel) *URN

NewURN creates a new contact URN with associated channel

func ParseURN added in v0.260.0

func ParseURN(ca *ChannelAssets, encoded urns.URN, missing assets.MissingCallback) (*URN, error)

ParseURN converts an encoded urns.URN to a URN

func (*URN) Encode added in v0.260.0

func (u *URN) Encode() urns.URN

Encode gets the URN as an encoded string

func (*URN) Equal added in v0.260.0

func (u *URN) Equal(other *URN) bool

Equal determines if this URN is equal to another

func (*URN) Identity added in v0.260.0

func (u *URN) Identity() urns.URN

Identity gets the URN as an identity URN (just scheme and path)

func (*URN) ToXValue added in v0.260.0

func (u *URN) ToXValue(env envs.Environment) types.XValue

ToXValue returns a representation of this object for use in expressions

type URNList

type URNList []*URN

URNList is the list of a contact's URNs

func NewURNList added in v0.260.0

func NewURNList(sa SessionAssets, encoded []urns.URN, missing assets.MissingCallback) (URNList, error)

func (URNList) Encode added in v0.260.0

func (l URNList) Encode() []urns.URN

Encode returns encoded URNs

func (URNList) Equal added in v0.23.0

func (l URNList) Equal(other URNList) bool

Equal returns whether this list of URNs is equal to another

func (URNList) MapContext added in v0.31.0

func (l URNList) MapContext(env envs.Environment) map[string]types.XValue

MapContext returns a map of the highest priority URN for each scheme - exposed in expressions as @urns

func (URNList) ToXValue added in v0.32.0

func (l URNList) ToXValue(env envs.Environment) types.XValue

ToXValue returns a representation of this object for use in expressions

func (URNList) WithScheme added in v0.4.4

func (l URNList) WithScheme(schemes ...string) URNList

WithScheme returns a new URN list containing of only URNs of the given schemes

type User added in v0.124.0

type User struct {
	assets.User
}

User adds some functionality to user assets.

func NewUser added in v0.124.0

func NewUser(asset assets.User) *User

NewUser returns a new user object from the given user asset

func (*User) Asset added in v0.124.0

func (u *User) Asset() assets.User

Asset returns the underlying asset

func (*User) Context added in v0.124.0

func (u *User) Context(env envs.Environment) map[string]types.XValue

Context returns the properties available in expressions

__default__:text -> the name or email
email:text -> the email address of the user
name:text -> the name of the user
first_name:text -> the first name of the user

@context user

func (*User) Format added in v0.124.4

func (u *User) Format() string

Format returns a friendly string version of this user depending on what fields are set

func (*User) Reference added in v0.124.0

func (u *User) Reference() *assets.UserReference

Reference returns a reference to this user

type UserAssets added in v0.124.0

type UserAssets struct {
	// contains filtered or unexported fields
}

UserAssets provides access to all user assets

func NewUserAssets added in v0.124.0

func NewUserAssets(users []assets.User) *UserAssets

NewUserAssets creates a new set of user assets

func (*UserAssets) FindByEmail added in v0.245.1

func (s *UserAssets) FindByEmail(email string) *User

FindByEmail looks for a user with the given email (case-insensitive)

func (*UserAssets) Get added in v0.124.0

func (s *UserAssets) Get(uuid assets.UserUUID) *User

Get returns the user with the given UUID

type Wait

type Wait interface {
	utils.Typed
	FlowTypeRestricted

	Timeout() Timeout

	Begin(Run, events.EventLogger) bool
	Accepts(Resume) bool
}

Wait tells the engine that the session requires input from the user

type WebhookCall added in v0.8.0

type WebhookCall struct {
	Method          string            `json:"method"`
	URL             string            `json:"url"`
	ResponseStatus  int               `json:"status"`
	ResponseHeaders map[string]string `json:"headers"`
	ResponseJSON    json.RawMessage   `json:"json"`
}

WebhookCall holds the details of a webhook call

func NewWebhookCall added in v0.10.20

func NewWebhookCall(t *httpx.Trace) *WebhookCall

NewWebhookCall creates a new webhook call from a trace

func (*WebhookCall) Context added in v0.204.0

func (w *WebhookCall) Context(env envs.Environment) map[string]types.XValue

Context returns the properties available in expressions

__default__:text -> the method and URL
status:number -> the response status code
headers:any -> the response headers
json:any -> the response body if valid JSON

@context webhook

type WebhookService added in v0.49.0

type WebhookService interface {
	Call(request *http.Request) (*httpx.Trace, error)
}

WebhookService provides webhook functionality to the engine

Jump to

Keyboard shortcuts

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