events

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2018 License: AGPL-3.0 Imports: 8 Imported by: 16

Documentation

Index

Constants

View Source
const TypeBroadcastCreated string = "broadcast_created"

TypeBroadcastCreated is a constant for outgoing message events

View Source
const TypeContactChanged string = "contact_changed"

TypeContactChanged is the type of our set contact event

View Source
const TypeContactChannelChanged string = "contact_channel_changed"

TypeContactChannelChanged is the type of our set preferred channel event

View Source
const TypeContactFieldChanged string = "contact_field_changed"

TypeContactFieldChanged is the type of our save to contact event

View Source
const TypeContactGroupsChanged string = "contact_groups_changed"

TypeContactGroupsChanged is the type of our groups changed event

View Source
const TypeContactLanguageChanged string = "contact_language_changed"

TypeContactLanguageChanged is the type of our contact language changed event

View Source
const TypeContactNameChanged string = "contact_name_changed"

TypeContactNameChanged is the type of our contact name changed event

View Source
const TypeContactTimezoneChanged string = "contact_timezone_changed"

TypeContactTimezoneChanged is the type of our contact timezone changed event

View Source
const TypeContactURNAdded string = "contact_urn_added"

TypeContactURNAdded is the type of our add URN event

View Source
const TypeEmailCreated string = "email_created"

TypeEmailCreated is our type for the email event

View Source
const TypeEnvironmentChanged string = "environment_changed"

TypeEnvironmentChanged is the type of our environment changed event

View Source
const TypeError string = "error"

TypeError is the type of our error events

View Source
const TypeFlowTriggered string = "flow_triggered"

TypeFlowTriggered is the type of our flow triggered event

View Source
const TypeInputLabelsAdded string = "input_labels_added"

TypeInputLabelsAdded is the type of our add label action

View Source
const TypeMsgCreated string = "msg_created"

TypeMsgCreated is a constant for incoming messages

View Source
const TypeMsgReceived string = "msg_received"

TypeMsgReceived is a constant for incoming messages

View Source
const TypeMsgWait string = "msg_wait"

TypeMsgWait is the type of our msg wait event

View Source
const TypeNothingWait string = "nothing_wait"

TypeNothingWait is the type of our nothing wait event

View Source
const TypeRunExpired string = "run_expired"

TypeRunExpired is the type of our flow expired event

View Source
const TypeRunResultChanged string = "run_result_changed"

TypeRunResultChanged is the type of our run result event

View Source
const TypeSessionTriggered string = "session_triggered"

TypeSessionTriggered is the type of our session triggered event

View Source
const TypeWaitTimedOut string = "wait_timed_out"

TypeWaitTimedOut is the type of our wait timed out events

View Source
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 ReadCallerEvents added in v0.18.0

func ReadCallerEvents(envelopes []*utils.TypedEnvelope) ([]flows.CallerEvent, error)

ReadCallerEvents reads the caller events from the given 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 RegisterType added in v0.11.0

func RegisterType(name string, initFunc func() flows.Event)

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"`
}

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) CreatedOn

func (e *BaseEvent) CreatedOn() time.Time

CreatedOn returns the created on time of this event

func (*BaseEvent) SetStepUUID added in v0.11.0

func (e *BaseEvent) SetStepUUID(stepUUID flows.StepUUID)

SetStepUUID sets the UUID of the step in the path where this event occured

func (*BaseEvent) StepUUID added in v0.11.0

func (e *BaseEvent) StepUUID() flows.StepUUID

StepUUID returns 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"`
}

BroadcastCreatedEvent events are created when an action wants to send a message to other contacts.

{
  "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) Type added in v0.5.0

func (e *BroadcastCreatedEvent) Type() string

Type returns the type of this event

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"`
}

ContactChangedEvent events are sent by the caller to tell the engine to update the session contact.

{
  "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) 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"`
}

ContactChannelChangedEvent events are created when the preferred channel of the contact has been 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) Type added in v0.5.0

Type returns the type of this event

type ContactFieldChangedEvent added in v0.5.0

type ContactFieldChangedEvent struct {
	BaseEvent

	Field *assets.FieldReference `json:"field" validate:"required"`
	Value *flows.Value           `json:"value" validate:"required"`
}

ContactFieldChangedEvent events are created when a custom field value of the contact has been changed.

{
  "type": "contact_field_changed",
  "created_on": "2006-01-02T15:04:05Z",
  "field": {"key": "gender", "name": "Gender"},
  "value": {"text": "Male"}
}

@event contact_field_changed

func NewContactFieldChangedEvent added in v0.5.0

func NewContactFieldChangedEvent(field *assets.FieldReference, value *flows.Value) *ContactFieldChangedEvent

NewContactFieldChangedEvent returns a new save to contact event

func (*ContactFieldChangedEvent) Type added in v0.5.0

func (e *ContactFieldChangedEvent) Type() string

Type returns the type of this event

type ContactGroupsChangedEvent added in v0.18.0

type ContactGroupsChangedEvent struct {
	BaseEvent

	GroupsAdded   []*assets.GroupReference `json:"groups_added,omitempty" validate:"omitempty,dive"`
	GroupsRemoved []*assets.GroupReference `json:"groups_removed,omitempty" validate:"omitempty,dive"`
}

ContactGroupsChangedEvent events are created when a contact is added or removed to/from one or more groups.

{
  "type": "contact_groups_changed",
  "created_on": "2006-01-02T15:04:05Z",
  "groups_added": [{"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "name": "Reporters"}],
  "groups_removed": [{"uuid": "1e1ce1e1-9288-4504-869e-022d1003c72a", "name": "Customers"}]
}

@event contact_groups_changed

func NewContactGroupsChangedEvent added in v0.18.0

func NewContactGroupsChangedEvent(added []*flows.Group, removed []*flows.Group) *ContactGroupsChangedEvent

NewContactGroupsChangedEvent returns a new contact_groups_changed event

func (*ContactGroupsChangedEvent) Type added in v0.18.0

Type returns the type of this event

type ContactLanguageChangedEvent added in v0.10.0

type ContactLanguageChangedEvent struct {
	BaseEvent

	Language string `json:"language"`
}

ContactLanguageChangedEvent events are created when the language of the 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) Type added in v0.10.0

Type returns the type of this event

type ContactNameChangedEvent added in v0.10.0

type ContactNameChangedEvent struct {
	BaseEvent

	Name string `json:"name"`
}

ContactNameChangedEvent events are created when the name of the 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) Type added in v0.10.0

func (e *ContactNameChangedEvent) Type() string

Type returns the type of this event

type ContactTimezoneChangedEvent added in v0.10.0

type ContactTimezoneChangedEvent struct {
	BaseEvent

	Timezone string `json:"timezone"`
}

ContactTimezoneChangedEvent events are created when the timezone of the 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) Type added in v0.10.0

Type returns the type of this event

type ContactURNAddedEvent added in v0.5.0

type ContactURNAddedEvent struct {
	BaseEvent

	URN urns.URN `json:"urn" validate:"urn"`
}

ContactURNAddedEvent events are created when a URN has been added to the 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) Type added in v0.5.0

func (e *ContactURNAddedEvent) Type() string

Type returns the type of this event

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"`
}

EmailCreatedEvent events are created when an action wants to send 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) Type added in v0.5.0

func (e *EmailCreatedEvent) Type() string

Type returns the type of this event

type EnvironmentChangedEvent added in v0.5.0

type EnvironmentChangedEvent struct {
	BaseEvent

	Environment json.RawMessage `json:"environment"`
}

EnvironmentChangedEvent events are sent by the caller to tell the engine to update the session environment.

{
  "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) Apply added in v0.5.0

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"`
}

ErrorEvent events are created when an error occurs during flow execution.

{
  "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) Type

func (e *ErrorEvent) Type() string

Type returns the type of this event

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"`
}

FlowTriggeredEvent events are created when an action has started a sub-flow.

{
  "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) Type added in v0.4.0

func (e *FlowTriggeredEvent) Type() string

Type returns the type of this event

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"`
}

InputLabelsAddedEvent events are created when an action wants to add labels to the current 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) Type added in v0.5.0

func (e *InputLabelsAddedEvent) Type() string

Type returns the type of this event

type MsgCreatedEvent added in v0.6.0

type MsgCreatedEvent struct {
	BaseEvent

	Msg flows.MsgOut `json:"msg" validate:"required,dive"`
}

MsgCreatedEvent events are created when an action wants to send a reply to the current 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) Type added in v0.6.0

func (e *MsgCreatedEvent) Type() string

Type returns the type of this event

type MsgReceivedEvent

type MsgReceivedEvent struct {
	BaseEvent

	Msg flows.MsgIn `json:"msg" validate:"required,dive"`
}

MsgReceivedEvent events are sent by the caller to tell the engine that a message was received from the contact and that it should try to resume the session.

{
  "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) 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"`
}

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) Type

func (e *MsgWaitEvent) Type() string

Type returns the type of this event

type NothingWaitEvent added in v0.4.0

type NothingWaitEvent struct {
	BaseEvent
}

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) Type added in v0.4.0

func (e *NothingWaitEvent) Type() string

Type returns the type of this event

type RunExpiredEvent added in v0.4.0

type RunExpiredEvent struct {
	BaseEvent

	RunUUID flows.RunUUID `json:"run_uuid"    validate:"required,uuid4"`
}

RunExpiredEvent events are sent by the caller to tell 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) 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"`
	Input             *string         `json:"input,omitempty"`
	Extra             json.RawMessage `json:"extra,omitempty"`
}

RunResultChangedEvent events are created when a run 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, input *string, extra json.RawMessage) *RunResultChangedEvent

NewRunResultChangedEvent returns a new save result event for the passed in values

func (*RunResultChangedEvent) Type added in v0.5.0

func (e *RunResultChangedEvent) Type() string

Type returns the type of this event

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"`
}

SessionTriggeredEvent events are created when an action wants to start other people in a flow.

{
  "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) Type added in v0.4.0

func (e *SessionTriggeredEvent) Type() string

Type returns the type of this event

type WaitTimedOutEvent added in v0.9.10

type WaitTimedOutEvent struct {
	BaseEvent
}

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) 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"`
	Resthook string              `json:"resthook,omitempty"`
	Status   flows.WebhookStatus `json:"status" validate:"required"`
	Request  string              `json:"request" validate:"required"`
	Response string              `json:"response"`
}

WebhookCalledEvent events are created when a webhook is called. The event contains the URL and the status 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",
  "request": "GET /?format=json HTTP/1.1",
  "response": "HTTP/1.1 200 OK\r\n\r\n{\"ip\":\"190.154.48.130\"}"
}

@event webhook_called

func NewWebhookCalledEvent added in v0.4.0

func NewWebhookCalledEvent(webhook *flows.WebhookCall, resthook string) *WebhookCalledEvent

NewWebhookCalledEvent returns a new webhook called event

func (*WebhookCalledEvent) Type

func (e *WebhookCalledEvent) Type() string

Type returns the type of this event

Jump to

Keyboard shortcuts

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