External Functions allow you to call webhooks from a Function and use them to interact with external systems. You can call these systems from applications built using Workshop, Actions, and Functions.
To use a webhook in a Function, you must first configure a Data Connection source that supports the webhooks capability. Normally this will be a REST API source. Once you have a source with webhooks configured, you can import the source into your Functions repository and create Functions that call webhooks and other logic.
You can apply external Functions for a variety of use cases, including the following:
External functions may not currently be used to make arbitrary API calls from TypeScript code without first defining the request as a webhook in Data Connection.
@OntologyEditFunction()
decorator.@Query()
decorator.In the following setup guide, we will walk through creating a webhook that calls a free public dictionary API ↗. If you already have an existing source with webhooks configured, proceed to external sources in functions for calling the webhooks from functions.
The dictionary API illustrated here is unaffiliated with Palantir and may change at any time. This tutorial is not an endorsement, recommendation, or suggestion to use this API for production use cases.
To connect to an external system from Functions, you must have a REST API source that can connect to the desired external API. You can follow instructions below to configure a new REST API source.
Review the Overview page, then select Continue in the bottom right. You will be prompted to choose the connection runtime: a direct connection, through an agent, or through an agent proxy. A direct connection is the preferred method when interacting with anything reachable over the Internet, and we will use it to connect to our free dictionary API.
Choose a name for your source, and select a Project to which it should be saved.
Fill out the Domains section with the connection information of the API source. The configuration for our free dictionary API example is shown below:
Now, you must set up the webhook on the REST API source you configured in the previous step. Then, before you can call a webhook from a Function, you must configure the webhook and assign it an API name. A Data Connection source may have multiple webhooks associated with it. Note that your source API name should be unique within a namespace, and the webhook API name must be unique within the source.
Follow the steps below to configure a webhook that makes a request to the dictionary API to fetch the definition of a single word.
wordToDefine
.In our example, the API is a GET request that does not modify any data. Therefore, we will leave the default setting of Read API
, allowing the webhook to be used in both types of Functions: @Query()
and @OntologyEditFunction()
. Webhooks marked with Write API
may only be used in an @OntologyEditFunction()
.
Once the webhook is saved, it is usable across the platform.
Learn more about webhook configuration options and usage..
To begin using this source in a function, proceed to the guide on external sources in functions.