triggers

package
v0.94.3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: AGPL-3.0 Imports: 13 Imported by: 13

Documentation

Index

Constants

View Source
const TypeCampaign string = "campaign"

TypeCampaign is the type for sessions triggered by campaign events

View Source
const TypeChannel string = "channel"

TypeChannel is the type for sessions triggered by channel events

View Source
const TypeFlowAction string = "flow_action"

TypeFlowAction is a constant for sessions triggered by flow actions in other sessions

View Source
const TypeManual string = "manual"

TypeManual is the type for manually triggered sessions

View Source
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

func EnsureDynamicGroups(session flows.Session, logEvent flows.EventCallback)

EnsureDynamicGroups ensures that our session contact is in the correct dynamic groups as as far as the engine is concerned

func NewManual added in v0.48.0

func NewManual(env envs.Environment, flow *assets.FlowReference, contact *flows.Contact, batch bool, params *types.XObject) flows.Trigger

NewManual creates a new manual trigger

func NewManualVoice added in v0.48.0

func NewManualVoice(env envs.Environment, flow *assets.FlowReference, contact *flows.Contact, connection *flows.Connection, batch bool, params *types.XObject) flows.Trigger

NewManualVoice creates a new manual trigger with a channel connection for voice

func NewMsg added in v0.48.0

func NewMsg(env envs.Environment, flow *assets.FlowReference, contact *flows.Contact, msg *flows.MsgIn, match *KeywordMatch) flows.Trigger

NewMsg creates a new message trigger

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

func RegisteredTypes() map[string]ReadFunc

RegisteredTypes gets the registered types of trigger

Types

type CampaignEvent added in v0.12.2

type CampaignEvent struct {
	UUID     string             `json:"uuid" validate:"required,uuid4"`
	Campaign *CampaignReference `json:"campaign" validate:"required,dive"`
}

CampaignEvent describes the specific event in the campaign that triggered the session

func NewCampaignEvent added in v0.24.0

func NewCampaignEvent(uuid string, campaign *CampaignReference) *CampaignEvent

NewCampaignEvent creates a new campaign event

type CampaignReference added in v0.24.0

type CampaignReference struct {
	UUID string `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, name string) *CampaignReference

NewCampaignReference creates a new campaign reference

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 NewCampaign added in v0.48.0

func NewCampaign(env envs.Environment, flow *assets.FlowReference, contact *flows.Contact, event *CampaignEvent) *CampaignTrigger

NewCampaign creates a new campaign trigger with the passed in values

func (*CampaignTrigger) Batch added in v0.87.0

func (t *CampaignTrigger) Batch() bool

func (*CampaignTrigger) Connection added in v0.25.0

func (t *CampaignTrigger) Connection() *flows.Connection

func (*CampaignTrigger) Contact added in v0.12.2

func (t *CampaignTrigger) Contact() *flows.Contact

func (*CampaignTrigger) Context added in v0.33.8

func (t *CampaignTrigger) 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:any -> the keyword match if this is a keyword trigger

@context trigger

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) 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.FlowRun, 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) Params added in v0.12.2

func (t *CampaignTrigger) Params() *types.XObject

func (*CampaignTrigger) TriggeredOn added in v0.12.2

func (t *CampaignTrigger) TriggeredOn() time.Time

func (*CampaignTrigger) Type added in v0.12.2

func (t *CampaignTrigger) Type() string

Type returns the type of this trigger

type ChannelEvent added in v0.22.0

type ChannelEvent struct {
	Type    ChannelEventType         `json:"type" validate:"required"`
	Channel *assets.ChannelReference `json:"channel" validate:"required,dive"`
}

ChannelEvent describes the specific event on the channel that triggered the session

func NewChannelEvent added in v0.24.0

func NewChannelEvent(typeName ChannelEventType, channel *assets.ChannelReference) *ChannelEvent

NewChannelEvent creates a new channel event

type ChannelEventType added in v0.24.0

type ChannelEventType string

ChannelEventType is the type of event that occurred on the channel

const (
	ChannelEventTypeNewConversation ChannelEventType = "new_conversation"
	ChannelEventTypeIncomingCall    ChannelEventType = "incoming_call"
)

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 NewChannel added in v0.48.0

func NewChannel(env envs.Environment, flow *assets.FlowReference, contact *flows.Contact, event *ChannelEvent, params *types.XObject) *ChannelTrigger

NewChannel creates a new channel trigger with the passed in values

func NewIncomingCall added in v0.48.0

func NewIncomingCall(env envs.Environment, flow *assets.FlowReference, contact *flows.Contact, urn urns.URN, channel *assets.ChannelReference) *ChannelTrigger

NewIncomingCall creates a new channel trigger with the passed in values

func (*ChannelTrigger) Batch added in v0.87.0

func (t *ChannelTrigger) Batch() bool

func (*ChannelTrigger) Connection added in v0.25.0

func (t *ChannelTrigger) Connection() *flows.Connection

func (*ChannelTrigger) Contact added in v0.22.0

func (t *ChannelTrigger) Contact() *flows.Contact

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:any -> the keyword match if this is a keyword 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) 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.FlowRun, 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) Params added in v0.22.0

func (t *ChannelTrigger) Params() *types.XObject

func (*ChannelTrigger) TriggeredOn added in v0.22.0

func (t *ChannelTrigger) TriggeredOn() time.Time

func (*ChannelTrigger) Type added in v0.22.0

func (t *ChannelTrigger) Type() string

Type returns the type of this 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"},
  "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 NewFlowAction added in v0.48.0

func NewFlowAction(env envs.Environment, flow *assets.FlowReference, contact *flows.Contact, runSummary json.RawMessage, batch bool) (*FlowActionTrigger, error)

NewFlowAction creates a new flow action trigger with the passed in values

func NewFlowActionVoice added in v0.48.0

func NewFlowActionVoice(env envs.Environment, flow *assets.FlowReference, contact *flows.Contact, connection *flows.Connection, runSummary json.RawMessage, batch bool) (*FlowActionTrigger, error)

NewFlowActionVoice creates a new flow action trigger with the passed in values

func (*FlowActionTrigger) Batch added in v0.87.0

func (t *FlowActionTrigger) Batch() bool

func (*FlowActionTrigger) Connection added in v0.25.0

func (t *FlowActionTrigger) Connection() *flows.Connection

func (*FlowActionTrigger) Contact added in v0.5.0

func (t *FlowActionTrigger) Contact() *flows.Contact

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:any -> the keyword match if this is a keyword 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) 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.FlowRun, 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) Params added in v0.5.0

func (t *FlowActionTrigger) Params() *types.XObject

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

func (t *FlowActionTrigger) TriggeredOn() time.Time

func (*FlowActionTrigger) Type

func (t *FlowActionTrigger) Type() string

Type returns the type of this trigger

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 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) Batch added in v0.87.0

func (t *ManualTrigger) Batch() bool

func (*ManualTrigger) Connection added in v0.25.0

func (t *ManualTrigger) Connection() *flows.Connection

func (*ManualTrigger) Contact added in v0.5.0

func (t *ManualTrigger) Contact() *flows.Contact

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) 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.FlowRun, 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) Params added in v0.5.0

func (t *ManualTrigger) Params() *types.XObject

func (*ManualTrigger) TriggeredOn

func (t *ManualTrigger) TriggeredOn() time.Time

func (*ManualTrigger) Type

func (t *ManualTrigger) Type() string

Type returns the type of this 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) Batch added in v0.87.0

func (t *MsgTrigger) Batch() bool

func (*MsgTrigger) Connection added in v0.25.0

func (t *MsgTrigger) Connection() *flows.Connection

func (*MsgTrigger) Contact added in v0.20.0

func (t *MsgTrigger) Contact() *flows.Contact

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) 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.FlowRun, 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) Params added in v0.20.0

func (t *MsgTrigger) Params() *types.XObject

func (*MsgTrigger) TriggeredOn added in v0.20.0

func (t *MsgTrigger) TriggeredOn() time.Time

func (*MsgTrigger) Type added in v0.20.0

func (t *MsgTrigger) Type() string

Type returns the type of this trigger

type ReadFunc added in v0.59.0

ReadFunc is a function that can read a trigger from JSON

Jump to

Keyboard shortcuts

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