Actions
Actions are the steps that your workflow takes to reach its overall goal, making them key to the running of a workflow. They make your workflow unique and suited to your specific use case.
You can mix and match actions from the available actions list to create different types of flows. These actions enable you to receive, send or create verifiable credentials. Also, there are actions to enable external interaction.
Category | Action | Version | Description |
---|---|---|---|
Connections | createInvitation | v1 | Create a connection invitation, encoded as URL. |
receiveInvitation | v1 | Receive a connection invitation, encoded as URL. | |
createConnection | v1 | Create a connection invitation, encoded as URL, and wait for the connection to be completed. Can only be used for single use invitations. | |
Credential Templates | createSchema | v1 | Create a credential schema with attributes, and register it on the ledger. |
createCredentialDefinition | v1 | Create a credential definition and register it on the ledger. | |
Issue Credentials | issueCredential | v1 | Issue a credential to a connection. |
createCredentialIssuanceInvitation | v1 | Issue a credential directly with an invitation. | |
Presentations | requestPresentation | v1 | Request a presentation from a connection. |
createPresentationInvitation | v1 | Request a presentation with an invitation. | |
Messaging | sendBasicMessage | v1 | Send a simple message to another connection. |
Validate Json | validateJson | v1 | Validate a JSON structure against a schema. |
External Actions | fetch | v1 | Call an external API. |
The following example consists of two actions - the workflow receives an invitation and sends two basic messages:
actions:
- id: receiveInvitation
name: didcomm/receiveInvitation@v1
attributes:
invitationUrl: $.input.invitationUrl
- id: issueDOBCredential
name: didcomm/issueCredential@v1
attributes:
connectionId: $.actions.receiveInvitation.output.connection.connectionId
anoncreds:
# from credential definition action
credentialDefinitionId: 'did:cheqd:mainnet:d76283f5-943f-4f4b-b5ae-9bd6794b6dcf/resources/9703ceb3-cda2-4315-8f7e-ebceaf351aa7'
attributes:
name: 'Alice'
dateOfBirth: 19901010
The output of a previous action can be used in other actions by referencing its output object through $.actions.<action name>.output.<key>
. From the previous example, the output of the action connectionId
can be referenced as $.actions.receiveInvitation.output.connectionId
.
Working with Actions
Format
Actions are written in YAML and are formatted in this way:
actions:
- id: actionId
name: actionType/actionName@v<version>
attributes:
input: inputValue
Parameter | Type | Description | Required | |
---|---|---|---|---|
id | string | Custom reference name for the action | ✅ | |
name | string | Action name | ✅ | |
attributes | object | Attributes of action. | ✅ | |
[USER_DEFINED] | [USER_DEFINED] | Input dependant on specific action. | ✅ |
The specifics of the action you're working with mostly take place in the attributes key. That's where unique elements of the different types of actions are defined.
The custom ID of an action should be unique and easy to reference (e.g. no spaces). It is used to refer to that specific action when retrieving output. This becomes especially important when a workflow has multiple actions of the same type (eg. create multiple schemas or issue multiple credentials).
Input values
The input of your workflow can be used to pass values to your defined actions. Values can be referenced using JSONPath (opens in a new tab) syntax. You can also hardcode values into your workflow:
name: Workflow X
input:
type: 'object'
properties:
inputValue:
type: string
actions:
- id: action1
name: actionType/actionName@v1
attributes:
input1: $.input.inputValue
input2: 'hardcoded_value'
The tutorials are a good place to see this in action, like in How to Issue an Employee Badge.
Results
Results of previous actions can be referenced by using the output object of the action:
actions:
- id: action1
name: actionType/actionName@v1
attributes:
input: inputValue
- id: action2
name: actionType/actionName@v1
attributes:
input: $.actions.action1.output.value
Versioning
Each action has a version. The version of the action is specified by appending a @v<version>
to the end of the action name <action name>@v<version>
. The documentation of each action lists the differences between versions of an action and its current version.
actions:
- id: action1@v1
name: actionType/actionName@v1
attributes:
input: inputValue
- id: action2v2
name: actionType/actionName@v1
attributes:
input: $.actions.action1.output.value