Documentation ¶
Index ¶
- Constants
- func ActionFromEnvelope(envelope *utils.TypedEnvelope) (flows.Action, error)
- func NewEventLog() flows.EventLog
- type AddLabelAction
- type AddToGroupAction
- type AddURNAction
- type BaseAction
- type EmailAction
- type PreferredChannelAction
- type RemoveFromGroupAction
- type ReplyAction
- type SaveContactField
- type SaveFlowResultAction
- type SendMsgAction
- type StartFlowAction
- type StartSessionAction
- type UpdateContactAction
- type WebhookAction
Constants ¶
const TypeAddLabel string = "add_label"
TypeAddLabel is our type for add label actions
const TypeAddToGroup string = "add_to_group"
TypeAddToGroup is our type for the add to group action
const TypeAddURN string = "add_urn"
TypeAddURN is our type for add URN actions
const TypeCallWebhook string = "call_webhook"
TypeCallWebhook is the type for our webhook action
const TypeRemoveFromGroup string = "remove_from_group"
TypeRemoveFromGroup is our type for our remove from group action
const TypeReply string = "reply"
TypeReply is the type for reply actions
const TypeSaveContactField string = "save_contact_field"
TypeSaveContactField is the type for our save to contact action
const TypeSaveFlowResult string = "save_flow_result"
TypeSaveFlowResult is our type for the save result action
const TypeSendEmail string = "send_email"
TypeSendEmail is our type for the email action
const TypeSendMsg string = "send_msg"
TypeSendMsg is the type for msg actions
const TypeSetPreferredChannel string = "set_preferred_channel"
const TypeStartFlow string = "start_flow"
TypeStartFlow is the type for the start flow action
const TypeStartSession string = "start_session"
TypeStartSession is the type for the start session action
const TypeUpdateContact string = "update_contact"
TypeUpdateContact is the type for our update contact action
Variables ¶
This section is empty.
Functions ¶
func ActionFromEnvelope ¶
func ActionFromEnvelope(envelope *utils.TypedEnvelope) (flows.Action, error)
func NewEventLog ¶ added in v0.4.0
Types ¶
type AddLabelAction ¶
type AddLabelAction struct { BaseAction Labels []*flows.LabelReference `json:"labels" validate:"required,min=1,dive"` }
AddLabelAction can be used to add a label to the last user input on a flow. An `input_labels_added` event will be created with the labels added when this action is encountered. If there is no user input at that point then this action will be ignored.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "add_label", "labels": [{ "uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "name": "complaint" }] }
```
@action add_label
func (*AddLabelAction) Type ¶
func (a *AddLabelAction) Type() string
Type returns the type of this action
func (*AddLabelAction) Validate ¶
func (a *AddLabelAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type AddToGroupAction ¶
type AddToGroupAction struct { BaseAction Groups []*flows.GroupReference `json:"groups" validate:"required,min=1,dive"` }
AddToGroupAction can be used to add a contact to one or more groups. An `contact_groups_added` event will be created for the groups which the contact has been added to.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "add_to_group", "groups": [{ "uuid": "2aad21f6-30b7-42c5-bd7f-1b720c154817", "name": "Survey Audience" }] }
```
@action add_to_group
func (*AddToGroupAction) Type ¶
func (a *AddToGroupAction) Type() string
Type returns the type of this action
func (*AddToGroupAction) Validate ¶
func (a *AddToGroupAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type AddURNAction ¶ added in v0.4.0
type AddURNAction struct { BaseAction Scheme string `json:"scheme" validate:"urnscheme"` Path string `json:"path" validate:"required"` }
AddURNAction can be used to add a URN to the current contact. An `contact_urn_added` event will be created when this action is encountered. If there is no contact then this action will be ignored.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "add_urn", "scheme": "tel", "path": "@flow.phone_number" }
```
@action add_urn
func (*AddURNAction) Type ¶ added in v0.4.0
func (a *AddURNAction) Type() string
Type returns the type of this action
func (*AddURNAction) Validate ¶ added in v0.4.0
func (a *AddURNAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type BaseAction ¶
type BaseAction struct {
UUID_ flows.ActionUUID `json:"uuid" validate:"required,uuid4"`
}
BaseAction is our base action
func NewBaseAction ¶ added in v0.4.0
func NewBaseAction(uuid flows.ActionUUID) BaseAction
func (*BaseAction) UUID ¶
func (a *BaseAction) UUID() flows.ActionUUID
UUID returns the UUID of the action
type EmailAction ¶
type EmailAction struct { BaseAction Addresses []string `json:"addresses" validate:"required,min=1"` Subject string `json:"subject" validate:"required"` Body string `json:"body" validate:"required"` }
EmailAction can be used to send an email to one or more recipients. The subject, body and addresses can all contain expressions.
A `email_created` event will be created for each email address.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "send_email", "addresses": ["@contact.urns.email"], "subject": "Here is your activation token", "body": "Your activation token is @contact.fields.activation_token" }
```
@action send_email
func (*EmailAction) Validate ¶
func (a *EmailAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type PreferredChannelAction ¶
type PreferredChannelAction struct { BaseAction Channel *flows.ChannelReference `json:"channel"` }
func (*PreferredChannelAction) Type ¶
func (a *PreferredChannelAction) Type() string
Type returns the type of this action
func (*PreferredChannelAction) Validate ¶
func (a *PreferredChannelAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type RemoveFromGroupAction ¶
type RemoveFromGroupAction struct { BaseAction Groups []*flows.GroupReference `json:"groups" validate:"required,min=1,dive"` }
RemoveFromGroupAction can be used to remove a contact from one or more groups. A `contact_groups_removed` event will be created for the groups which the contact is removed from. If no groups are specified, then the contact will be removed from all groups.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "remove_from_group", "groups": [{ "uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "name": "Registered Users" }] }
```
@action remove_from_group
func (*RemoveFromGroupAction) Execute ¶
func (a *RemoveFromGroupAction) Execute(run flows.FlowRun, step flows.Step, log flows.EventLog) error
Execute runs the action
func (*RemoveFromGroupAction) Type ¶
func (a *RemoveFromGroupAction) Type() string
Type returns the type of this action
func (*RemoveFromGroupAction) Validate ¶
func (a *RemoveFromGroupAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type ReplyAction ¶
type ReplyAction struct { BaseAction Text string `json:"text"` Attachments []string `json:"attachments"` QuickReplies []string `json:"quick_replies,omitempty"` AllURNs bool `json:"all_urns,omitempty"` }
ReplyAction can be used to reply to the current contact in a flow. The text field may contain templates.
A `broadcast_created` event will be created with the evaluated text.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "reply", "text": "Hi @contact.name, are you ready to complete today's survey?", "attachments": [], "all_urns": false }
```
@action reply
func (*ReplyAction) Validate ¶
func (a *ReplyAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type SaveContactField ¶
type SaveContactField struct { BaseAction Field *flows.FieldReference `json:"field" validate:"required"` Value string `json:"value"` }
SaveContactField can be used to save a value to a contact. The value can be a template and will be evaluated during the flow. A `contact_field_changed` event will be created with the corresponding value.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "save_contact_field", "field": {"key": "gender", "label": "Gender"}, "value": "Male" }
```
@action save_contact_field
func (*SaveContactField) Type ¶
func (a *SaveContactField) Type() string
Type returns the type of this action
func (*SaveContactField) Validate ¶
func (a *SaveContactField) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type SaveFlowResultAction ¶
type SaveFlowResultAction struct { BaseAction Name string `json:"name" validate:"required"` Value string `json:"value" validate:"required"` Category string `json:"category"` }
SaveFlowResultAction can be used to save a result for a flow. The result will be available in the context for the run as @run.results.[name]. The optional category can be used as a way of categorizing results, this can be useful for reporting or analytics.
Both the value and category fields may be templates. A `run_result_changed` event will be created with the final values.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "save_flow_result", "name": "Gender", "value": "m", "category": "Male" }
```
@action save_flow_result
func (*SaveFlowResultAction) Execute ¶
func (a *SaveFlowResultAction) Execute(run flows.FlowRun, step flows.Step, log flows.EventLog) error
Execute runs this action
func (*SaveFlowResultAction) Type ¶
func (a *SaveFlowResultAction) Type() string
Type returns the type of this action
func (*SaveFlowResultAction) Validate ¶
func (a *SaveFlowResultAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type SendMsgAction ¶
type SendMsgAction struct { BaseAction Text string `json:"text"` Attachments []string `json:"attachments"` QuickReplies []string `json:"quick_replies,omitempty"` URNs []urns.URN `json:"urns,omitempty"` Contacts []*flows.ContactReference `json:"contacts,omitempty" validate:"dive"` Groups []*flows.GroupReference `json:"groups,omitempty" validate:"dive"` LegacyVars []string `json:"legacy_vars,omitempty"` }
SendMsgAction can be used to send a message to one or more contacts. It accepts a list of URNs, a list of groups and a list of contacts.
The URNs and text fields may be templates. A `send_msg` event will be created for each unique urn, contact and group with the evaluated text.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "send_msg", "urns": ["tel:+12065551212"], "text": "Hi @contact.name, are you ready to complete today's survey?" }
```
@action send_msg
func (*SendMsgAction) Type ¶
func (a *SendMsgAction) Type() string
Type returns the type of this action
func (*SendMsgAction) Validate ¶
func (a *SendMsgAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type StartFlowAction ¶
type StartFlowAction struct { BaseAction Flow *flows.FlowReference `json:"flow" validate:"required"` }
StartFlowAction can be used to start a contact down another flow. The current flow will pause until the subflow exits or expires.
A `flow_entered` event will be created when the flow is started, a `flow_exited` event will be created upon the subflows exit.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "start_flow", "flow": {"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "name": "Collect Language"} }
```
@action start_flow
func (*StartFlowAction) Type ¶
func (a *StartFlowAction) Type() string
Type returns the type of this action
func (*StartFlowAction) Validate ¶
func (a *StartFlowAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type StartSessionAction ¶ added in v0.4.0
type StartSessionAction struct { BaseAction URNs []urns.URN `json:"urns,omitempty"` Contacts []*flows.ContactReference `json:"contacts,omitempty" validate:"dive"` Groups []*flows.GroupReference `json:"groups,omitempty" validate:"dive"` LegacyVars []string `json:"legacy_vars,omitempty"` Flow *flows.FlowReference `json:"flow" validate:"required"` CreateContact bool `json:"create_contact,omitempty"` }
StartSessionAction can be used to trigger sessions for other contacts and groups
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "start_session", "flow": {"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "name": "Registration"}, "groups": [ {"uuid": "8f8e2cae-3c8d-4dce-9c4b-19514437e427", "name": "New contacts"} ] }
```
@action start_session
func (*StartSessionAction) Type ¶ added in v0.4.0
func (a *StartSessionAction) Type() string
Type returns the type of this action
func (*StartSessionAction) Validate ¶ added in v0.4.0
func (a *StartSessionAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type UpdateContactAction ¶
type UpdateContactAction struct { BaseAction FieldName string `json:"field_name" validate:"required,eq=name|eq=language"` Value string `json:"value"` }
UpdateContactAction can be used to update one of the built in fields for a contact of "name" or "language". An `contact_property_changed` event will be created with the corresponding values.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "update_contact", "field_name": "language", "value": "eng" }
```
@action update_contact
func (*UpdateContactAction) Type ¶
func (a *UpdateContactAction) Type() string
Type returns the type of this action
func (*UpdateContactAction) Validate ¶
func (a *UpdateContactAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type WebhookAction ¶
type WebhookAction struct { BaseAction Method string `json:"method" validate:"required"` URL string `json:"url" validate:"required"` Headers map[string]string `json:"headers,omitempty"` Body string `json:"body,omitempty"` }
WebhookAction can be used to call an external service and insert the results in @run.webhook context variable. The body, header and url fields may be templates and will be evaluated at runtime.
A `webhook_called` event will be created based on the results of the HTTP call.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "call_webhook", "method": "get", "url": "https://api.ipify.org?format=json", "headers": { "Authorization": "Token AAFFZZHH" } }
```
@action call_webhook
func (*WebhookAction) Type ¶
func (a *WebhookAction) Type() string
Type returns the type of this action
func (*WebhookAction) Validate ¶
func (a *WebhookAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs