Documentation ¶
Index ¶
- Constants
- func ActionFromEnvelope(envelope *utils.TypedEnvelope) (flows.Action, error)
- type AddLabelAction
- type AddToGroupAction
- type BaseAction
- type EmailAction
- type PreferredChannelAction
- type RemoveFromGroupAction
- type ReplyAction
- type SaveContactField
- type SaveFlowResultAction
- type SendMsgAction
- type StartFlowAction
- 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 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 of our flow 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)
Types ¶
type AddLabelAction ¶
type AddLabelAction struct { BaseAction Labels []*flows.Label `json:"labels" validate:"dive,min=1"` }
AddLabelAction can be used to add a label to the last incoming message on a flow. An `add_label` event will be created with the msg id and label id when this action is encountered. If there is no incoming msg at that point an error will be output.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "add_label", "labels": [{ "uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "name": "complaint" }] }
```
@disabled_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() error
Validate validates the fields for this label
type AddToGroupAction ¶
type AddToGroupAction struct { BaseAction Groups []*flows.Group `json:"groups" validate:"required,min=1"` }
AddToGroupAction can be used to add a contact to one or more groups. An `add_to_group` event will be created for each group which the contact is 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() error
Validate validates that this action is valid
type BaseAction ¶
type BaseAction struct {
UUID flows.ActionUUID `json:"uuid" validate:"required,uuid4"`
}
BaseAction is our base action type
type EmailAction ¶
type EmailAction struct { BaseAction Emails []string `json:"emails" 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 emails can all contain templates.
A `send_email` event will be created for each email address.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "send_email", "subject": "Here is your activation token", "body": "Your activation token is @contact.fields.activation_token", "emails": ["@contact.urns.email"] }
```
@action send_email
func (*EmailAction) Validate ¶
func (a *EmailAction) Validate() error
Validate validates the fields on this action
type PreferredChannelAction ¶
type PreferredChannelAction struct { BaseAction Name string `json:"name"` ChannelUUID flows.ChannelUUID `json:"channel_uuid"` }
func (*PreferredChannelAction) Type ¶
func (a *PreferredChannelAction) Type() string
func (*PreferredChannelAction) Validate ¶
func (a *PreferredChannelAction) Validate() error
type RemoveFromGroupAction ¶
type RemoveFromGroupAction struct { BaseAction Groups []*flows.Group `json:"groups" validate:"dive"` }
RemoveFromGroupAction can be used to remove a contact from one or more groups. A `remove_from_group` event will be created for each group 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) Type ¶
func (a *RemoveFromGroupAction) Type() string
Type returns the type of this action
func (*RemoveFromGroupAction) Validate ¶
func (a *RemoveFromGroupAction) Validate() error
Validate validates the fields on this action
type ReplyAction ¶
type ReplyAction struct { BaseAction Text string `json:"text" validate:"required"` Attachments []string `json:"attachments"` }
ReplyAction can be used to reply to the current contact in a flow. The text field may contain templates.
A `send_msg` 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": [] }
```
@action reply
func (*ReplyAction) Validate ¶
func (a *ReplyAction) Validate() error
Validate validates whether this struct is correct
type SaveContactField ¶
type SaveContactField struct { BaseAction FieldUUID flows.FieldUUID `json:"field_uuid" validate:"required,uuid4"` FieldName string `json:"field_name" 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 `save_contact_field` event will be created with the corresponding value.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "save_contact_field", "field_uuid": "0cb17b2a-3bfe-4a19-8c99-98ab9561045d", "field_name": "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() error
Validate validates this action
type SaveFlowResultAction ¶
type SaveFlowResultAction struct { BaseAction ResultName string `json:"result_name" validate:"required"` Value string `json:"value"` 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 `save_flow_result` event will be created with the final values.
```
{ "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", "type": "save_flow_result", "result_name": "gender", "value": "m", "category": "Male" }
```
@action save_flow_result
func (*SaveFlowResultAction) Type ¶
func (a *SaveFlowResultAction) Type() string
Type returns the type of this action
func (*SaveFlowResultAction) Validate ¶
func (a *SaveFlowResultAction) Validate() error
Validate validates the fields on this action
type SendMsgAction ¶
type SendMsgAction struct { BaseAction URNs []flows.URN `json:"urns"` Contacts []*flows.ContactReference `json:"contacts" validate:"dive"` Groups []*flows.Group `json:"groups" validate:"dive"` Text string `json:"text"` Attachments []string `json:"attachments"` }
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() error
Validate validates whether this struct is correct
type StartFlowAction ¶
type StartFlowAction struct { BaseAction FlowName string `json:"flow_name" validate:"required"` FlowUUID flows.FlowUUID `json:"flow_uuid" validate:"required,uuid4"` }
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_name": "Collect Language", "flow_uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d" }
```
@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() error
Validate validates our action is valid
type UpdateContactAction ¶
type UpdateContactAction struct { BaseAction FieldName string `json:"field_name" validate:"required,eq=language|eq=name"` Value string `json:"value" validate:"required"` }
UpdateContactAction can be used to update one of the built in fields for a contact of "name" or "language". An `update_contact` 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() error
Validate validates this action
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 the @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() error
Validate validates the fields on this action