Documentation ¶
Index ¶
- Constants
- func ActionFromEnvelope(envelope *utils.TypedEnvelope) (flows.Action, error)
- func NewEventLog() flows.EventLog
- type AddContactGroupsAction
- type AddContactURNAction
- type AddInputLabelsAction
- type BaseAction
- type CallWebhookAction
- type RemoveContactGroupsAction
- type SendBroadcastAction
- type SendEmailAction
- type SendMsgAction
- type SetContactChannelAction
- type SetContactFieldAction
- type SetContactLanguageAction
- type SetContactNameAction
- type SetContactTimezoneAction
- type SetRunResultAction
- type StartFlowAction
- type StartSessionAction
Constants ¶
const TypeAddContactGroups string = "add_contact_groups"
TypeAddContactGroups is our type for the add to groups action
const TypeAddContactURN string = "add_contact_urn"
TypeAddContactURN is our type for the add URN action
const TypeAddInputLabels string = "add_input_labels"
TypeAddInputLabels is the type for the add label action
const TypeCallWebhook string = "call_webhook"
TypeCallWebhook is the type for the call webhook action
const TypeRemoveContactGroups string = "remove_contact_groups"
TypeRemoveContactGroups is the type for the remove from groups action
const TypeSendBroadcast string = "send_broadcast"
TypeSendBroadcast is the type for the send broadcast action
const TypeSendEmail string = "send_email"
TypeSendEmail is the type for the send email action
const TypeSendMsg string = "send_msg"
TypeSendMsg is the type for the send message action
const TypeSetContactChannel string = "set_contact_channel"
TypeSetContactChannel is the type for the set contact channel action
const TypeSetContactField string = "set_contact_field"
TypeSetContactField is the type for the set contact field action
const TypeSetContactLanguage string = "set_contact_language"
TypeSetContactLanguage is the type for the set contact Language action
const TypeSetContactName string = "set_contact_name"
TypeSetContactName is the type for the set contact name action
const TypeSetContactTimezone string = "set_contact_timezone"
TypeSetContactTimezone is the type for the set contact timezone action
const TypeSetRunResult string = "set_run_result"
TypeSetRunResult is the type for the set run result action
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
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 AddContactGroupsAction ¶ added in v0.6.0
type AddContactGroupsAction struct { BaseAction Groups []*flows.GroupReference `json:"groups" validate:"required,min=1,dive"` }
AddContactGroupsAction 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_contact_groups", "groups": [{ "uuid": "1e1ce1e1-9288-4504-869e-022d1003c72a", "name": "Customers" }] }
@action add_contact_groups
func (*AddContactGroupsAction) Execute ¶ added in v0.6.0
func (a *AddContactGroupsAction) Execute(run flows.FlowRun, step flows.Step, log flows.EventLog) error
Execute adds our contact to the specified groups
func (*AddContactGroupsAction) Type ¶ added in v0.6.0
func (a *AddContactGroupsAction) Type() string
Type returns the type of this action
func (*AddContactGroupsAction) Validate ¶ added in v0.6.0
func (a *AddContactGroupsAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type AddContactURNAction ¶ added in v0.6.0
type AddContactURNAction struct { BaseAction Scheme string `json:"scheme" validate:"urnscheme"` Path string `json:"path" validate:"required"` }
AddContactURNAction 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_contact_urn", "scheme": "tel", "path": "@run.results.phone_number" }
@action add_contact_urn
func (*AddContactURNAction) Type ¶ added in v0.6.0
func (a *AddContactURNAction) Type() string
Type returns the type of this action
func (*AddContactURNAction) Validate ¶ added in v0.6.0
func (a *AddContactURNAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type AddInputLabelsAction ¶ added in v0.6.0
type AddInputLabelsAction struct { BaseAction Labels []*flows.LabelReference `json:"labels" validate:"required,min=1,dive"` }
AddInputLabelsAction can be used to add labels 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_input_labels", "labels": [{ "uuid": "3f65d88a-95dc-4140-9451-943e94e06fea", "name": "Spam" }] }
@action add_input_labels
func (*AddInputLabelsAction) Execute ¶ added in v0.6.0
func (a *AddInputLabelsAction) Execute(run flows.FlowRun, step flows.Step, log flows.EventLog) error
Execute runs the labeling action
func (*AddInputLabelsAction) Type ¶ added in v0.6.0
func (a *AddInputLabelsAction) Type() string
Type returns the type of this action
func (*AddInputLabelsAction) Validate ¶ added in v0.6.0
func (a *AddInputLabelsAction) 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 CallWebhookAction ¶ added in v0.6.0
type CallWebhookAction struct { BaseAction Method string `json:"method" validate:"required,http_method"` URL string `json:"url" validate:"required"` Headers map[string]string `json:"headers,omitempty"` Body string `json:"body,omitempty"` }
CallWebhookAction 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": "http://localhost:49998/?cmd=success", "headers": { "Authorization": "Token AAFFZZHH" } }
@action call_webhook
func (*CallWebhookAction) Type ¶ added in v0.6.0
func (a *CallWebhookAction) Type() string
Type returns the type of this action
func (*CallWebhookAction) Validate ¶ added in v0.6.0
func (a *CallWebhookAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type RemoveContactGroupsAction ¶ added in v0.6.0
type RemoveContactGroupsAction struct { BaseAction Groups []*flows.GroupReference `json:"groups" validate:"required,min=1,dive"` }
RemoveContactGroupsAction 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_contact_groups", "groups": [{ "uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "name": "Registered Users" }] }
@action remove_contact_groups
func (*RemoveContactGroupsAction) Execute ¶ added in v0.6.0
func (a *RemoveContactGroupsAction) Execute(run flows.FlowRun, step flows.Step, log flows.EventLog) error
Execute runs the action
func (*RemoveContactGroupsAction) Type ¶ added in v0.6.0
func (a *RemoveContactGroupsAction) Type() string
Type returns the type of this action
func (*RemoveContactGroupsAction) Validate ¶ added in v0.6.0
func (a *RemoveContactGroupsAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type SendBroadcastAction ¶ added in v0.6.0
type SendBroadcastAction 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"` }
SendBroadcastAction 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_broadcast` event will be created for each unique urn, contact and group with the evaluated text.
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "send_broadcast", "urns": ["tel:+12065551212"], "text": "Hi @contact.name, are you ready to complete today's survey?" }
@action send_broadcast
func (*SendBroadcastAction) Type ¶ added in v0.6.0
func (a *SendBroadcastAction) Type() string
Type returns the type of this action
func (*SendBroadcastAction) Validate ¶ added in v0.6.0
func (a *SendBroadcastAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type SendEmailAction ¶ added in v0.6.0
type SendEmailAction struct { BaseAction Addresses []string `json:"addresses" validate:"required,min=1"` Subject string `json:"subject" validate:"required"` Body string `json:"body" validate:"required"` }
SendEmailAction can be used to send an email to one or more recipients. The subject, body and addresses can all contain expressions.
An `email_created` event will be created for each email address.
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "send_email", "addresses": ["@contact.urns.mailto.0"], "subject": "Here is your activation token", "body": "Your activation token is @contact.fields.activation_token" }
@action send_email
func (*SendEmailAction) Type ¶ added in v0.6.0
func (a *SendEmailAction) Type() string
Type returns the type of this action
func (*SendEmailAction) Validate ¶ added in v0.6.0
func (a *SendEmailAction) 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"` AllURNs bool `json:"all_urns,omitempty"` }
SendMsgAction 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": "send_msg", "text": "Hi @contact.name, are you ready to complete today's survey?", "attachments": [], "all_urns": false }
@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 SetContactChannelAction ¶ added in v0.6.0
type SetContactChannelAction struct { BaseAction Channel *flows.ChannelReference `json:"channel"` }
SetContactChannelAction can be used to update the preferred channel of the current contact.
A `contact_channel_changed` event will be created with the set channel.
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "set_contact_channel", "channel": {"uuid": "4bb288a0-7fca-4da1-abe8-59a593aff648", "name": "FAcebook Channel"} }
@action set_contact_channel
func (*SetContactChannelAction) Type ¶ added in v0.6.0
func (a *SetContactChannelAction) Type() string
Type returns the type of this action
func (*SetContactChannelAction) Validate ¶ added in v0.6.0
func (a *SetContactChannelAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type SetContactFieldAction ¶ added in v0.6.0
type SetContactFieldAction struct { BaseAction Field *flows.FieldReference `json:"field" validate:"required"` Value string `json:"value"` }
SetContactFieldAction can be used to update a field value on the contact. The value is a localizable template and white space is trimmed from the final value. An empty string clears the value. A `contact_field_changed` event will be created with the corresponding value.
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "set_contact_field", "field": {"key": "gender", "name": "Gender"}, "value": "Male" }
@action set_contact_field
func (*SetContactFieldAction) Execute ¶ added in v0.6.0
func (a *SetContactFieldAction) Execute(run flows.FlowRun, step flows.Step, log flows.EventLog) error
Execute runs this action
func (*SetContactFieldAction) Type ¶ added in v0.6.0
func (a *SetContactFieldAction) Type() string
Type returns the type of this action
func (*SetContactFieldAction) Validate ¶ added in v0.6.0
func (a *SetContactFieldAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type SetContactLanguageAction ¶ added in v0.10.0
type SetContactLanguageAction struct { BaseAction Language string `json:"language"` }
SetContactLanguageAction can be used to update the name of the contact. The language is a localizable template and white space is trimmed from the final value. An empty string clears the language. A `contact_language_changed` event will be created with the corresponding value.
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "set_contact_language", "language": "eng" }
@action set_contact_language
func (*SetContactLanguageAction) Execute ¶ added in v0.10.0
func (a *SetContactLanguageAction) Execute(run flows.FlowRun, step flows.Step, log flows.EventLog) error
Execute runs this action
func (*SetContactLanguageAction) Type ¶ added in v0.10.0
func (a *SetContactLanguageAction) Type() string
Type returns the type of this action
func (*SetContactLanguageAction) Validate ¶ added in v0.10.0
func (a *SetContactLanguageAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type SetContactNameAction ¶ added in v0.10.0
type SetContactNameAction struct { BaseAction Name string `json:"name"` }
SetContactNameAction can be used to update the name of the contact. The name is a localizable template and white space is trimmed from the final value. An empty string clears the name. A `contact_name_changed` event will be created with the corresponding value.
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "set_contact_name", "name": "Bob Smith" }
@action set_contact_name
func (*SetContactNameAction) Execute ¶ added in v0.10.0
func (a *SetContactNameAction) Execute(run flows.FlowRun, step flows.Step, log flows.EventLog) error
Execute runs this action
func (*SetContactNameAction) Type ¶ added in v0.10.0
func (a *SetContactNameAction) Type() string
Type returns the type of this action
func (*SetContactNameAction) Validate ¶ added in v0.10.0
func (a *SetContactNameAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type SetContactTimezoneAction ¶ added in v0.10.0
type SetContactTimezoneAction struct { BaseAction Timezone string `json:"timezone"` }
SetContactTimezoneAction can be used to update the timezone of the contact. The timezone is a localizable template and white space is trimmed from the final value. An empty string clears the timezone. A `contact_timezone_changed` event will be created with the corresponding value.
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "set_contact_timezone", "timezone": "Africa/Kigali" }
@action set_contact_timezone
func (*SetContactTimezoneAction) Execute ¶ added in v0.10.0
func (a *SetContactTimezoneAction) Execute(run flows.FlowRun, step flows.Step, log flows.EventLog) error
Execute runs this action
func (*SetContactTimezoneAction) Type ¶ added in v0.10.0
func (a *SetContactTimezoneAction) Type() string
Type returns the type of this action
func (*SetContactTimezoneAction) Validate ¶ added in v0.10.0
func (a *SetContactTimezoneAction) Validate(assets flows.SessionAssets) error
Validate validates our action is valid and has all the assets it needs
type SetRunResultAction ¶ added in v0.6.0
type SetRunResultAction struct { BaseAction Name string `json:"name" validate:"required"` Value string `json:"value" validate:"required"` Category string `json:"category"` }
SetRunResultAction 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": "set_run_result", "name": "Gender", "value": "m", "category": "Male" }
@action set_run_result
func (*SetRunResultAction) Type ¶ added in v0.6.0
func (a *SetRunResultAction) Type() string
Type returns the type of this action
func (*SetRunResultAction) Validate ¶ added in v0.6.0
func (a *SetRunResultAction) 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": "1e1ce1e1-9288-4504-869e-022d1003c72a", "name": "Customers"} ] }
@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
Source Files ¶
- add_contact_groups.go
- add_contact_urn.go
- add_input_labels.go
- base.go
- call_webhook.go
- envelope.go
- remove_contact_groups.go
- send_broadcast.go
- send_email.go
- send_msg.go
- set_contact_channel.go
- set_contact_field.go
- set_contact_language.go
- set_contact_name.go
- set_contact_timezone.go
- set_run_result.go
- start_flow.go
- start_session.go