Documentation
¶
Index ¶
- Constants
- func EventFromEnvelope(envelope *utils.TypedEnvelope) (flows.Event, error)
- type AddToGroupEvent
- type BaseEvent
- type ErrorEvent
- type FlowEnteredEvent
- type FlowExitedEvent
- type FlowWaitEvent
- type MsgReceivedEvent
- type MsgWaitEvent
- type RemoveFromGroupEvent
- type SaveContactFieldEvent
- type SaveFlowResultEvent
- type SendEmailEvent
- type SendMsgEvent
- type UpdateContactEvent
- type WebhookCalledEvent
Constants ¶
const TypeAddToGroup string = "add_to_group"
TypeAddToGroup is the type of our add to group action
const TypeError string = "error"
TypeError is the type of our error events
const TypeFlowEntered string = "flow_entered"
TypeFlowEntered is the type of our flow enter event
const TypeFlowExited string = "flow_exited"
TypeFlowExited is the type of our flow exit
const TypeFlowWait string = "flow_wait"
TypeFlowWait is the type of our flow wait event
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 TypeRemoveFromGroup string = "remove_from_group"
TypeRemoveFromGroup is the type fo our remove from group action
const TypeSaveContactField string = "save_contact_field"
TypeSaveContactField is the type of our save to contact event
const TypeSaveFlowResult string = "save_flow_result"
TypeSaveFlowResult is the type of our save result event
const TypeSendEmail string = "send_email"
TypeSendEmail is our type for the email event
const TypeSendMsg string = "send_msg"
TypeSendMsg is a constant for incoming messages
const TypeUpdateContact string = "update_contact"
TypeUpdateContact is the type of our update contact 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)
Types ¶
type AddToGroupEvent ¶
type AddToGroupEvent struct { BaseEvent Groups []*flows.Group `json:"groups" validate:"required,min=1,dive,uuid4"` }
AddToGroupEvent events will be created with the groups a contact should be added to.
```
{ "step_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "created_on": "2006-01-02T15:04:05Z", "type": "add_to_group", "groups": [{ "uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "name": "Survey Audience" }] }
```
@event add_to_group
func NewGroupEvent ¶
func NewGroupEvent(groups []*flows.Group) *AddToGroupEvent
NewGroupEvent returns a new group event
func (*AddToGroupEvent) Type ¶
func (e *AddToGroupEvent) Type() string
Type returns the type of this event
type BaseEvent ¶
type BaseEvent struct { CreatedOn_ *time.Time `json:"created_on" validate:"required"` StepUUID_ flows.StepUUID `json:"step_uuid"` }
func (*BaseEvent) SetCreatedOn ¶
type ErrorEvent ¶
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", "step_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "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
type FlowEnteredEvent ¶
type FlowEnteredEvent struct { BaseEvent FlowUUID flows.FlowUUID `json:"flow_uuid" validate:"required,uuid4"` ContactUUID flows.ContactUUID `json:"contact_uuid" validate:"required,uuid4"` }
FlowEnteredEvent events are created when a contact first enters a flow.
```
{ "type": "flow_entered", "step_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "created_on": "2006-01-02T15:04:05Z", "flow_uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a", "contact_uuid": "95eb96df-461b-4668-b168-727f8ceb13dd" }
```
@event flow_entered
func NewFlowEnterEvent ¶
func NewFlowEnterEvent(flow flows.FlowUUID, contact flows.ContactUUID) *FlowEnteredEvent
NewFlowEnterEvent returns a new flow enter event for the passed in flow and contact
func (*FlowEnteredEvent) Default ¶
func (e *FlowEnteredEvent) Default() interface{}
Default returns the default value for this event
func (*FlowEnteredEvent) Resolve ¶
func (e *FlowEnteredEvent) Resolve(key string) interface{}
Resolve resolves the passed in key for this event
func (*FlowEnteredEvent) String ¶
func (e *FlowEnteredEvent) String() string
String returns the default string value for this event
func (*FlowEnteredEvent) Type ¶
func (e *FlowEnteredEvent) Type() string
Type returns the type of this event
type FlowExitedEvent ¶
type FlowExitedEvent struct { BaseEvent FlowUUID flows.FlowUUID `json:"flow_uuid" validate:"required"` ContactUUID flows.ContactUUID `json:"contact_uuid" validate:"required"` Status flows.RunStatus `json:"status" validate:"required"` ExitedOn *time.Time `json:"exited_on" validate:"required"` }
FlowExitedEvent events are created when a contact exits a flow. It contains not only the contact and flow which was exited, but also the time it was exited and the exit status.
```
{ "type": "flow_exited", "step_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "created_on": "2006-01-02T15:04:05Z", "flow_uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a", "contact_uuid": "95eb96df-461b-4668-b168-727f8ceb13dd", "exited_on": "2006-01-02T15:04:05Z", "status": "C" }
```
@event flow_exited
func NewFlowExitedEvent ¶
func NewFlowExitedEvent(run flows.FlowRunReference) *FlowExitedEvent
NewFlowExitedEvent returns a new flow exit event
func (*FlowExitedEvent) Default ¶
func (e *FlowExitedEvent) Default() interface{}
Default returns the default value for this event
func (*FlowExitedEvent) Resolve ¶
func (e *FlowExitedEvent) Resolve(key string) interface{}
Resolve resolves the passed in key
func (*FlowExitedEvent) String ¶
func (e *FlowExitedEvent) String() string
String returns the default string value
func (*FlowExitedEvent) Type ¶
func (e *FlowExitedEvent) Type() string
Type returns the type of our event
type FlowWaitEvent ¶
FlowWaitEvent events are created when a flow pauses waiting for a subflow to exit.
```
{ "type": "flow_wait", "step_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "created_on": "2006-01-02T15:04:05Z", "flow_uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a" }
```
@event flow_wait
func NewFlowWait ¶
func NewFlowWait(flow flows.FlowUUID) *FlowWaitEvent
NewFlowWait returns a new flow wait event
func (*FlowWaitEvent) Type ¶
func (e *FlowWaitEvent) Type() string
Type returns the type of this event
type MsgReceivedEvent ¶
type MsgReceivedEvent struct { BaseEvent ID int64 `json:"id"` ChannelUUID flows.ChannelUUID `json:"channel_uuid" validate:"required,uuid4"` URN flows.URN `json:"urn" validate:"required"` ContactUUID flows.ContactUUID `json:"contact_uuid" validate:"required,uuid4"` Text string `json:"text"` }
MsgReceivedEvent events are used for resuming flows or starting flows. They represent an MO message for a contact.
```
{ "type": "msg_received", "step_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "created_on": "2006-01-02T15:04:05Z", "urn": "tel:+12065551212", "channel_uuid": "61602f3e-f603-4c70-8a8f-c477505bf4bf", "contact_uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a", "text": "hi there" }
```
@event msg_received
func NewMsgReceivedEvent ¶
func NewMsgReceivedEvent(channel flows.ChannelUUID, contact flows.ContactUUID, urn flows.URN, text string) *MsgReceivedEvent
NewMsgReceivedEvent creates a new incoming msg event for the passed in channel, contact and string
func (*MsgReceivedEvent) Default ¶
func (e *MsgReceivedEvent) Default() interface{}
Default returns our default value if evaluated in a context, our text in our case
func (*MsgReceivedEvent) Resolve ¶
func (e *MsgReceivedEvent) Resolve(key string) interface{}
Resolve resolves the passed in key to a value, returning an error if the key is unknown
func (*MsgReceivedEvent) String ¶
func (e *MsgReceivedEvent) String() string
String returns our default value if evaluated in a context, our text in our case
func (*MsgReceivedEvent) Type ¶
func (e *MsgReceivedEvent) Type() string
Type returns the type of this event
type MsgWaitEvent ¶
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.
```
{ "step_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "created_on": "2006-01-02T15:04:05Z", "type": "msg_wait", "timeout": 300 }
```
@event msg_wait
func NewMsgWait ¶
func NewMsgWait(timeout int) *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 RemoveFromGroupEvent ¶
type RemoveFromGroupEvent struct { Groups []*flows.Group `json:"groups" validate:"required,min=1"` BaseEvent }
RemoveFromGroupEvent events are created when a contact is removed from one or more groups.
```
{ "step_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "created_on": "2006-01-02T15:04:05Z", "type": "remove_from_group", "groups": [{ "name": "Survey Audience", "uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d" }] }
```
@event remove_from_group
func NewRemoveFromGroup ¶
func NewRemoveFromGroup(groups []*flows.Group) *RemoveFromGroupEvent
NewRemoveFromGroup returns a new remove from group event
func (*RemoveFromGroupEvent) Type ¶
func (e *RemoveFromGroupEvent) Type() string
Type returns the type of this event
type SaveContactFieldEvent ¶
type SaveContactFieldEvent struct { BaseEvent FieldUUID flows.FieldUUID `json:"field_uuid" validate:"required"` FieldName string `json:"field_name" validate:"required"` Value string `json:"value"` }
SaveContactFieldEvent events are created when a contact field is updated.
```
{ "step_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "save_contact_field", "created_on": "2006-01-02T15:04:05Z", "field_uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "field_name": "Gender", "value": "Male" }
```
@event save_contact_field
func NewSaveToContact ¶
func NewSaveToContact(field flows.FieldUUID, name string, value string) *SaveContactFieldEvent
NewSaveToContact returns a new save to contact event
func (*SaveContactFieldEvent) Type ¶
func (e *SaveContactFieldEvent) Type() string
Type returns the type of this event
type SaveFlowResultEvent ¶
type SaveFlowResultEvent struct { BaseEvent NodeUUID flows.NodeUUID `json:"node_uuid" validate:"required"` ResultName string `json:"result_name" validate:"required"` Value string `json:"value"` Category string `json:"category"` CategoryLocalized string `json:"category_localized,omitempty"` }
SaveFlowResultEvent 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 saved.
```
{ "step_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "created_on": "2006-01-02T15:04:05Z", "type": "save_flow_result", "node_uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "result_name": "Gender", "value": "m", "category": "Make" }
```
@event save_flow_result
func NewSaveFlowResult ¶
func NewSaveFlowResult(node flows.NodeUUID, name string, value string, categoryName string, categoryLocalized string) *SaveFlowResultEvent
NewSaveFlowResult returns a new save result event for the passed in values
func (*SaveFlowResultEvent) Type ¶
func (e *SaveFlowResultEvent) Type() string
Type returns the type of this event
type SendEmailEvent ¶
type SendEmailEvent struct { BaseEvent Email string `json:"email" validate:"required"` Subject string `json:"subject" validate:"required"` Body string `json:"body"` }
SendEmailEvent events are created for each recipient which should receive an email.
```
{ "type": "send_email", "step_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "created_on": "2006-01-02T15:04:05Z", "email": "foo@bar.com", "subject": "Your activation token", "body": "Your activation token is AAFFKKEE" }
```
@event send_email
func NewSendEmailEvent ¶
func NewSendEmailEvent(email string, subject string, body string) *SendEmailEvent
NewSendEmailEvent returns a new email event with the passed in subject, body and emails
func (*SendEmailEvent) Type ¶
func (a *SendEmailEvent) Type() string
Type returns the type of this event
type SendMsgEvent ¶
type SendMsgEvent struct { BaseEvent URN flows.URN `json:"urn,omitempty"` ContactUUID flows.ContactUUID `json:"contact_uuid,omitempty"` GroupUUID flows.GroupUUID `json:"group_uuid,omitempty"` Text string `json:"text" validate:"required"` Attachments []string `json:"attachments,omitempty"` }
SendMsgEvent events are created for each outgoing message. They represent an MT message to a contact, urn or group.
```
{ "type": "send_msg", "step_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "created_on": "2006-01-02T15:04:05Z", "urn": "tel:%2B12065551212", "contact_uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a", "text": "hi, what's up", "attachments": [] }
```
@event send_msg
func NewSendMsgToContact ¶
func NewSendMsgToContact(contact flows.ContactUUID, text string, attachments []string) *SendMsgEvent
NewSendMsgToContact creates a new outgoing msg event for the passed in channel, contact and string
func NewSendMsgToGroup ¶
func NewSendMsgToGroup(group flows.GroupUUID, text string, attachments []string) *SendMsgEvent
NewSendMsgToGroup creates a new outgoing msg event for the passed in channel, group and string
func NewSendMsgToURN ¶
func NewSendMsgToURN(urn flows.URN, text string, attachments []string) *SendMsgEvent
NewSendMsgToURN creates a new outgoing msg event for the passed in channel, urn and string
func (*SendMsgEvent) Type ¶
func (e *SendMsgEvent) Type() string
Type returns the type of this event
type UpdateContactEvent ¶
type UpdateContactEvent struct { BaseEvent FieldName string `json:"field_name" validate:"required"` Value string `json:"value"` }
UpdateContactEvent events are created when a contact's built in field is updated.
```
{ "step_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "update_contact", "created_on": "2006-01-02T15:04:05Z", "field_name": "Language", "value": "eng" }
```
@event update_contact
func NewUpdateContact ¶
func NewUpdateContact(name string, value string) *UpdateContactEvent
NewUpdateContact returns a new save to contact event
func (*UpdateContactEvent) Type ¶
func (e *UpdateContactEvent) Type() string
Type returns the type of this event
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"` }
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.
```
{ "step_uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "created_on": "2006-01-02T15:04:05Z", "type": "webhook_called", "url": "https://api.ipify.org?format=json", "status": "S", "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 (*WebhookCalledEvent) Type ¶
func (e *WebhookCalledEvent) Type() string
Type returns the type of this event