Documentation ¶
Index ¶
- Constants
- func EnsureDynamicGroups(session flows.Session)
- func NewManualTrigger(env utils.Environment, contact *flows.Contact, flow *assets.FlowReference, ...) flows.Trigger
- func NewMsgTrigger(env utils.Environment, contact *flows.Contact, flow *assets.FlowReference, ...) flows.Trigger
- func ReadCampaignTrigger(session flows.Session, data json.RawMessage) (flows.Trigger, error)
- func ReadChannelTrigger(session flows.Session, data json.RawMessage) (flows.Trigger, error)
- func ReadFlowActionTrigger(session flows.Session, data json.RawMessage) (flows.Trigger, error)
- func ReadManualTrigger(session flows.Session, data json.RawMessage) (flows.Trigger, error)
- func ReadMsgTrigger(session flows.Session, data json.RawMessage) (flows.Trigger, error)
- func ReadTrigger(session flows.Session, data json.RawMessage) (flows.Trigger, error)
- func RegisterType(name string, f readFunc)
- type Campaign
- type CampaignEvent
- type CampaignTrigger
- func (t *CampaignTrigger) Contact() *flows.Contact
- func (t *CampaignTrigger) Describe() string
- func (t *CampaignTrigger) Environment() utils.Environment
- func (t *CampaignTrigger) Flow() *assets.FlowReference
- func (t *CampaignTrigger) Initialize(session flows.Session) error
- func (t *CampaignTrigger) InitializeRun(run flows.FlowRun, step flows.Step) error
- func (t *CampaignTrigger) MarshalJSON() ([]byte, error)
- func (t *CampaignTrigger) Params() types.XValue
- func (t *CampaignTrigger) Reduce(env utils.Environment) types.XPrimitive
- func (t *CampaignTrigger) Resolve(env utils.Environment, key string) types.XValue
- func (t *CampaignTrigger) ToXJSON(env utils.Environment) types.XText
- func (t *CampaignTrigger) TriggeredOn() time.Time
- func (t *CampaignTrigger) Type() string
- type ChannelEvent
- type ChannelTrigger
- func (t *ChannelTrigger) Contact() *flows.Contact
- func (t *ChannelTrigger) Describe() string
- func (t *ChannelTrigger) Environment() utils.Environment
- func (t *ChannelTrigger) Flow() *assets.FlowReference
- func (t *ChannelTrigger) Initialize(session flows.Session) error
- func (t *ChannelTrigger) InitializeRun(run flows.FlowRun, step flows.Step) error
- func (t *ChannelTrigger) MarshalJSON() ([]byte, error)
- func (t *ChannelTrigger) Params() types.XValue
- func (t *ChannelTrigger) Reduce(env utils.Environment) types.XPrimitive
- func (t *ChannelTrigger) Resolve(env utils.Environment, key string) types.XValue
- func (t *ChannelTrigger) ToXJSON(env utils.Environment) types.XText
- func (t *ChannelTrigger) TriggeredOn() time.Time
- func (t *ChannelTrigger) Type() string
- type FlowActionTrigger
- func (t *FlowActionTrigger) Contact() *flows.Contact
- func (t *FlowActionTrigger) Describe() string
- func (t *FlowActionTrigger) Environment() utils.Environment
- func (t *FlowActionTrigger) Flow() *assets.FlowReference
- func (t *FlowActionTrigger) Initialize(session flows.Session) error
- func (t *FlowActionTrigger) InitializeRun(run flows.FlowRun, step flows.Step) error
- func (t *FlowActionTrigger) MarshalJSON() ([]byte, error)
- func (t *FlowActionTrigger) Params() types.XValue
- func (t *FlowActionTrigger) Reduce(env utils.Environment) types.XPrimitive
- func (t *FlowActionTrigger) Resolve(env utils.Environment, key string) types.XValue
- func (t *FlowActionTrigger) Run() flows.RunSummary
- func (t *FlowActionTrigger) ToXJSON(env utils.Environment) types.XText
- func (t *FlowActionTrigger) TriggeredOn() time.Time
- func (t *FlowActionTrigger) Type() string
- type KeywordMatch
- type KeywordMatchType
- type ManualTrigger
- func (t *ManualTrigger) Contact() *flows.Contact
- func (t *ManualTrigger) Describe() string
- func (t *ManualTrigger) Environment() utils.Environment
- func (t *ManualTrigger) Flow() *assets.FlowReference
- func (t *ManualTrigger) Initialize(session flows.Session) error
- func (t *ManualTrigger) InitializeRun(run flows.FlowRun, step flows.Step) error
- func (t *ManualTrigger) MarshalJSON() ([]byte, error)
- func (t *ManualTrigger) Params() types.XValue
- func (t *ManualTrigger) Reduce(env utils.Environment) types.XPrimitive
- func (t *ManualTrigger) Resolve(env utils.Environment, key string) types.XValue
- func (t *ManualTrigger) ToXJSON(env utils.Environment) types.XText
- func (t *ManualTrigger) TriggeredOn() time.Time
- func (t *ManualTrigger) Type() string
- type MsgTrigger
- func (t *MsgTrigger) Contact() *flows.Contact
- func (t *MsgTrigger) Describe() string
- func (t *MsgTrigger) Environment() utils.Environment
- func (t *MsgTrigger) Flow() *assets.FlowReference
- func (t *MsgTrigger) Initialize(session flows.Session) error
- func (t *MsgTrigger) InitializeRun(run flows.FlowRun, step flows.Step) error
- func (t *MsgTrigger) MarshalJSON() ([]byte, error)
- func (t *MsgTrigger) Params() types.XValue
- func (t *MsgTrigger) Reduce(env utils.Environment) types.XPrimitive
- func (t *MsgTrigger) Resolve(env utils.Environment, key string) types.XValue
- func (t *MsgTrigger) ToXJSON(env utils.Environment) types.XText
- func (t *MsgTrigger) TriggeredOn() time.Time
- func (t *MsgTrigger) Type() string
Constants ¶
const TypeCampaign string = "campaign"
TypeCampaign is the type for sessions triggered by campaign events
const TypeChannel string = "channel"
TypeChannel is the type for sessions triggered by channel events
const TypeFlowAction string = "flow_action"
TypeFlowAction is a constant for sessions triggered by flow actions in other sessions
const TypeManual string = "manual"
TypeManual is the type for manually triggered sessions
const TypeMsg string = "msg"
TypeMsg is the type for message triggered sessions
Variables ¶
This section is empty.
Functions ¶
func EnsureDynamicGroups ¶ added in v0.21.1
EnsureDynamicGroups ensures that our session contact is in the correct dynamic groups as as far as the engine is concerned
func NewManualTrigger ¶
func NewManualTrigger(env utils.Environment, contact *flows.Contact, flow *assets.FlowReference, params types.XValue, triggeredOn time.Time) flows.Trigger
NewManualTrigger creates a new manual trigger
func NewMsgTrigger ¶ added in v0.20.0
func NewMsgTrigger(env utils.Environment, contact *flows.Contact, flow *assets.FlowReference, msg *flows.MsgIn, match *KeywordMatch, triggeredOn time.Time) flows.Trigger
NewMsgTrigger creates a new message trigger
func ReadCampaignTrigger ¶ added in v0.12.2
ReadCampaignTrigger reads a campaign trigger
func ReadChannelTrigger ¶ added in v0.22.0
ReadChannelTrigger reads a channel trigger
func ReadFlowActionTrigger ¶
ReadFlowActionTrigger reads a flow action trigger
func ReadManualTrigger ¶
ReadManualTrigger reads a manual trigger
func ReadMsgTrigger ¶ added in v0.20.0
ReadMsgTrigger reads a message trigger
func ReadTrigger ¶
ReadTrigger reads a trigger from the given JSON
func RegisterType ¶ added in v0.11.0
func RegisterType(name string, f readFunc)
RegisterType registers a new type of trigger
Types ¶
type Campaign ¶ added in v0.12.2
type Campaign struct { UUID string `json:"uuid" validate:"required,uuid4"` Name string `json:"name" validate:"required"` }
Campaign describes the campaign that triggered the session
type CampaignEvent ¶ added in v0.12.2
type CampaignEvent struct { UUID string `json:"uuid" validate:"required,uuid4"` Campaign Campaign `json:"campaign" validate:"required,dive"` }
CampaignEvent describes the specific event in the campaign that triggered the session
type CampaignTrigger ¶ added in v0.12.2
type CampaignTrigger struct {
// contains filtered or unexported fields
}
CampaignTrigger is used when a session was triggered by a campaign event
{ "type": "campaign", "flow": {"uuid": "50c3706e-fedb-42c0-8eab-dda3335714b7", "name": "Registration"}, "contact": { "uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81", "name": "Bob", "created_on": "2018-01-01T12:00:00.000000Z" }, "event": { "uuid": "34d16dbd-476d-4b77-bac3-9f3d597848cc", "campaign": {"uuid": "58e9b092-fe42-4173-876c-ff45a14a24fe", "name": "New Mothers"} }, "triggered_on": "2000-01-01T00:00:00.000000000-00:00" }
@trigger campaign
func NewCampaignTrigger ¶ added in v0.14.4
func NewCampaignTrigger(env utils.Environment, flow *assets.FlowReference, contact *flows.Contact, event *CampaignEvent, triggeredOn time.Time) *CampaignTrigger
NewCampaignTrigger creates a new campaign trigger with the passed in values
func (*CampaignTrigger) Describe ¶ added in v0.12.2
func (t *CampaignTrigger) Describe() string
Describe returns a representation of this type for error messages
func (*CampaignTrigger) Environment ¶ added in v0.12.2
func (t *CampaignTrigger) Environment() utils.Environment
func (*CampaignTrigger) Flow ¶ added in v0.12.2
func (t *CampaignTrigger) Flow() *assets.FlowReference
func (*CampaignTrigger) Initialize ¶ added in v0.20.0
Initialize initializes the session
func (*CampaignTrigger) InitializeRun ¶ added in v0.20.0
InitializeRun performs additional initialization when we create our first run
func (*CampaignTrigger) MarshalJSON ¶ added in v0.12.2
func (t *CampaignTrigger) MarshalJSON() ([]byte, error)
MarshalJSON marshals this trigger into JSON
func (*CampaignTrigger) Reduce ¶ added in v0.12.2
func (t *CampaignTrigger) Reduce(env utils.Environment) types.XPrimitive
Reduce is called when this object needs to be reduced to a primitive
func (*CampaignTrigger) Resolve ¶ added in v0.12.2
func (t *CampaignTrigger) Resolve(env utils.Environment, key string) types.XValue
Resolve resolves the given key when this trigger is referenced in an expression
func (*CampaignTrigger) ToXJSON ¶ added in v0.12.2
func (t *CampaignTrigger) ToXJSON(env utils.Environment) types.XText
ToXJSON is called when this type is passed to @(json(...))
func (*CampaignTrigger) TriggeredOn ¶ added in v0.12.2
type ChannelEvent ¶ added in v0.22.0
type ChannelEvent struct { Type string `json:"type" validate:"required"` Channel assets.ChannelReference `json:"channel" validate:"required,dive"` }
ChannelEvent describes the specific event on the channel that triggered the session
type ChannelTrigger ¶ added in v0.22.0
type ChannelTrigger struct {
// contains filtered or unexported fields
}
ChannelTrigger is used when a session was triggered by a channel event
{ "type": "channel", "flow": {"uuid": "50c3706e-fedb-42c0-8eab-dda3335714b7", "name": "Registration"}, "contact": { "uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81", "name": "Bob", "created_on": "2018-01-01T12:00:00.000000Z" }, "event": { "type": "new_conversation", "channel": {"uuid": "58e9b092-fe42-4173-876c-ff45a14a24fe", "name": "Facebook"} }, "triggered_on": "2000-01-01T00:00:00.000000000-00:00" }
@trigger channel
func NewChannelTrigger ¶ added in v0.22.0
func NewChannelTrigger(env utils.Environment, flow *assets.FlowReference, contact *flows.Contact, event *ChannelEvent, params types.XValue, triggeredOn time.Time) *ChannelTrigger
NewChannelTrigger creates a new channel trigger with the passed in values
func (*ChannelTrigger) Describe ¶ added in v0.22.0
func (t *ChannelTrigger) Describe() string
Describe returns a representation of this type for error messages
func (*ChannelTrigger) Environment ¶ added in v0.22.0
func (t *ChannelTrigger) Environment() utils.Environment
func (*ChannelTrigger) Flow ¶ added in v0.22.0
func (t *ChannelTrigger) Flow() *assets.FlowReference
func (*ChannelTrigger) Initialize ¶ added in v0.22.0
Initialize initializes the session
func (*ChannelTrigger) InitializeRun ¶ added in v0.22.0
InitializeRun performs additional initialization when we create our first run
func (*ChannelTrigger) MarshalJSON ¶ added in v0.22.0
func (t *ChannelTrigger) MarshalJSON() ([]byte, error)
MarshalJSON marshals this trigger into JSON
func (*ChannelTrigger) Reduce ¶ added in v0.22.0
func (t *ChannelTrigger) Reduce(env utils.Environment) types.XPrimitive
Reduce is called when this object needs to be reduced to a primitive
func (*ChannelTrigger) Resolve ¶ added in v0.22.0
func (t *ChannelTrigger) Resolve(env utils.Environment, key string) types.XValue
Resolve resolves the given key when this trigger is referenced in an expression
func (*ChannelTrigger) ToXJSON ¶ added in v0.22.0
func (t *ChannelTrigger) ToXJSON(env utils.Environment) types.XText
ToXJSON is called when this type is passed to @(json(...))
func (*ChannelTrigger) TriggeredOn ¶ added in v0.22.0
type FlowActionTrigger ¶
type FlowActionTrigger struct {
// contains filtered or unexported fields
}
FlowActionTrigger is used when another session triggered this run using a trigger_flow action.
{ "type": "flow_action", "flow": {"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "name": "Collect Age"}, "triggered_on": "2000-01-01T00:00:00.000000000-00:00", "run": { "uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "flow": {"uuid": "50c3706e-fedb-42c0-8eab-dda3335714b7", "name": "Registration"}, "contact": { "uuid": "c59b0033-e748-4240-9d4c-e85eb6800151", "name": "Bob", "fields": {"gender": {"text": "Male"}}, "created_on": "2018-01-01T12:00:00.000000000-00:00" }, "status": "active", "results": { "age": { "result_name": "Age", "value": "33", "node": "cd2be8c4-59bc-453c-8777-dec9a80043b8", "created_on": "2018-01-01T12:00:00.000000000-00:00" } } } }
@trigger flow_action
func (*FlowActionTrigger) Describe ¶ added in v0.10.1
func (t *FlowActionTrigger) Describe() string
Describe returns a representation of this type for error messages
func (*FlowActionTrigger) Environment ¶ added in v0.5.0
func (t *FlowActionTrigger) Environment() utils.Environment
func (*FlowActionTrigger) Flow ¶
func (t *FlowActionTrigger) Flow() *assets.FlowReference
func (*FlowActionTrigger) Initialize ¶ added in v0.20.0
Initialize initializes the session
func (*FlowActionTrigger) InitializeRun ¶ added in v0.20.0
InitializeRun performs additional initialization when we create our first run
func (*FlowActionTrigger) MarshalJSON ¶
func (t *FlowActionTrigger) MarshalJSON() ([]byte, error)
MarshalJSON marshals this trigger into JSON
func (*FlowActionTrigger) Reduce ¶ added in v0.8.0
func (t *FlowActionTrigger) Reduce(env utils.Environment) types.XPrimitive
Reduce is called when this object needs to be reduced to a primitive
func (*FlowActionTrigger) Resolve ¶ added in v0.5.0
func (t *FlowActionTrigger) Resolve(env utils.Environment, key string) types.XValue
Resolve resolves the given key when this trigger is referenced in an expression
func (*FlowActionTrigger) Run ¶
func (t *FlowActionTrigger) Run() flows.RunSummary
Run returns the summary of the run that triggered this session
func (*FlowActionTrigger) ToXJSON ¶ added in v0.8.0
func (t *FlowActionTrigger) ToXJSON(env utils.Environment) types.XText
ToXJSON is called when this type is passed to @(json(...))
func (*FlowActionTrigger) TriggeredOn ¶
type KeywordMatch ¶ added in v0.20.0
type KeywordMatch struct { Type KeywordMatchType `json:"type" validate:"required"` Keyword string `json:"keyword" validate:"required"` }
KeywordMatch describes why the message triggered a session
type KeywordMatchType ¶ added in v0.20.0
type KeywordMatchType string
KeywordMatchType describes how the message matched a keyword
const ( KeywordMatchTypeFirstWord KeywordMatchType = "first_word" KeywordMatchTypeOnlyWord KeywordMatchType = "only_word" )
the different types of keyword match
type ManualTrigger ¶
type ManualTrigger struct {
// contains filtered or unexported fields
}
ManualTrigger is used when a session was triggered manually by a user
{ "type": "manual", "flow": {"uuid": "50c3706e-fedb-42c0-8eab-dda3335714b7", "name": "Registration"}, "contact": { "uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81", "name": "Bob", "created_on": "2018-01-01T12:00:00.000000Z" }, "triggered_on": "2000-01-01T00:00:00.000000000-00:00" }
@trigger manual
func (*ManualTrigger) Describe ¶ added in v0.10.1
func (t *ManualTrigger) Describe() string
Describe returns a representation of this type for error messages
func (*ManualTrigger) Environment ¶ added in v0.5.0
func (t *ManualTrigger) Environment() utils.Environment
func (*ManualTrigger) Flow ¶
func (t *ManualTrigger) Flow() *assets.FlowReference
func (*ManualTrigger) Initialize ¶ added in v0.20.0
Initialize initializes the session
func (*ManualTrigger) InitializeRun ¶ added in v0.20.0
InitializeRun performs additional initialization when we create our first run
func (*ManualTrigger) MarshalJSON ¶
func (t *ManualTrigger) MarshalJSON() ([]byte, error)
MarshalJSON marshals this trigger into JSON
func (*ManualTrigger) Reduce ¶ added in v0.8.0
func (t *ManualTrigger) Reduce(env utils.Environment) types.XPrimitive
Reduce is called when this object needs to be reduced to a primitive
func (*ManualTrigger) Resolve ¶ added in v0.5.0
func (t *ManualTrigger) Resolve(env utils.Environment, key string) types.XValue
Resolve resolves the given key when this trigger is referenced in an expression
func (*ManualTrigger) ToXJSON ¶ added in v0.8.0
func (t *ManualTrigger) ToXJSON(env utils.Environment) types.XText
ToXJSON is called when this type is passed to @(json(...))
func (*ManualTrigger) TriggeredOn ¶
type MsgTrigger ¶ added in v0.20.0
type MsgTrigger struct {
// contains filtered or unexported fields
}
MsgTrigger is used when a session was triggered by a message being recieved by the caller
{ "type": "msg", "flow": {"uuid": "50c3706e-fedb-42c0-8eab-dda3335714b7", "name": "Registration"}, "contact": { "uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81", "name": "Bob", "created_on": "2018-01-01T12:00:00.000000Z" }, "msg": { "uuid": "2d611e17-fb22-457f-b802-b8f7ec5cda5b", "channel": {"uuid": "61602f3e-f603-4c70-8a8f-c477505bf4bf", "name": "Twilio"}, "urn": "tel:+12065551212", "text": "hi there", "attachments": ["https://s3.amazon.com/mybucket/attachment.jpg"] }, "keyword_match": { "type": "first_word", "keyword": "start" }, "triggered_on": "2000-01-01T00:00:00.000000000-00:00" }
@trigger msg
func (*MsgTrigger) Describe ¶ added in v0.20.0
func (t *MsgTrigger) Describe() string
Describe returns a representation of this type for error messages
func (*MsgTrigger) Environment ¶ added in v0.20.0
func (t *MsgTrigger) Environment() utils.Environment
func (*MsgTrigger) Flow ¶ added in v0.20.0
func (t *MsgTrigger) Flow() *assets.FlowReference
func (*MsgTrigger) Initialize ¶ added in v0.20.0
Initialize initializes the session
func (*MsgTrigger) InitializeRun ¶ added in v0.20.0
InitializeRun performs additional initialization when we visit our first node
func (*MsgTrigger) MarshalJSON ¶ added in v0.20.0
func (t *MsgTrigger) MarshalJSON() ([]byte, error)
MarshalJSON marshals this trigger into JSON
func (*MsgTrigger) Reduce ¶ added in v0.20.0
func (t *MsgTrigger) Reduce(env utils.Environment) types.XPrimitive
Reduce is called when this object needs to be reduced to a primitive
func (*MsgTrigger) Resolve ¶ added in v0.20.0
func (t *MsgTrigger) Resolve(env utils.Environment, key string) types.XValue
Resolve resolves the given key when this trigger is referenced in an expression
func (*MsgTrigger) ToXJSON ¶ added in v0.20.0
func (t *MsgTrigger) ToXJSON(env utils.Environment) types.XText
ToXJSON is called when this type is passed to @(json(...))