Documentation
¶
Index ¶
- Constants
- func EventsToEnvelopes(events []flows.Event) ([]*utils.TypedEnvelope, error)
- func ReadEvent(envelope *utils.TypedEnvelope) (flows.Event, error)
- func ReadEvents(envelopes []*utils.TypedEnvelope) ([]flows.Event, error)
- func RegisterType(name string, initFunc func() flows.Event)
- type BaseEvent
- type BroadcastCreatedEvent
- type BroadcastTranslation
- type ContactChangedEvent
- type ContactChannelChangedEvent
- type ContactFieldChangedEvent
- type ContactGroupsAddedEvent
- type ContactGroupsRemovedEvent
- type ContactLanguageChangedEvent
- type ContactNameChangedEvent
- type ContactTimezoneChangedEvent
- type ContactURNAddedEvent
- type EmailCreatedEvent
- type EnvironmentChangedEvent
- type ErrorEvent
- type FlowTriggeredEvent
- type InputLabelsAddedEvent
- type MsgCreatedEvent
- type MsgReceivedEvent
- type MsgWaitEvent
- type NothingWaitEvent
- type ResthookCalledEvent
- type ResthookSubscriberCall
- type RunExpiredEvent
- type RunResultChangedEvent
- type SessionTriggeredEvent
- type WaitTimedOutEvent
- type WebhookCalledEvent
Constants ¶
const TypeBroadcastCreated string = "broadcast_created"
TypeBroadcastCreated is a constant for outgoing message events
const TypeContactChanged string = "contact_changed"
TypeContactChanged is the type of our set contact event
const TypeContactChannelChanged string = "contact_channel_changed"
TypeContactChannelChanged is the type of our set preferred channel event
const TypeContactFieldChanged string = "contact_field_changed"
TypeContactFieldChanged is the type of our save to contact event
const TypeContactGroupsAdded string = "contact_groups_added"
TypeContactGroupsAdded is the type of our add to group action
const TypeContactGroupsRemoved string = "contact_groups_removed"
TypeContactGroupsRemoved is the type fo our remove from group action
const TypeContactLanguageChanged string = "contact_language_changed"
TypeContactLanguageChanged is the type of our contact language changed event
const TypeContactNameChanged string = "contact_name_changed"
TypeContactNameChanged is the type of our contact name changed event
const TypeContactTimezoneChanged string = "contact_timezone_changed"
TypeContactTimezoneChanged is the type of our contact timezone changed event
const TypeContactURNAdded string = "contact_urn_added"
TypeContactURNAdded is the type of our add URN event
const TypeEmailCreated string = "email_created"
TypeEmailCreated is our type for the email event
const TypeEnvironmentChanged string = "environment_changed"
TypeEnvironmentChanged is the type of our environment changed event
const TypeError string = "error"
TypeError is the type of our error events
const TypeFlowTriggered string = "flow_triggered"
TypeFlowTriggered is the type of our flow triggered event
const TypeInputLabelsAdded string = "input_labels_added"
TypeInputLabelsAdded is the type of our add label action
const TypeMsgCreated string = "msg_created"
TypeMsgCreated is a constant for incoming messages
const TypeMsgReceived string = "msg_received"
TypeMsgReceived is a constant for incoming messages
const TypeMsgWait string = "msg_wait"
TypeMsgWait is the type of our msg wait event
const TypeNothingWait string = "nothing_wait"
TypeNothingWait is the type of our nothing wait event
const TypeResthookCalled string = "resthook_called"
TypeResthookCalled is the type for our resthook events
const TypeRunExpired string = "run_expired"
TypeRunExpired is the type of our flow expired event
const TypeRunResultChanged string = "run_result_changed"
TypeRunResultChanged is the type of our run result event
const TypeSessionTriggered string = "session_triggered"
TypeSessionTriggered is the type of our session triggered event
const TypeWaitTimedOut string = "wait_timed_out"
TypeWaitTimedOut is the type of our wait timed out events
const TypeWebhookCalled string = "webhook_called"
TypeWebhookCalled is the type for our webhook events
Variables ¶
This section is empty.
Functions ¶
func EventsToEnvelopes ¶ added in v0.7.0
func EventsToEnvelopes(events []flows.Event) ([]*utils.TypedEnvelope, error)
EventsToEnvelopes converts the given events to typed envelopes
func ReadEvent ¶ added in v0.11.0
func ReadEvent(envelope *utils.TypedEnvelope) (flows.Event, error)
ReadEvent reads a single event from the given envelope
func ReadEvents ¶ added in v0.4.0
func ReadEvents(envelopes []*utils.TypedEnvelope) ([]flows.Event, error)
ReadEvents reads the events from the given envelopes
func RegisterType ¶ added in v0.11.0
RegisterType registers a new type of router
Types ¶
type BaseEvent ¶
type BaseEvent struct { CreatedOn_ time.Time `json:"created_on" validate:"required"` StepUUID_ flows.StepUUID `json:"step_uuid,omitempty" validate:"omitempty,uuid4"` FromCaller_ bool `json:"-"` }
BaseEvent is the base of all event types
func NewBaseEvent ¶ added in v0.4.0
func NewBaseEvent() BaseEvent
NewBaseEvent creates a new base event
func (*BaseEvent) FromCaller ¶ added in v0.4.0
FromCaller returns whether this event originated from the caller
func (*BaseEvent) SetFromCaller ¶ added in v0.4.0
SetFromCaller sets whether this event originated from the caller
func (*BaseEvent) SetStepUUID ¶ added in v0.11.0
SetStepUUID sets the UUID of the step in the path where this event occured
type BroadcastCreatedEvent ¶ added in v0.5.0
type BroadcastCreatedEvent struct { BaseEvent Translations map[utils.Language]*BroadcastTranslation `json:"translations,min=1" validate:"dive"` BaseLanguage utils.Language `json:"base_language" validate:"required"` URNs []urns.URN `json:"urns,omitempty" validate:"dive,urn"` Contacts []*flows.ContactReference `json:"contacts,omitempty" validate:"dive"` Groups []*assets.GroupReference `json:"groups,omitempty" validate:"dive"` // contains filtered or unexported fields }
BroadcastCreatedEvent events are created for outgoing broadcasts.
{ "type": "broadcast_created", "created_on": "2006-01-02T15:04:05Z", "translations": { "eng": { "text": "hi, what's up", "attachments": [], "quick_replies": ["All good", "Got 99 problems"] }, "spa": { "text": "Que pasa", "attachments": [], "quick_replies": ["Todo bien", "Tengo 99 problemas"] } }, "base_language": "eng", "urns": ["tel:+12065551212"], "contacts": [{"uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a", "name": "Bob"}] }
@event broadcast_created
func NewBroadcastCreatedEvent ¶ added in v0.5.0
func NewBroadcastCreatedEvent(translations map[utils.Language]*BroadcastTranslation, baseLanguage utils.Language, urns []urns.URN, contacts []*flows.ContactReference, groups []*assets.GroupReference) *BroadcastCreatedEvent
NewBroadcastCreatedEvent creates a new outgoing msg event for the given recipients
func (*BroadcastCreatedEvent) AllowedOrigin ¶ added in v0.6.0
func (e *BroadcastCreatedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*BroadcastCreatedEvent) Apply ¶ added in v0.5.0
func (e *BroadcastCreatedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*BroadcastCreatedEvent) Type ¶ added in v0.5.0
func (e *BroadcastCreatedEvent) Type() string
Type returns the type of this event
func (*BroadcastCreatedEvent) Validate ¶ added in v0.6.0
func (e *BroadcastCreatedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs. We assume engine generated events are valid.
type BroadcastTranslation ¶ added in v0.6.1
type BroadcastTranslation struct { Text string `json:"text"` Attachments []flows.Attachment `json:"attachments,omitempty"` QuickReplies []string `json:"quick_replies,omitempty"` }
BroadcastTranslation is the broadcast content in a particular language
type ContactChangedEvent ¶ added in v0.5.0
type ContactChangedEvent struct { BaseEvent Contact json.RawMessage `json:"contact"` // contains filtered or unexported fields }
ContactChangedEvent events are created to set a contact on a session
{ "type": "contact_changed", "created_on": "2006-01-02T15:04:05Z", "contact": { "uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a", "name": "Bob", "urns": ["tel:+11231234567"] } }
@event contact_changed
func (*ContactChangedEvent) AllowedOrigin ¶ added in v0.6.0
func (e *ContactChangedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*ContactChangedEvent) Apply ¶ added in v0.5.0
func (e *ContactChangedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*ContactChangedEvent) Type ¶ added in v0.5.0
func (e *ContactChangedEvent) Type() string
Type returns the type of this event
func (*ContactChangedEvent) Validate ¶ added in v0.6.0
func (e *ContactChangedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type ContactChannelChangedEvent ¶ added in v0.5.0
type ContactChannelChangedEvent struct { BaseEvent Channel *assets.ChannelReference `json:"channel" validate:"required"` // contains filtered or unexported fields }
ContactChannelChangedEvent events are created when a contact's preferred channel is changed.
{ "type": "contact_channel_changed", "created_on": "2006-01-02T15:04:05Z", "channel": {"uuid": "67a3ac69-e5e0-4ef0-8423-eddf71a71472", "name": "Twilio"} }
@event contact_channel_changed
func NewContactChannelChangedEvent ¶ added in v0.5.0
func NewContactChannelChangedEvent(channel *assets.ChannelReference) *ContactChannelChangedEvent
NewContactChannelChangedEvent returns a new preferred channel event
func (*ContactChannelChangedEvent) AllowedOrigin ¶ added in v0.6.0
func (e *ContactChannelChangedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*ContactChannelChangedEvent) Apply ¶ added in v0.5.0
func (e *ContactChannelChangedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*ContactChannelChangedEvent) Type ¶ added in v0.5.0
func (e *ContactChannelChangedEvent) Type() string
Type returns the type of this event
func (*ContactChannelChangedEvent) Validate ¶ added in v0.6.0
func (e *ContactChannelChangedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type ContactFieldChangedEvent ¶ added in v0.5.0
type ContactFieldChangedEvent struct { BaseEvent Field *assets.FieldReference `json:"field" validate:"required"` Value string `json:"value" validate:"required"` // contains filtered or unexported fields }
ContactFieldChangedEvent events are created when a contact field is updated.
{ "type": "contact_field_changed", "created_on": "2006-01-02T15:04:05Z", "field": {"key": "gender", "name": "Gender"}, "value": "Male" }
@event contact_field_changed
func NewContactFieldChangedEvent ¶ added in v0.5.0
func NewContactFieldChangedEvent(field *assets.FieldReference, value string) *ContactFieldChangedEvent
NewContactFieldChangedEvent returns a new save to contact event
func (*ContactFieldChangedEvent) AllowedOrigin ¶ added in v0.6.0
func (e *ContactFieldChangedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*ContactFieldChangedEvent) Apply ¶ added in v0.5.0
func (e *ContactFieldChangedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*ContactFieldChangedEvent) Type ¶ added in v0.5.0
func (e *ContactFieldChangedEvent) Type() string
Type returns the type of this event
func (*ContactFieldChangedEvent) Validate ¶ added in v0.6.0
func (e *ContactFieldChangedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type ContactGroupsAddedEvent ¶ added in v0.5.0
type ContactGroupsAddedEvent struct { BaseEvent Groups []*assets.GroupReference `json:"groups" validate:"required,min=1,dive"` // contains filtered or unexported fields }
ContactGroupsAddedEvent events will be created with the groups a contact was added to.
{ "type": "contact_groups_added", "created_on": "2006-01-02T15:04:05Z", "groups": [{"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "name": "Reporters"}] }
@event contact_groups_added
func NewContactGroupsAddedEvent ¶ added in v0.5.0
func NewContactGroupsAddedEvent(groups []*assets.GroupReference) *ContactGroupsAddedEvent
NewContactGroupsAddedEvent returns a new contact_groups_added event
func (*ContactGroupsAddedEvent) AllowedOrigin ¶ added in v0.6.0
func (e *ContactGroupsAddedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*ContactGroupsAddedEvent) Apply ¶ added in v0.5.0
func (e *ContactGroupsAddedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*ContactGroupsAddedEvent) Type ¶ added in v0.5.0
func (e *ContactGroupsAddedEvent) Type() string
Type returns the type of this event
func (*ContactGroupsAddedEvent) Validate ¶ added in v0.6.0
func (e *ContactGroupsAddedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type ContactGroupsRemovedEvent ¶ added in v0.5.0
type ContactGroupsRemovedEvent struct { BaseEvent Groups []*assets.GroupReference `json:"groups" validate:"required,min=1,dive"` // contains filtered or unexported fields }
ContactGroupsRemovedEvent events are created when a contact has been removed from one or more groups.
{ "type": "contact_groups_removed", "created_on": "2006-01-02T15:04:05Z", "groups": [{"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "name": "Reporters"}] }
@event contact_groups_removed
func NewContactGroupsRemovedEvent ¶ added in v0.5.0
func NewContactGroupsRemovedEvent(groups []*assets.GroupReference) *ContactGroupsRemovedEvent
NewContactGroupsRemovedEvent returns a new remove from group event
func (*ContactGroupsRemovedEvent) AllowedOrigin ¶ added in v0.6.0
func (e *ContactGroupsRemovedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*ContactGroupsRemovedEvent) Apply ¶ added in v0.5.0
func (e *ContactGroupsRemovedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*ContactGroupsRemovedEvent) Type ¶ added in v0.5.0
func (e *ContactGroupsRemovedEvent) Type() string
Type returns the type of this event
func (*ContactGroupsRemovedEvent) Validate ¶ added in v0.6.0
func (e *ContactGroupsRemovedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type ContactLanguageChangedEvent ¶ added in v0.10.0
type ContactLanguageChangedEvent struct { BaseEvent Language string `json:"language"` // contains filtered or unexported fields }
ContactLanguageChangedEvent events are created when a Language of a contact has been changed
{ "type": "contact_language_changed", "created_on": "2006-01-02T15:04:05Z", "language": "eng" }
@event contact_language_changed
func NewContactLanguageChangedEvent ¶ added in v0.10.0
func NewContactLanguageChangedEvent(language string) *ContactLanguageChangedEvent
NewContactLanguageChangedEvent returns a new contact language changed event
func (*ContactLanguageChangedEvent) AllowedOrigin ¶ added in v0.10.0
func (e *ContactLanguageChangedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*ContactLanguageChangedEvent) Apply ¶ added in v0.10.0
func (e *ContactLanguageChangedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*ContactLanguageChangedEvent) Type ¶ added in v0.10.0
func (e *ContactLanguageChangedEvent) Type() string
Type returns the type of this event
func (*ContactLanguageChangedEvent) Validate ¶ added in v0.10.0
func (e *ContactLanguageChangedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type ContactNameChangedEvent ¶ added in v0.10.0
type ContactNameChangedEvent struct { BaseEvent Name string `json:"name"` // contains filtered or unexported fields }
ContactNameChangedEvent events are created when a name of a contact has been changed
{ "type": "contact_name_changed", "created_on": "2006-01-02T15:04:05Z", "name": "Bob Smith" }
@event contact_name_changed
func NewContactNameChangedEvent ¶ added in v0.10.0
func NewContactNameChangedEvent(name string) *ContactNameChangedEvent
NewContactNameChangedEvent returns a new contact name changed event
func (*ContactNameChangedEvent) AllowedOrigin ¶ added in v0.10.0
func (e *ContactNameChangedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*ContactNameChangedEvent) Apply ¶ added in v0.10.0
func (e *ContactNameChangedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*ContactNameChangedEvent) Type ¶ added in v0.10.0
func (e *ContactNameChangedEvent) Type() string
Type returns the type of this event
func (*ContactNameChangedEvent) Validate ¶ added in v0.10.0
func (e *ContactNameChangedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type ContactTimezoneChangedEvent ¶ added in v0.10.0
type ContactTimezoneChangedEvent struct { BaseEvent Timezone string `json:"timezone"` // contains filtered or unexported fields }
ContactTimezoneChangedEvent events are created when a timezone of a contact has been changed
{ "type": "contact_timezone_changed", "created_on": "2006-01-02T15:04:05Z", "timezone": "Africa/Kigali" }
@event contact_timezone_changed
func NewContactTimezoneChangedEvent ¶ added in v0.10.0
func NewContactTimezoneChangedEvent(timezone string) *ContactTimezoneChangedEvent
NewContactTimezoneChangedEvent returns a new contact timezone changed event
func (*ContactTimezoneChangedEvent) AllowedOrigin ¶ added in v0.10.0
func (e *ContactTimezoneChangedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*ContactTimezoneChangedEvent) Apply ¶ added in v0.10.0
func (e *ContactTimezoneChangedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*ContactTimezoneChangedEvent) Type ¶ added in v0.10.0
func (e *ContactTimezoneChangedEvent) Type() string
Type returns the type of this event
func (*ContactTimezoneChangedEvent) Validate ¶ added in v0.10.0
func (e *ContactTimezoneChangedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type ContactURNAddedEvent ¶ added in v0.5.0
type ContactURNAddedEvent struct { BaseEvent URN urns.URN `json:"urn" validate:"urn"` // contains filtered or unexported fields }
ContactURNAddedEvent events will be created with the URN that should be added to the current contact.
{ "type": "contact_urn_added", "created_on": "2006-01-02T15:04:05Z", "urn": "tel:+12345678900" }
@event contact_urn_added
func NewURNAddedEvent ¶ added in v0.5.0
func NewURNAddedEvent(urn urns.URN) *ContactURNAddedEvent
NewURNAddedEvent returns a new add URN event
func (*ContactURNAddedEvent) AllowedOrigin ¶ added in v0.6.0
func (e *ContactURNAddedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*ContactURNAddedEvent) Apply ¶ added in v0.5.0
func (e *ContactURNAddedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*ContactURNAddedEvent) Type ¶ added in v0.5.0
func (e *ContactURNAddedEvent) Type() string
Type returns the type of this event
func (*ContactURNAddedEvent) Validate ¶ added in v0.6.0
func (e *ContactURNAddedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type EmailCreatedEvent ¶ added in v0.5.0
type EmailCreatedEvent struct { BaseEvent Addresses []string `json:"addresses" validate:"required,min=1"` Subject string `json:"subject" validate:"required"` Body string `json:"body"` // contains filtered or unexported fields }
EmailCreatedEvent events are created for each recipient which should receive an email.
{ "type": "email_created", "created_on": "2006-01-02T15:04:05Z", "addresses": ["foo@bar.com"], "subject": "Your activation token", "body": "Your activation token is AAFFKKEE" }
@event email_created
func NewEmailCreatedEvent ¶ added in v0.5.0
func NewEmailCreatedEvent(addresses []string, subject string, body string) *EmailCreatedEvent
NewEmailCreatedEvent returns a new email event with the passed in subject, body and emails
func (*EmailCreatedEvent) AllowedOrigin ¶ added in v0.6.0
func (e *EmailCreatedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*EmailCreatedEvent) Apply ¶ added in v0.5.0
func (e *EmailCreatedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*EmailCreatedEvent) Type ¶ added in v0.5.0
func (e *EmailCreatedEvent) Type() string
Type returns the type of this event
func (*EmailCreatedEvent) Validate ¶ added in v0.6.0
func (e *EmailCreatedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type EnvironmentChangedEvent ¶ added in v0.5.0
type EnvironmentChangedEvent struct { BaseEvent Environment json.RawMessage `json:"environment"` // contains filtered or unexported fields }
EnvironmentChangedEvent events are created to set the environment on a session
{ "type": "environment_changed", "created_on": "2006-01-02T15:04:05Z", "environment": { "date_format": "YYYY-MM-DD", "time_format": "hh:mm", "timezone": "Africa/Kigali", "languages": ["eng", "fra"] } }
@event environment_changed
func (*EnvironmentChangedEvent) AllowedOrigin ¶ added in v0.6.0
func (e *EnvironmentChangedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*EnvironmentChangedEvent) Apply ¶ added in v0.5.0
func (e *EnvironmentChangedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*EnvironmentChangedEvent) Type ¶ added in v0.5.0
func (e *EnvironmentChangedEvent) Type() string
Type returns the type of this event
func (*EnvironmentChangedEvent) Validate ¶ added in v0.6.0
func (e *EnvironmentChangedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type ErrorEvent ¶
type ErrorEvent struct { BaseEvent Text string `json:"text" validate:"required"` Fatal bool `json:"fatal"` // contains filtered or unexported fields }
ErrorEvent events will be created whenever an error is encountered during flow execution. This can vary from template evaluation errors to invalid actions.
{ "type": "error", "created_on": "2006-01-02T15:04:05Z", "text": "invalid date format: '12th of October'" }
@event error
func NewErrorEvent ¶
func NewErrorEvent(err error) *ErrorEvent
NewErrorEvent returns a new error event for the passed in error
func NewFatalErrorEvent ¶ added in v0.4.0
func NewFatalErrorEvent(err error) *ErrorEvent
NewFatalErrorEvent returns a new fatal error event for the passed in error
func (*ErrorEvent) AllowedOrigin ¶ added in v0.6.0
func (e *ErrorEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*ErrorEvent) Apply ¶ added in v0.4.0
func (e *ErrorEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*ErrorEvent) Validate ¶ added in v0.6.0
func (e *ErrorEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type FlowTriggeredEvent ¶ added in v0.4.0
type FlowTriggeredEvent struct { BaseEvent Flow *assets.FlowReference `json:"flow" validate:"required"` ParentRunUUID flows.RunUUID `json:"parent_run_uuid" validate:"omitempty,uuid4"` // contains filtered or unexported fields }
FlowTriggeredEvent events are created when an action wants to start a subflow
{ "type": "flow_triggered", "created_on": "2006-01-02T15:04:05Z", "flow": {"uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a", "name": "Registration"}, "parent_run_uuid": "95eb96df-461b-4668-b168-727f8ceb13dd" }
@event flow_triggered
func NewFlowTriggeredEvent ¶ added in v0.4.0
func NewFlowTriggeredEvent(flow *assets.FlowReference, parentRunUUID flows.RunUUID) *FlowTriggeredEvent
NewFlowTriggeredEvent returns a new flow triggered event for the passed in flow and parent run
func (*FlowTriggeredEvent) AllowedOrigin ¶ added in v0.6.0
func (e *FlowTriggeredEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*FlowTriggeredEvent) Apply ¶ added in v0.4.0
func (e *FlowTriggeredEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*FlowTriggeredEvent) Type ¶ added in v0.4.0
func (e *FlowTriggeredEvent) Type() string
Type returns the type of this event
func (*FlowTriggeredEvent) Validate ¶ added in v0.6.0
func (e *FlowTriggeredEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs. We assume engine generated events are valid.
type InputLabelsAddedEvent ¶ added in v0.5.0
type InputLabelsAddedEvent struct { BaseEvent InputUUID flows.InputUUID `json:"input_uuid" validate:"required,uuid4"` Labels []*assets.LabelReference `json:"labels" validate:"required,min=1,dive"` // contains filtered or unexported fields }
InputLabelsAddedEvent events will be created with the labels that were applied to the given input.
{ "type": "input_labels_added", "created_on": "2006-01-02T15:04:05Z", "input_uuid": "4aef4050-1895-4c80-999a-70368317a4f5", "labels": [{"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "name": "Spam"}] }
@event input_labels_added
func NewInputLabelsAddedEvent ¶ added in v0.5.0
func NewInputLabelsAddedEvent(inputUUID flows.InputUUID, labels []*assets.LabelReference) *InputLabelsAddedEvent
NewInputLabelsAddedEvent returns a new add to group event
func (*InputLabelsAddedEvent) AllowedOrigin ¶ added in v0.6.0
func (e *InputLabelsAddedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*InputLabelsAddedEvent) Apply ¶ added in v0.5.0
func (e *InputLabelsAddedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*InputLabelsAddedEvent) Type ¶ added in v0.5.0
func (e *InputLabelsAddedEvent) Type() string
Type returns the type of this event
func (*InputLabelsAddedEvent) Validate ¶ added in v0.6.0
func (e *InputLabelsAddedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type MsgCreatedEvent ¶ added in v0.6.0
type MsgCreatedEvent struct { BaseEvent Msg flows.MsgOut `json:"msg" validate:"required,dive"` // contains filtered or unexported fields }
MsgCreatedEvent events are used for replies to the session contact.
{ "type": "msg_created", "created_on": "2006-01-02T15:04:05Z", "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"] } }
@event msg_created
func NewMsgCreatedEvent ¶ added in v0.5.0
func NewMsgCreatedEvent(msg *flows.MsgOut) *MsgCreatedEvent
NewMsgCreatedEvent creates a new outgoing msg event to a single contact
func (*MsgCreatedEvent) AllowedOrigin ¶ added in v0.6.0
func (e *MsgCreatedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*MsgCreatedEvent) Apply ¶ added in v0.6.0
func (e *MsgCreatedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*MsgCreatedEvent) Type ¶ added in v0.6.0
func (e *MsgCreatedEvent) Type() string
Type returns the type of this event
func (*MsgCreatedEvent) Validate ¶ added in v0.6.0
func (e *MsgCreatedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs. We assume engine generated events are valid.
type MsgReceivedEvent ¶
type MsgReceivedEvent struct { BaseEvent Msg flows.MsgIn `json:"msg" validate:"required,dive"` // contains filtered or unexported fields }
MsgReceivedEvent events are used for starting flows or resuming flows which are waiting for a message. They represent an incoming message for a contact.
{ "type": "msg_received", "created_on": "2006-01-02T15:04:05Z", "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"] } }
@event msg_received
func NewMsgReceivedEvent ¶
func NewMsgReceivedEvent(msg *flows.MsgIn) *MsgReceivedEvent
NewMsgReceivedEvent creates a new incoming msg event for the passed in channel, URN and text
func (*MsgReceivedEvent) AllowedOrigin ¶ added in v0.6.0
func (e *MsgReceivedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*MsgReceivedEvent) Apply ¶ added in v0.4.0
func (e *MsgReceivedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*MsgReceivedEvent) Type ¶
func (e *MsgReceivedEvent) Type() string
Type returns the type of this event
func (*MsgReceivedEvent) Validate ¶ added in v0.6.0
func (e *MsgReceivedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type MsgWaitEvent ¶
type MsgWaitEvent struct { BaseEvent TimeoutOn *time.Time `json:"timeout_on,omitempty"` // contains filtered or unexported fields }
MsgWaitEvent events are created when a flow pauses waiting for a response from a contact. If a timeout is set, then the caller should resume the flow after the number of seconds in the timeout to resume it.
{ "type": "msg_wait", "created_on": "2006-01-02T15:04:05Z", "timeout": 300 }
@event msg_wait
func NewMsgWait ¶
func NewMsgWait(timeoutOn *time.Time) *MsgWaitEvent
NewMsgWait returns a new msg wait with the passed in timeout
func (*MsgWaitEvent) AllowedOrigin ¶ added in v0.6.0
func (e *MsgWaitEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*MsgWaitEvent) Apply ¶ added in v0.4.0
func (e *MsgWaitEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*MsgWaitEvent) Type ¶
func (e *MsgWaitEvent) Type() string
Type returns the type of this event
func (*MsgWaitEvent) Validate ¶ added in v0.6.0
func (e *MsgWaitEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs. We assume engine generated events are valid.
type NothingWaitEvent ¶ added in v0.4.0
type NothingWaitEvent struct { BaseEvent // contains filtered or unexported fields }
NothingWaitEvent events are created when a flow requests to hand back control to the caller but isn't waiting for anything from the caller.
{ "type": "nothing_wait", "created_on": "2006-01-02T15:04:05.234532Z" }
@event nothing_wait
func NewNothingWait ¶ added in v0.4.0
func NewNothingWait() *NothingWaitEvent
NewNothingWait returns a new nothing wait
func (*NothingWaitEvent) AllowedOrigin ¶ added in v0.6.0
func (e *NothingWaitEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*NothingWaitEvent) Apply ¶ added in v0.4.0
func (e *NothingWaitEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*NothingWaitEvent) Type ¶ added in v0.4.0
func (e *NothingWaitEvent) Type() string
Type returns the type of this event
func (*NothingWaitEvent) Validate ¶ added in v0.6.0
func (e *NothingWaitEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs. We assume engine generated events are valid.
type ResthookCalledEvent ¶ added in v0.10.20
type ResthookCalledEvent struct { BaseEvent Resthook string `json:"resthook" validate:"required"` Payload string `json:"payload"` Calls []*ResthookSubscriberCall `json:"calls" validate:"omitempty,dive"` // contains filtered or unexported fields }
ResthookCalledEvent events are created when a resthook is called. The event contains the status and status code of each call to the resthook's subscribers, as well as the payload sent to each subscriber. Applying this event updates @run.webhook in the context to the results of the last subscriber call. However if one of the subscriber calls fails, then it is used to update @run.webhook instead.
{ "type": "resthook_called", "created_on": "2006-01-02T15:04:05Z", "resthook": "new-registration", "payload": "{...}", "calls": [ { "url": "http://localhost:49998/?cmd=success", "status": "success", "status_code": 200, "response": "{\"errors\":[]}" },{ "url": "https://api.ipify.org?format=json", "status": "success", "status_code": 410, "response": "{\"errors\":[\"Unsubscribe\"]}" } ] }
@event resthook_called
func NewResthookCalledEvent ¶ added in v0.10.20
func NewResthookCalledEvent(resthook string, payload string, calls []*ResthookSubscriberCall) *ResthookCalledEvent
NewResthookCalledEvent returns a new resthook called event
func (*ResthookCalledEvent) AllowedOrigin ¶ added in v0.10.20
func (e *ResthookCalledEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*ResthookCalledEvent) Apply ¶ added in v0.10.20
func (e *ResthookCalledEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*ResthookCalledEvent) Type ¶ added in v0.10.20
func (e *ResthookCalledEvent) Type() string
Type returns the type of this event
func (*ResthookCalledEvent) Validate ¶ added in v0.10.20
func (e *ResthookCalledEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs. We assume engine generated events are valid.
type ResthookSubscriberCall ¶ added in v0.10.20
type ResthookSubscriberCall struct { URL string `json:"url" validate:"required"` Status flows.WebhookStatus `json:"status" validate:"required"` StatusCode int `json:"status_code" validate:"required"` Response string `json:"response"` }
ResthookSubscriberCall is call to a single subsccriber of a resthook
func NewResthookSubscriberCall ¶ added in v0.10.20
func NewResthookSubscriberCall(webhook *flows.WebhookCall) *ResthookSubscriberCall
NewResthookSubscriberCall creates a new subscriber call from the given webhook call
type RunExpiredEvent ¶ added in v0.4.0
type RunExpiredEvent struct { BaseEvent RunUUID flows.RunUUID `json:"run_uuid" validate:"required,uuid4"` // contains filtered or unexported fields }
RunExpiredEvent events are sent by the caller to notify the engine that a run has expired
{ "type": "run_expired", "created_on": "2006-01-02T15:04:05Z", "run_uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a" }
@event run_expired
func (*RunExpiredEvent) AllowedOrigin ¶ added in v0.6.0
func (e *RunExpiredEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*RunExpiredEvent) Apply ¶ added in v0.4.0
func (e *RunExpiredEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*RunExpiredEvent) Type ¶ added in v0.4.0
func (e *RunExpiredEvent) Type() string
Type returns the type of this event
func (*RunExpiredEvent) Validate ¶ added in v0.6.0
func (e *RunExpiredEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type RunResultChangedEvent ¶ added in v0.5.0
type RunResultChangedEvent struct { BaseEvent Name string `json:"name" validate:"required"` Value string `json:"value"` Category string `json:"category"` CategoryLocalized string `json:"category_localized,omitempty"` NodeUUID flows.NodeUUID `json:"node_uuid" validate:"required,uuid4"` Input *string `json:"input,omitempty"` // contains filtered or unexported fields }
RunResultChangedEvent events are created when a result is saved. They contain not only the name, value and category of the result, but also the UUID of the node where the result was generated.
{ "type": "run_result_changed", "created_on": "2006-01-02T15:04:05Z", "name": "Gender", "value": "m", "category": "Male", "category_localized": "Homme", "node_uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "input": "M" }
@event run_result_changed
func NewRunResultChangedEvent ¶ added in v0.5.0
func NewRunResultChangedEvent(name string, value string, categoryName string, categoryLocalized string, node flows.NodeUUID, input *string) *RunResultChangedEvent
NewRunResultChangedEvent returns a new save result event for the passed in values
func (*RunResultChangedEvent) AllowedOrigin ¶ added in v0.6.0
func (e *RunResultChangedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*RunResultChangedEvent) Apply ¶ added in v0.5.0
func (e *RunResultChangedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*RunResultChangedEvent) Type ¶ added in v0.5.0
func (e *RunResultChangedEvent) Type() string
Type returns the type of this event
func (*RunResultChangedEvent) Validate ¶ added in v0.6.0
func (e *RunResultChangedEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type SessionTriggeredEvent ¶ added in v0.4.0
type SessionTriggeredEvent struct { BaseEvent Flow *assets.FlowReference `json:"flow" validate:"required"` URNs []urns.URN `json:"urns,omitempty" validate:"dive,urn"` Contacts []*flows.ContactReference `json:"contacts,omitempty" validate:"dive"` Groups []*assets.GroupReference `json:"groups,omitempty" validate:"dive"` CreateContact bool `json:"create_contact,omitempty"` Run json.RawMessage `json:"run"` // contains filtered or unexported fields }
SessionTriggeredEvent events are created when an action wants to start a subflow
{ "type": "session_triggered", "created_on": "2006-01-02T15:04:05Z", "flow": {"uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a", "name": "Registration"}, "groups": [ {"uuid": "8f8e2cae-3c8d-4dce-9c4b-19514437e427", "name": "New contacts"} ], "run": { "uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "flow": {"uuid": "93c554a1-b90d-4892-b029-a2a87dec9b87", "name": "Other Flow"}, "contact": { "uuid": "c59b0033-e748-4240-9d4c-e85eb6800151", "name": "Bob", "fields": {"state": {"value": "Azuay", "created_on": "2000-01-01T00:00:00.000000000-00:00"}} }, "results": { "age": { "result_name": "Age", "value": "33", "node": "cd2be8c4-59bc-453c-8777-dec9a80043b8", "created_on": "2000-01-01T00:00:00.000000000-00:00" } } } }
@event session_triggered
func NewSessionTriggeredEvent ¶ added in v0.4.0
func NewSessionTriggeredEvent(flow *assets.FlowReference, urns []urns.URN, contacts []*flows.ContactReference, groups []*assets.GroupReference, createContact bool, runSnapshot json.RawMessage) *SessionTriggeredEvent
NewSessionTriggeredEvent returns a new session triggered event
func (*SessionTriggeredEvent) AllowedOrigin ¶ added in v0.6.0
func (e *SessionTriggeredEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*SessionTriggeredEvent) Apply ¶ added in v0.4.0
func (e *SessionTriggeredEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*SessionTriggeredEvent) Type ¶ added in v0.4.0
func (e *SessionTriggeredEvent) Type() string
Type returns the type of this event
func (*SessionTriggeredEvent) Validate ¶ added in v0.6.0
func (e *SessionTriggeredEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs. We assume engine generated events are valid.
type WaitTimedOutEvent ¶ added in v0.9.10
type WaitTimedOutEvent struct { BaseEvent // contains filtered or unexported fields }
WaitTimedOutEvent events are sent by the caller when a wait has timed out - i.e. they are sent instead of the item that the wait was waiting for
{ "type": "wait_timed_out", "created_on": "2006-01-02T15:04:05Z" }
@event wait_timed_out
func NewWaitTimedOutEvent ¶ added in v0.9.10
func NewWaitTimedOutEvent() *WaitTimedOutEvent
NewWaitTimedOutEvent creates a new wait timed out event
func (*WaitTimedOutEvent) AllowedOrigin ¶ added in v0.9.10
func (e *WaitTimedOutEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*WaitTimedOutEvent) Apply ¶ added in v0.9.10
func (e *WaitTimedOutEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*WaitTimedOutEvent) Type ¶ added in v0.9.10
func (e *WaitTimedOutEvent) Type() string
Type returns the type of this event
func (*WaitTimedOutEvent) Validate ¶ added in v0.9.10
func (e *WaitTimedOutEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs
type WebhookCalledEvent ¶
type WebhookCalledEvent struct { BaseEvent URL string `json:"url" validate:"required"` Status flows.WebhookStatus `json:"status" validate:"required"` StatusCode int `json:"status_code"` Request string `json:"request" validate:"required"` Response string `json:"response"` // contains filtered or unexported fields }
WebhookCalledEvent events are created when a webhook is called. The event contains the status and status code of the response, as well as a full dump of the request and response. Applying this event updates @run.webhook in the context.
{ "type": "webhook_called", "created_on": "2006-01-02T15:04:05Z", "url": "https://api.ipify.org?format=json", "status": "success", "status_code": 200, "request": "GET https://api.ipify.org?format=json", "response": "HTTP/1.1 200 OK {\"ip\":\"190.154.48.130\"}" }
@event webhook_called
func NewWebhookCalledEvent ¶ added in v0.4.0
func NewWebhookCalledEvent(url string, status flows.WebhookStatus, statusCode int, request string, response string) *WebhookCalledEvent
NewWebhookCalledEvent returns a new webhook called event
func (*WebhookCalledEvent) AllowedOrigin ¶ added in v0.6.0
func (e *WebhookCalledEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*WebhookCalledEvent) Apply ¶ added in v0.4.0
func (e *WebhookCalledEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*WebhookCalledEvent) Type ¶
func (e *WebhookCalledEvent) Type() string
Type returns the type of this event
func (*WebhookCalledEvent) Validate ¶ added in v0.6.0
func (e *WebhookCalledEvent) Validate(assets flows.SessionAssets) error
Validate validates our event is valid and has all the assets it needs. We assume engine generated events are valid.
Source Files
¶
- base.go
- broadcast_created.go
- contact_changed.go
- contact_channel_changed.go
- contact_field_changed.go
- contact_groups_added.go
- contact_groups_removed.go
- contact_language_changed.go
- contact_name_changed.go
- contact_timezone_changed.go
- contact_urn_added.go
- email_created.go
- environment_changed.go
- error.go
- flow_triggered.go
- input_labels_added.go
- msg_created.go
- msg_received.go
- msg_wait.go
- nothing_wait.go
- resthook_called.go
- run_expired.go
- run_result_changed.go
- session_triggered.go
- wait_timed_out.go
- webhook_called.go