Prompt Fields
Sym Flows can be configured to include custom input fields.
This page is deprecated!
The information here is no longer accurate as of version 2.0.0 of the Terraform Sym Provider.
Please see upgrade to a newer version and refer to the Provider Documentation for the latest information.
Overview
Sym workflows support custom input fields so you can collect variable information from a user who's requesting access to a resource, and then use it in the SDK.
Prompt Fields are used in two ways:
- For Flows invoked in Slack, they define input fields to be displayed in the request modal.
- For Flows invoked by API, they define the structure of the
flow_inputs
block in the body of the request.
Configuring Prompt Fields
Prompt Fields are defined as part of a Flow's Params using the prompt_fields_json
attribute. This attribute collects all your fields as a jsonencoded string so they can be rendered at runtime.
The prompt_fields_json
attribute must be provided via Terraform as a jsonencoded list. Each item in the list must be a map, containing the following items:
name
(required string) - a unique identifier for the fieldtype
(required string) - the field type (one of "string", "int", "bool", "duration")required
(optional boolean, defaults to True) - whether this field is a required inputlabel
(optional string) - a non-unique name for the field, to be displayed in Slackdefault
(optional string) - a fallback value for optional fields if no value is providedallowed_values
(optional string list) - defines the full list of valid choices for this field's value (changes field display in Slack to a dropdown)
For more information on the special "duration" field type, see Access Duration.
Example
resource "sym_flow" "example" {
...
params = {
...
prompt_fields_json = jsonencode(
[
{
name = "reason"
type = "string"
required = true
},
{
name = "urgency"
type = "string"
allowed_values = ["low", "medium", "high", "emergency"]
required = true
}
]
)
}
}
Accessing Prompt Fields in the SDK
Any fields defined in prompt_fields_json
can be accessed and used in the SDK via the event.payload.fields
dictionary, as with other field data.
Example
@hook
def on_request(event):
urgency = event.payload.fields["urgency"]
# Auto-approve requests in emergencies.
if urgency == "emergency":
return ApprovalTemplate.approve()
Updated 14 days ago