Home

Coding Input Prompt Operations

An input prompt operation is optionally used when you would like to explicitly provide a Block Kit input to the user instead of a plain text box.

For example, if you'd like the user to provide input by selecting an option from a dropdown, you would use the input prompt operation to build and return that dropdown.

The schema for the return value of the input prompt operation is as follows:

    return {
"inputs": {
"page_id": {"blockKitOverride": <a single block kit block>},
"page_status": {"blockKitOverride": <a single block kit block>}
}
}

where "page_id" and "page_status" are names of parameters defined in this action's execute operation.

You can also add parameters to the input prompt, if they are needed to construct your input. For example, adding a parameter for a Jira project key, if you're planning on showing a dropdown of Jiras.

If you do not need to explicitly provide a Block Kit input, you can simply add parameters to the action's execute operation and an input field will be auto-generated for the end user.

Error handling in input prompt operations#

If you've detected an invalid input or otherwise need to prevent the user from running the action's execute operation, you can return an error block like so:

    return {"error": {"blockKitOverride": <a single block kit block>}}

Here's a helper function you can copy-and-paste into the bottom of your input prompt operation to return errors:

def make_error(error_message):    
error_block = api.run("block_kit_lib.markdown_text_section",
{"text": error_message})[0]
return {
"error": {"blockKitOverride": error_block}
}

Use the Block Kit library to make it easier to form Slack Block Kit UI. You will need to add it as a connector in your action application. Under Code > Data connectors, search for Slack Block Kit. Select the "-- None --" operation and save. The Block Kit library docs also have examples you can use. Make sure to only copy single block objects to use in your return object.

If the Block Kit JSON is not valid, it will fail silently.