Documentation
¶
Index ¶
- Constants
- func EventFromEnvelope(envelope *utils.TypedEnvelope) (flows.Event, error)
- func ReadEvents(envelopes []*utils.TypedEnvelope) ([]flows.Event, error)
- type BaseEvent
- type BroadcastCreatedEvent
- type BroadcastTranslation
- type ContactChangedEvent
- type ContactChannelChangedEvent
- type ContactFieldChangedEvent
- type ContactGroupsAddedEvent
- type ContactGroupsRemovedEvent
- type ContactPropertyChangedEvent
- type ContactURNAddedEvent
- type EmailCreatedEvent
- type EnvironmentChangedEvent
- type ErrorEvent
- type FlowTriggeredEvent
- type InputLabelsAddedEvent
- type MsgCreatedEvent
- type MsgReceivedEvent
- type MsgWaitEvent
- type NothingWaitEvent
- type RunExpiredEvent
- type RunResultChangedEvent
- type SessionTriggeredEvent
- 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 TypeContactPropertyChanged string = "contact_property_changed"
TypeContactPropertyChanged is the type of our update contact 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 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 TypeWebhookCalled string = "webhook_called"
TypeWebhookCalled is the type for our webhook events
Variables ¶
This section is empty.
Functions ¶
func EventFromEnvelope ¶
func EventFromEnvelope(envelope *utils.TypedEnvelope) (flows.Event, error)
EventFromEnvelope 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
Types ¶
type BaseEvent ¶
type BaseEvent struct { CreatedOn_ time.Time `json:"created_on" validate:"required"` FromCaller_ bool `json:"-"` }
func NewBaseEvent ¶ added in v0.4.0
func NewBaseEvent() BaseEvent
func (*BaseEvent) FromCaller ¶ added in v0.4.0
func (*BaseEvent) SetCreatedOn ¶
func (*BaseEvent) SetFromCaller ¶ added in v0.4.0
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 []*flows.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 []*flows.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 *flows.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 *flows.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 *flows.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", "label": "Gender"}, "value": "Male" }
```
@event contact_field_changed
func NewContactFieldChangedEvent ¶ added in v0.5.0
func NewContactFieldChangedEvent(field *flows.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 []*flows.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 []*flows.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 []*flows.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 []*flows.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 ContactPropertyChangedEvent ¶ added in v0.5.0
type ContactPropertyChangedEvent struct { BaseEvent Property string `json:"property" validate:"required,eq=name|eq=language"` Value string `json:"value"` // contains filtered or unexported fields }
ContactPropertyChangedEvent events are created when a property of a contact has been changed
```
{ "type": "contact_property_changed", "created_on": "2006-01-02T15:04:05Z", "property": "language", "value": "eng" }
```
@event contact_property_changed
func NewContactPropertyChangedEvent ¶ added in v0.5.0
func NewContactPropertyChangedEvent(property string, value string) *ContactPropertyChangedEvent
NewContactPropertyChangedEvent returns a new contact property changed event
func (*ContactPropertyChangedEvent) AllowedOrigin ¶ added in v0.6.0
func (e *ContactPropertyChangedEvent) AllowedOrigin() flows.EventOrigin
AllowedOrigin determines where this event type can originate
func (*ContactPropertyChangedEvent) Apply ¶ added in v0.5.0
func (e *ContactPropertyChangedEvent) Apply(run flows.FlowRun) error
Apply applies this event to the given run
func (*ContactPropertyChangedEvent) Type ¶ added in v0.5.0
func (e *ContactPropertyChangedEvent) Type() string
Type returns the type of this event
func (*ContactPropertyChangedEvent) Validate ¶ added in v0.6.0
func (e *ContactPropertyChangedEvent) 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
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 *flows.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 *flows.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 []*flows.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 []*flows.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 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 *flows.FlowReference `json:"flow" validate:"required"` URNs []urns.URN `json:"urns,omitempty" validate:"dive,urn"` Contacts []*flows.ContactReference `json:"contacts,omitempty" validate:"dive"` Groups []*flows.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", "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 *flows.FlowReference, urns []urns.URN, contacts []*flows.ContactReference, groups []*flows.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 WebhookCalledEvent ¶
type WebhookCalledEvent struct { BaseEvent URL string `json:"url" validate:"required"` Status utils.RequestResponseStatus `json:"status" validate:"required"` StatusCode int `json:"status_code" validate:"required"` 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.
```
{ "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 utils.RequestResponseStatus, 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_property_changed.go
- contact_urn_added.go
- email_created.go
- envelope.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
- run_expired.go
- run_result_changed.go
- session_triggered.go
- webhook_called.go