If the built-in Action connectors don't meet your needs then you can use one of the Custom Actions for greater control over how Clause responds to obligations that are emitted by your contracts.

Custom Actions allow you to use dynamic values in your integration. For example, the message sent to an interested party via email could include the value of a payment as computed by the Smart Clause®.

Currently, your custom action will need to also include any secrets or API keys that are required to perform the integration.

To configure a Custom Action:

  1. Select + Add Additional Action from the Smart Clause configuration panel.
  2. Choose Custom as the Action Type
  3. Select your Target from the drop-down menu
  4. Provide a transform object in the Transform field.

The Transform should be provided in the JSONata format. This format allows you to write expressions that will be evaluated at runtime to build the output object based on values in the Smart Clause emitted events object.

Note that in the future you will be able to create default transformations graphically and will not need to understand JSON or JSONata.

The online JSONata test tool is great for testing your transformation before using it in Clause. 

How the transform works

The transform can access the raw obligation object that causes this Action to be processed (the event object).

Let's look at an example to understand how this works.

In this scenario we use the Fragile Goods sample to send messages to Slack broadcasting the payments due for each completed delivery.

Note that sample response and event objects for each of the Accord Project templates is available in the Accord Project template library.

Triggering a fragile goods clause will emit the following payment obligation, we call this the event.

    "$class": "org.accordproject.cicero.runtime.PaymentObligation",
    "amount": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 186.02,
        "currencyCode": "USD"
    "description": "penalty payment owed by Dan to Steve for delivery of fragile goods, including delays",
    "promisor": "resource:org.accordproject.cicero.contract.AccordParty#Dan",
    "promisee": "resource:org.accordproject.cicero.contract.AccordParty#Steve",
    "eventId": "valid",
    "timestamp": "2018-09-23T16:09:18.649Z"

In order to allow Clause to perform a Slack notification we need to transform this object into a io.clause.outbound.physical.alerts.atticus.AtticusSlackMessage.

This integration model expects a JSON object that looks like:

    "$class": "io.clause.outbound.physical.alerts.atticus.AtticusSlackMessage",
    "url": "MY_SLACK_WEBHOOK_URL",
    "message": "MY_MESSAGE"
You can create a Slack Webhook by following the instructions at https://api.slack.com/incoming-webhooks

The following JSONata transform achieves the required transformation. See the JSONata docs for further guidance on how to construct your transform.

    "$class": "io.clause.outbound.physical.alerts.atticus.AtticusSlackMessage",
    "url": "https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYY/ZZZZZZZZZZZZZZZZZZZZZZ",
    "message":"*Fragile Goods Payout*\n" & event.amount.doubleValue & " " & event.amount.currencyCode

Sample Transformations

To help you to get started here are some sample connection configurations that you can copy into Clause.

  1. HTTP Action
  2. Zapier via HTTP Action
  3. Stripe Action
  4. Ether Transfer Action
  5. Ethereum Transaction Action
  6. MQTT Publish Action 
  7. Email Action