Documentation ¶
Index ¶
- Constants
- func ReadTrigger(sessionAssets flows.SessionAssets, data json.RawMessage, ...) (flows.Trigger, error)
- func RegisteredTypes() map[string]ReadFunc
- type Builder
- func (b *Builder) Campaign(campaign *CampaignReference, eventUUID CampaignEventUUID) *CampaignBuilder
- func (b *Builder) Channel(channel *assets.ChannelReference, eventType ChannelEventType) *ChannelBuilder
- func (b *Builder) FlowAction(history *flows.SessionHistory, runSummary json.RawMessage) *FlowActionBuilder
- func (b *Builder) Manual() *ManualBuilder
- func (b *Builder) Msg(msg *flows.MsgIn) *MsgBuilder
- func (b *Builder) OptIn(optIn *flows.OptIn, eventType OptInEventType) *OptInBuilder
- func (b *Builder) Ticket(ticket *flows.Ticket, eventType TicketEventType) *TicketBuilder
- type CampaignBuilder
- type CampaignEvent
- type CampaignEventUUID
- type CampaignReference
- type CampaignTrigger
- func (t *CampaignTrigger) Batch() bool
- func (t *CampaignTrigger) Call() *flows.Call
- func (t *CampaignTrigger) Contact() *flows.Contact
- func (t *CampaignTrigger) Context(env envs.Environment) map[string]types.XValue
- func (t *CampaignTrigger) Environment() envs.Environment
- func (t *CampaignTrigger) Flow() *assets.FlowReference
- func (t *CampaignTrigger) History() *flows.SessionHistory
- func (t *CampaignTrigger) Initialize(session flows.Session, logEvent flows.EventCallback) error
- func (t *CampaignTrigger) InitializeRun(run flows.Run, logEvent flows.EventCallback) error
- func (t *CampaignTrigger) MarshalJSON() ([]byte, error)
- func (t *CampaignTrigger) Params() *types.XObject
- func (t *CampaignTrigger) TriggeredOn() time.Time
- func (t *CampaignTrigger) Type() string
- type CampaignUUID
- type ChannelBuilder
- type ChannelEvent
- type ChannelEventType
- type ChannelTrigger
- func (t *ChannelTrigger) Batch() bool
- func (t *ChannelTrigger) Call() *flows.Call
- func (t *ChannelTrigger) Contact() *flows.Contact
- func (t *ChannelTrigger) Context(env envs.Environment) map[string]types.XValue
- func (t *ChannelTrigger) Environment() envs.Environment
- func (t *ChannelTrigger) Flow() *assets.FlowReference
- func (t *ChannelTrigger) History() *flows.SessionHistory
- func (t *ChannelTrigger) Initialize(session flows.Session, logEvent flows.EventCallback) error
- func (t *ChannelTrigger) InitializeRun(run flows.Run, logEvent flows.EventCallback) error
- func (t *ChannelTrigger) MarshalJSON() ([]byte, error)
- func (t *ChannelTrigger) Params() *types.XObject
- func (t *ChannelTrigger) TriggeredOn() time.Time
- func (t *ChannelTrigger) Type() string
- type Context
- type FlowActionBuilder
- type FlowActionTrigger
- func (t *FlowActionTrigger) Batch() bool
- func (t *FlowActionTrigger) Call() *flows.Call
- func (t *FlowActionTrigger) Contact() *flows.Contact
- func (t *FlowActionTrigger) Context(env envs.Environment) map[string]types.XValue
- func (t *FlowActionTrigger) Environment() envs.Environment
- func (t *FlowActionTrigger) Flow() *assets.FlowReference
- func (t *FlowActionTrigger) History() *flows.SessionHistory
- func (t *FlowActionTrigger) Initialize(session flows.Session, logEvent flows.EventCallback) error
- func (t *FlowActionTrigger) InitializeRun(run flows.Run, logEvent flows.EventCallback) error
- func (t *FlowActionTrigger) MarshalJSON() ([]byte, error)
- func (t *FlowActionTrigger) Params() *types.XObject
- func (t *FlowActionTrigger) RunSummary() json.RawMessage
- func (t *FlowActionTrigger) TriggeredOn() time.Time
- func (t *FlowActionTrigger) Type() string
- type KeywordMatch
- type KeywordMatchType
- type ManualBuilder
- func (b *ManualBuilder) AsBatch() *ManualBuilder
- func (b *ManualBuilder) Build() *ManualTrigger
- func (b *ManualBuilder) WithCall(channel *assets.ChannelReference, urn urns.URN) *ManualBuilder
- func (b *ManualBuilder) WithOrigin(origin string) *ManualBuilder
- func (b *ManualBuilder) WithParams(params *types.XObject) *ManualBuilder
- func (b *ManualBuilder) WithUser(user *flows.User) *ManualBuilder
- type ManualTrigger
- func (t *ManualTrigger) Batch() bool
- func (t *ManualTrigger) Call() *flows.Call
- func (t *ManualTrigger) Contact() *flows.Contact
- func (t *ManualTrigger) Context(env envs.Environment) map[string]types.XValue
- func (t *ManualTrigger) Environment() envs.Environment
- func (t *ManualTrigger) Flow() *assets.FlowReference
- func (t *ManualTrigger) History() *flows.SessionHistory
- func (t *ManualTrigger) Initialize(session flows.Session, logEvent flows.EventCallback) error
- func (t *ManualTrigger) InitializeRun(run flows.Run, logEvent flows.EventCallback) error
- func (t *ManualTrigger) MarshalJSON() ([]byte, error)
- func (t *ManualTrigger) Params() *types.XObject
- func (t *ManualTrigger) TriggeredOn() time.Time
- func (t *ManualTrigger) Type() string
- type MsgBuilder
- type MsgTrigger
- func (t *MsgTrigger) Batch() bool
- func (t *MsgTrigger) Call() *flows.Call
- func (t *MsgTrigger) Contact() *flows.Contact
- func (t *MsgTrigger) Context(env envs.Environment) map[string]types.XValue
- func (t *MsgTrigger) Environment() envs.Environment
- func (t *MsgTrigger) Flow() *assets.FlowReference
- func (t *MsgTrigger) History() *flows.SessionHistory
- func (t *MsgTrigger) Initialize(session flows.Session, logEvent flows.EventCallback) error
- func (t *MsgTrigger) InitializeRun(run flows.Run, logEvent flows.EventCallback) error
- func (t *MsgTrigger) MarshalJSON() ([]byte, error)
- func (t *MsgTrigger) Params() *types.XObject
- func (t *MsgTrigger) TriggeredOn() time.Time
- func (t *MsgTrigger) Type() string
- type OptInBuilder
- type OptInEvent
- type OptInEventType
- type OptInTrigger
- func (t *OptInTrigger) Batch() bool
- func (t *OptInTrigger) Call() *flows.Call
- func (t *OptInTrigger) Contact() *flows.Contact
- func (t *OptInTrigger) Context(env envs.Environment) map[string]types.XValue
- func (t *OptInTrigger) Environment() envs.Environment
- func (t *OptInTrigger) Flow() *assets.FlowReference
- func (t *OptInTrigger) History() *flows.SessionHistory
- func (t *OptInTrigger) Initialize(session flows.Session, logEvent flows.EventCallback) error
- func (t *OptInTrigger) InitializeRun(run flows.Run, logEvent flows.EventCallback) error
- func (t *OptInTrigger) MarshalJSON() ([]byte, error)
- func (t *OptInTrigger) Params() *types.XObject
- func (t *OptInTrigger) TriggeredOn() time.Time
- func (t *OptInTrigger) Type() string
- type ReadFunc
- type TicketBuilder
- type TicketEvent
- type TicketEventType
- type TicketTrigger
- func (t *TicketTrigger) Batch() bool
- func (t *TicketTrigger) Call() *flows.Call
- func (t *TicketTrigger) Contact() *flows.Contact
- func (t *TicketTrigger) Context(env envs.Environment) map[string]types.XValue
- func (t *TicketTrigger) Environment() envs.Environment
- func (t *TicketTrigger) Flow() *assets.FlowReference
- func (t *TicketTrigger) History() *flows.SessionHistory
- func (t *TicketTrigger) Initialize(session flows.Session, logEvent flows.EventCallback) error
- func (t *TicketTrigger) InitializeRun(run flows.Run, logEvent flows.EventCallback) error
- func (t *TicketTrigger) MarshalJSON() ([]byte, error)
- func (t *TicketTrigger) Params() *types.XObject
- func (t *TicketTrigger) TriggeredOn() time.Time
- func (t *TicketTrigger) 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
const TypeOptIn string = "optin"
TypeOptIn is the type for sessions triggered by optin/optout events
const TypeTicket string = "ticket"
TypeTicket is the type for sessions triggered by ticket events
Variables ¶
This section is empty.
Functions ¶
func ReadTrigger ¶
func ReadTrigger(sessionAssets flows.SessionAssets, data json.RawMessage, missing assets.MissingCallback) (flows.Trigger, error)
ReadTrigger reads a trigger from the given JSON
func RegisteredTypes ¶ added in v0.59.0
RegisteredTypes gets the registered types of trigger
Types ¶
type Builder ¶ added in v0.95.0
type Builder struct {
// contains filtered or unexported fields
}
Builder is a builder for triggers
func NewBuilder ¶ added in v0.95.0
func NewBuilder(env envs.Environment, flow *assets.FlowReference, contact *flows.Contact) *Builder
NewBuilder creates a new trigger builder
func (*Builder) Campaign ¶ added in v0.95.0
func (b *Builder) Campaign(campaign *CampaignReference, eventUUID CampaignEventUUID) *CampaignBuilder
Campaign returns a campaign trigger builder
func (*Builder) Channel ¶ added in v0.95.0
func (b *Builder) Channel(channel *assets.ChannelReference, eventType ChannelEventType) *ChannelBuilder
Channel returns a channel trigger builder
func (*Builder) FlowAction ¶ added in v0.95.0
func (b *Builder) FlowAction(history *flows.SessionHistory, runSummary json.RawMessage) *FlowActionBuilder
FlowAction returns a flow action trigger builder
func (*Builder) Manual ¶ added in v0.95.0
func (b *Builder) Manual() *ManualBuilder
Manual returns a manual trigger builder
func (*Builder) Msg ¶ added in v0.95.0
func (b *Builder) Msg(msg *flows.MsgIn) *MsgBuilder
Msg returns a msg trigger builder
func (*Builder) OptIn ¶ added in v0.195.0
func (b *Builder) OptIn(optIn *flows.OptIn, eventType OptInEventType) *OptInBuilder
OptIn returns a optin trigger builder
func (*Builder) Ticket ¶ added in v0.120.0
func (b *Builder) Ticket(ticket *flows.Ticket, eventType TicketEventType) *TicketBuilder
Ticket returns a ticket trigger builder
type CampaignBuilder ¶ added in v0.95.0
type CampaignBuilder struct {
// contains filtered or unexported fields
}
CampaignBuilder is a builder for campaign type triggers
func (*CampaignBuilder) Build ¶ added in v0.95.0
func (b *CampaignBuilder) Build() *CampaignTrigger
Build builds the trigger
type CampaignEvent ¶ added in v0.12.2
type CampaignEvent struct { UUID CampaignEventUUID `json:"uuid" validate:"required,uuid4"` Campaign *CampaignReference `json:"campaign" validate:"required"` }
CampaignEvent describes the specific event in the campaign that triggered the session
type CampaignEventUUID ¶ added in v0.95.0
CampaignEventUUID is the type for campaign event UUIDs
type CampaignReference ¶ added in v0.24.0
type CampaignReference struct { UUID CampaignUUID `json:"uuid" validate:"required,uuid4"` Name string `json:"name" validate:"required"` }
CampaignReference is a reference to the campaign that triggered the session
func NewCampaignReference ¶ added in v0.24.0
func NewCampaignReference(uuid CampaignUUID, name string) *CampaignReference
NewCampaignReference creates a new campaign reference
func (*CampaignReference) Context ¶ added in v0.147.0
func (c *CampaignReference) Context(env envs.Environment) map[string]types.XValue
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 (*CampaignTrigger) Context ¶ added in v0.33.8
func (t *CampaignTrigger) Context(env envs.Environment) map[string]types.XValue
Context for manual triggers always has non-nil params
func (*CampaignTrigger) Environment ¶ added in v0.12.2
func (t *CampaignTrigger) Environment() envs.Environment
func (*CampaignTrigger) Flow ¶ added in v0.12.2
func (t *CampaignTrigger) Flow() *assets.FlowReference
func (*CampaignTrigger) History ¶ added in v0.96.0
func (t *CampaignTrigger) History() *flows.SessionHistory
func (*CampaignTrigger) Initialize ¶ added in v0.20.0
func (t *CampaignTrigger) Initialize(session flows.Session, logEvent flows.EventCallback) error
Initialize initializes the session
func (*CampaignTrigger) InitializeRun ¶ added in v0.20.0
func (t *CampaignTrigger) InitializeRun(run flows.Run, logEvent flows.EventCallback) error
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) TriggeredOn ¶ added in v0.12.2
type CampaignUUID ¶ added in v0.95.0
CampaignUUID is the type for campaign UUIDs
type ChannelBuilder ¶ added in v0.95.0
type ChannelBuilder struct {
// contains filtered or unexported fields
}
ChannelBuilder is a builder for channel type triggers
func (*ChannelBuilder) Build ¶ added in v0.95.0
func (b *ChannelBuilder) Build() *ChannelTrigger
Build builds the trigger
func (*ChannelBuilder) WithCall ¶ added in v0.171.0
func (b *ChannelBuilder) WithCall(urn urns.URN) *ChannelBuilder
WithCall sets the call for the trigger
func (*ChannelBuilder) WithParams ¶ added in v0.95.0
func (b *ChannelBuilder) WithParams(params *types.XObject) *ChannelBuilder
WithParams sets the params for the trigger
type ChannelEvent ¶ added in v0.22.0
type ChannelEvent struct { Type ChannelEventType `json:"type" validate:"required"` Channel *assets.ChannelReference `json:"channel" validate:"required"` }
ChannelEvent describes the specific event on the channel that triggered the session
type ChannelEventType ¶ added in v0.24.0
type ChannelEventType string
ChannelEventType is the type of event that occurred on the channel
const ( ChannelEventTypeIncomingCall ChannelEventType = "incoming_call" ChannelEventTypeMissedCall ChannelEventType = "missed_call" ChannelEventTypeNewConversation ChannelEventType = "new_conversation" ChannelEventTypeReferral ChannelEventType = "referral" )
different channel event types
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 (*ChannelTrigger) Context ¶ added in v0.33.8
func (t *ChannelTrigger) Context(env envs.Environment) map[string]types.XValue
Context returns the properties available in expressions
type:text -> the type of trigger that started this session params:any -> the parameters passed to the trigger keyword:text -> the keyword match if this is a keyword trigger user:user -> the user who started this session if this is a manual trigger origin:text -> the origin of this session if this is a manual trigger ticket:ticket -> the ticket if this is a ticket trigger
@context trigger
func (*ChannelTrigger) Environment ¶ added in v0.22.0
func (t *ChannelTrigger) Environment() envs.Environment
func (*ChannelTrigger) Flow ¶ added in v0.22.0
func (t *ChannelTrigger) Flow() *assets.FlowReference
func (*ChannelTrigger) History ¶ added in v0.96.0
func (t *ChannelTrigger) History() *flows.SessionHistory
func (*ChannelTrigger) Initialize ¶ added in v0.22.0
func (t *ChannelTrigger) Initialize(session flows.Session, logEvent flows.EventCallback) error
Initialize initializes the session
func (*ChannelTrigger) InitializeRun ¶ added in v0.22.0
func (t *ChannelTrigger) InitializeRun(run flows.Run, logEvent flows.EventCallback) error
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) TriggeredOn ¶ added in v0.22.0
type Context ¶ added in v0.95.0
type Context struct {
// contains filtered or unexported fields
}
Context is the schema of trigger objects in the context, across all types
type FlowActionBuilder ¶ added in v0.95.0
type FlowActionBuilder struct {
// contains filtered or unexported fields
}
FlowActionBuilder is a builder for flow action type triggers
func (*FlowActionBuilder) AsBatch ¶ added in v0.95.0
func (b *FlowActionBuilder) AsBatch() *FlowActionBuilder
AsBatch sets batch mode on for the trigger
func (*FlowActionBuilder) Build ¶ added in v0.95.0
func (b *FlowActionBuilder) Build() *FlowActionTrigger
Build builds the trigger
func (*FlowActionBuilder) WithCall ¶ added in v0.171.0
func (b *FlowActionBuilder) WithCall(channel *assets.ChannelReference, urn urns.URN) *FlowActionBuilder
WithCall sets the call for the trigger
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"}, "contact": { "uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81", "name": "Bob", "created_on": "2018-01-01T12:00:00.000000Z" }, "history": { "parent_uuid": "a5b25fb0-75fd-4898-a34f-5ff14fc19078", "ancestors": 3, "ancestors_since_input": 1 }, "triggered_on": "2000-01-01T00:00:00.000000000-00:00", "run_summary": { "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) Context ¶ added in v0.33.8
func (t *FlowActionTrigger) Context(env envs.Environment) map[string]types.XValue
Context returns the properties available in expressions
type:text -> the type of trigger that started this session params:any -> the parameters passed to the trigger keyword:text -> the keyword match if this is a keyword trigger user:user -> the user who started this session if this is a manual trigger origin:text -> the origin of this session if this is a manual trigger ticket:ticket -> the ticket if this is a ticket trigger
@context trigger
func (*FlowActionTrigger) Environment ¶ added in v0.5.0
func (t *FlowActionTrigger) Environment() envs.Environment
func (*FlowActionTrigger) Flow ¶
func (t *FlowActionTrigger) Flow() *assets.FlowReference
func (*FlowActionTrigger) History ¶ added in v0.96.0
func (t *FlowActionTrigger) History() *flows.SessionHistory
func (*FlowActionTrigger) Initialize ¶ added in v0.20.0
func (t *FlowActionTrigger) Initialize(session flows.Session, logEvent flows.EventCallback) error
Initialize initializes the session
func (*FlowActionTrigger) InitializeRun ¶ added in v0.20.0
func (t *FlowActionTrigger) InitializeRun(run flows.Run, logEvent flows.EventCallback) error
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) RunSummary ¶ added in v0.24.0
func (t *FlowActionTrigger) RunSummary() json.RawMessage
RunSummary returns the summary of the run that triggered this session
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
func NewKeywordMatch ¶ added in v0.24.0
func NewKeywordMatch(typeName KeywordMatchType, keyword string) *KeywordMatch
NewKeywordMatch creates a new keyword match
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 ManualBuilder ¶ added in v0.95.0
type ManualBuilder struct {
// contains filtered or unexported fields
}
ManualBuilder is a builder for manual type triggers
func (*ManualBuilder) AsBatch ¶ added in v0.95.0
func (b *ManualBuilder) AsBatch() *ManualBuilder
AsBatch sets batch mode on for the trigger
func (*ManualBuilder) Build ¶ added in v0.95.0
func (b *ManualBuilder) Build() *ManualTrigger
Build builds the trigger
func (*ManualBuilder) WithCall ¶ added in v0.171.0
func (b *ManualBuilder) WithCall(channel *assets.ChannelReference, urn urns.URN) *ManualBuilder
WithCall sets the call for the trigger
func (*ManualBuilder) WithOrigin ¶ added in v0.95.0
func (b *ManualBuilder) WithOrigin(origin string) *ManualBuilder
WithOrigin sets the origin (e.g. ui, api) for the trigger
func (*ManualBuilder) WithParams ¶ added in v0.95.0
func (b *ManualBuilder) WithParams(params *types.XObject) *ManualBuilder
WithParams sets the params for the trigger
func (*ManualBuilder) WithUser ¶ added in v0.95.0
func (b *ManualBuilder) WithUser(user *flows.User) *ManualBuilder
WithUser sets the user (e.g. an email address, login) for the trigger
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" }, "user": {"email": "bob@nyaruka.com", "name": "Bob"}, "origin": "ui", "triggered_on": "2000-01-01T00:00:00.000000000-00:00" }
@trigger manual
func (*ManualTrigger) Context ¶ added in v0.33.8
func (t *ManualTrigger) Context(env envs.Environment) map[string]types.XValue
Context for manual triggers always has non-nil params
func (*ManualTrigger) Environment ¶ added in v0.5.0
func (t *ManualTrigger) Environment() envs.Environment
func (*ManualTrigger) Flow ¶
func (t *ManualTrigger) Flow() *assets.FlowReference
func (*ManualTrigger) History ¶ added in v0.96.0
func (t *ManualTrigger) History() *flows.SessionHistory
func (*ManualTrigger) Initialize ¶ added in v0.20.0
func (t *ManualTrigger) Initialize(session flows.Session, logEvent flows.EventCallback) error
Initialize initializes the session
func (*ManualTrigger) InitializeRun ¶ added in v0.20.0
func (t *ManualTrigger) InitializeRun(run flows.Run, logEvent flows.EventCallback) error
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) TriggeredOn ¶
type MsgBuilder ¶ added in v0.95.0
type MsgBuilder struct {
// contains filtered or unexported fields
}
MsgBuilder is a builder for msg type triggers
func (*MsgBuilder) Build ¶ added in v0.95.0
func (b *MsgBuilder) Build() *MsgTrigger
Build builds the trigger
func (*MsgBuilder) WithConnection ¶ added in v0.126.2
func (b *MsgBuilder) WithConnection(channel *assets.ChannelReference, urn urns.URN) *MsgBuilder
WithConnection sets the channel connection for the trigger
func (*MsgBuilder) WithMatch ¶ added in v0.95.0
func (b *MsgBuilder) WithMatch(match *KeywordMatch) *MsgBuilder
WithMatch sets the keyword match for the trigger
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 received 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) Context ¶ added in v0.33.8
func (t *MsgTrigger) Context(env envs.Environment) map[string]types.XValue
Context for msg triggers additionally exposes the keyword match
func (*MsgTrigger) Environment ¶ added in v0.20.0
func (t *MsgTrigger) Environment() envs.Environment
func (*MsgTrigger) Flow ¶ added in v0.20.0
func (t *MsgTrigger) Flow() *assets.FlowReference
func (*MsgTrigger) History ¶ added in v0.96.0
func (t *MsgTrigger) History() *flows.SessionHistory
func (*MsgTrigger) Initialize ¶ added in v0.20.0
func (t *MsgTrigger) Initialize(session flows.Session, logEvent flows.EventCallback) error
Initialize initializes the session
func (*MsgTrigger) InitializeRun ¶ added in v0.20.0
func (t *MsgTrigger) InitializeRun(run flows.Run, logEvent flows.EventCallback) error
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) TriggeredOn ¶ added in v0.20.0
type OptInBuilder ¶ added in v0.195.0
type OptInBuilder struct {
// contains filtered or unexported fields
}
OptInBuilder is a builder for optin type triggers
func (*OptInBuilder) Build ¶ added in v0.195.0
func (b *OptInBuilder) Build() *OptInTrigger
Build builds the trigger
type OptInEvent ¶ added in v0.195.0
type OptInEvent struct {
// contains filtered or unexported fields
}
OptInEvent describes the specific event on the ticket that triggered the session
type OptInEventType ¶ added in v0.195.0
type OptInEventType string
OptInEventType is the type of event that occurred on the optin
const ( OptInEventTypeStarted OptInEventType = "started" OptInEventTypeStopped OptInEventType = "stopped" )
different optin event types
type OptInTrigger ¶ added in v0.195.0
type OptInTrigger struct {
// contains filtered or unexported fields
}
OptInTrigger is used when a session was triggered by an optin or optout.
{ "type": "optin", "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": "started", "optin": { "uuid": "248be71d-78e9-4d71-a6c4-9981d369e5cb", "name": "Joke Of The Day" } }, "triggered_on": "2000-01-01T00:00:00.000000000-00:00" }
@trigger optin
func (*OptInTrigger) Context ¶ added in v0.195.0
func (t *OptInTrigger) Context(env envs.Environment) map[string]types.XValue
Context for optin triggers includes the optin
func (*OptInTrigger) Environment ¶ added in v0.195.0
func (t *OptInTrigger) Environment() envs.Environment
func (*OptInTrigger) Flow ¶ added in v0.195.0
func (t *OptInTrigger) Flow() *assets.FlowReference
func (*OptInTrigger) History ¶ added in v0.195.0
func (t *OptInTrigger) History() *flows.SessionHistory
func (*OptInTrigger) Initialize ¶ added in v0.195.0
func (t *OptInTrigger) Initialize(session flows.Session, logEvent flows.EventCallback) error
Initialize initializes the session
func (*OptInTrigger) InitializeRun ¶ added in v0.195.0
func (t *OptInTrigger) InitializeRun(run flows.Run, logEvent flows.EventCallback) error
InitializeRun performs additional initialization when we create our first run
func (*OptInTrigger) MarshalJSON ¶ added in v0.195.0
func (t *OptInTrigger) MarshalJSON() ([]byte, error)
MarshalJSON marshals this trigger into JSON
func (*OptInTrigger) TriggeredOn ¶ added in v0.195.0
type ReadFunc ¶ added in v0.59.0
type ReadFunc func(flows.SessionAssets, json.RawMessage, assets.MissingCallback) (flows.Trigger, error)
ReadFunc is a function that can read a trigger from JSON
type TicketBuilder ¶ added in v0.120.0
type TicketBuilder struct {
// contains filtered or unexported fields
}
TicketBuilder is a builder for ticket type triggers
func (*TicketBuilder) Build ¶ added in v0.120.0
func (b *TicketBuilder) Build() *TicketTrigger
Build builds the trigger
type TicketEvent ¶ added in v0.120.0
type TicketEvent struct {
// contains filtered or unexported fields
}
TicketEvent describes the specific event on the ticket that triggered the session
type TicketEventType ¶ added in v0.120.0
type TicketEventType string
TicketEventType is the type of event that occurred on the ticket
const (
TicketEventTypeClosed TicketEventType = "closed"
)
different ticket event types
type TicketTrigger ¶ added in v0.120.0
type TicketTrigger struct {
// contains filtered or unexported fields
}
TicketTrigger is used when a session was triggered by a ticket event
{ "type": "ticket", "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": "closed", "ticket": { "uuid": "58e9b092-fe42-4173-876c-ff45a14a24fe", "ticketer": {"uuid": "19dc6346-9623-4fe4-be80-538d493ecdf5", "name": "Support Tickets"}, "topic": {"uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", "name": "Weather"}, "body": "Where are my shoes?" } }, "triggered_on": "2000-01-01T00:00:00.000000000-00:00" }
@trigger ticket
func (*TicketTrigger) Context ¶ added in v0.120.0
func (t *TicketTrigger) Context(env envs.Environment) map[string]types.XValue
Context for ticket triggers includes the ticket
func (*TicketTrigger) Environment ¶ added in v0.120.0
func (t *TicketTrigger) Environment() envs.Environment
func (*TicketTrigger) Flow ¶ added in v0.120.0
func (t *TicketTrigger) Flow() *assets.FlowReference
func (*TicketTrigger) History ¶ added in v0.120.0
func (t *TicketTrigger) History() *flows.SessionHistory
func (*TicketTrigger) Initialize ¶ added in v0.120.0
func (t *TicketTrigger) Initialize(session flows.Session, logEvent flows.EventCallback) error
Initialize initializes the session
func (*TicketTrigger) InitializeRun ¶ added in v0.120.0
func (t *TicketTrigger) InitializeRun(run flows.Run, logEvent flows.EventCallback) error
InitializeRun performs additional initialization when we create our first run
func (*TicketTrigger) MarshalJSON ¶ added in v0.120.0
func (t *TicketTrigger) MarshalJSON() ([]byte, error)
MarshalJSON marshals this trigger into JSON