Skip to main content


Hooks are callbacks triggered by external HTTP calls implementing webhooks. Their primary use case is handling incoming data from async processes that depend on external services, such as payment systems and document signatures, instead of user actions.

The URL path associated with each Hook may be changed in its settings on our editor web UI.

Request object

from abstra.hooks import get_request

body, query, headers = get_request()

Function definition

def get_request(local_file=None):


Keyword Arguments
local_file (string)Fallback file location for testing locally


(parsed json or string)Body parsed according to content-type header
(dict)Query parameters

Response object

To send the response object you have to use one of our built-in util functions: send_response or send_json.


from abstra.hooks import send_response

send_response(body="plain text body")
def send_response(body=None, status_code=200, headers=None, local_file=None):
Keyword ArgumentsDescription
body (string)Plain text response body
status_code (number)Http response status code
headers (dict)Headers to be sent back
local_file (string)Fallback file location for testing locally


from abstra.hooks import send_json

send_json(data={'ok': True}, status_code=200, headers={"ABSTRA": "CLOUD"})
def send_json(data=None, status_code=200, headers=None, local_file=None):
Keyword ArgumentsDescription
data (any serializable value)Data to be serialized and sent back
status_code (number)Http response status code
headers (dict)Headers to be sent back, in addition to content-type: application/json
local_file (string)Fallback file location for testing locally

Hooks in a Workflow

Every Hook that depends on previous stages in a Workflow must use the match_thread function. This is how the Hook matches the incoming information to a thread waiting in that Stage.

Consider a Workflow for contract signature with four stages:

  1. Fill Contract - filling the necessary information with a Form
  2. Send Contract - generating the document and sending it to/Users/ybere/Desktop/abstracloud/docusaurus/docs/hooks/ the client
  3. Await Signature - awaiting for the document to be sent back
  4. Send Confirmation - notifying the people involved that the process has been completed

Contract Signing

After the Fill Contract and Send Contract stages, threads stay waiting in the Await Signature stage until the Hook acknowledges a contract has been signed to resume the process. To do so, use the match_thread function.


def match_thread(filter=dict):
Keyword ArgumentsDescription
filter (dict)Data to match a thread to be resumed


The match_thread function finds a corresponding waiting thread in the current stage by searching for pieces of data already set in previous stages.

from abstra.workflows import match_thread
from abstra.hooks import get_request, send_json

body, query, headers = get_request()

filter = {
"contractId": body["contract_id"],
"clientId": body["client_id"]

send_json(data={'ok': True}, status_code=200)

print(f"Unable to find an corresponding contract")
send_json(data={'ok': False}, status_code=404)

The filter must be an object with only primitive types as values. For the thread to be matched, all keys in filter must be set with the corresponding values in previous stages using the set_data function.


If no thread is found, an error will be thrown. If more than one thread is found, one of them will be randomly selected.

To avoid dubious side effects, try to use values that are unique across all threads.