Overview
This document is intended for developers who want to author and edit Pipedream Actions. After completing this quickstart, you’ll understand how to:- Develop Pipedream components
- Publish private actions and run them through Connect
- Use props to capture user input
- Update an action
- Use npm packages
- Use Pipedream managed auth for a 3rd party app
Prerequisites
- Create a free account at https://pipedream.com
- Download and install the Pipedream CLI
- Once the CLI is installed, link your Pipedream account to the CLI by running
pd loginin your terminal
NOTE: See the CLI reference for detailed usage and examples beyond those covered below.
Walkthrough
We recommend that you complete the examples below in order. hello world! (~5 minutes)- Develop a
hello world!action - Publish it (private to your account) using the Pipedream CLI
- Run it through Connect
- Capture user input using a
stringprop - Publish a new version of your action
- Run the updated action
- Require the
axiosnpm package - Make a simple API request
- Export data returned by the API from your action
- Use Pipedream managed OAuth for GitHub with the
octokitnpm package - Pass a connected GitHub account to the action
- Retrieve details for a repo and return them from the action
hello world!
The following code represents a simple component that can be published as an action (learn more about the component structure). When you run it, it returnshello world!.
.js file (e.g., action.js) and run the following CLI command:
action_demo. The key must be unique across all components in your account (sources and actions). If it’s not unique, the existing component with the matching key will be updated.
The CLI output should look similar to this:
-
Publish the component to your development environment:
-
Run the action with the Connect API or SDKs. Reference your private component with the
~/prefix —~/action_demo— as described in the custom tools docs.
hello world! in the ret field of the response.
We’ll run the action the same way in the rest of the examples as we update it.
hello [name]!
Next, let’s update the component to capture some user input. First, add astring prop called name to the component.
run() function to reference this.name in the return value.
0.0.2. If you fail to update the version, the CLI will throw an error.
pd publish command again to update the action in your account.
action_demo. You should see something like this:
-
Publish the new version with
pd publish action.js --connect-environment development -
Run the action again, passing a value for the new prop in
configuredProps(for example,{ "name": "foo" })
hello foo! (or the value you passed for name) in the ret field of the response.
Use an npm Package
Next, we’ll update the component to get data from the Star Wars API using theaxios npm package. To use the axios package, just import it.
To use most npm packages on Pipedream, just
import or require them — there is no package.json or npm install required.run() method to:
- Make a request to the following endpoint for the Star Wars API:
https://swapi.dev/api/people/1/ - Reference the
namefield of the payload returned by the API
name prop since we’re no longer using it.
0.0.3. If you fail to update the version, the CLI will throw an error.
pd publish command again to update the action in your account.
action_demo. You should see something like this:
hello Luke Skywalker! returned in ret.
Use Managed Auth
For the last example, we’ll use Pipedream managed auth to retrieve and emit data from the GitHub API (which uses OAuth for authentication). First, remove the line that importsaxios and clear the run() function from the last example. Your code should look like this:
octokit npm package
The value for the
app property is the name slug for the app in Pipedream. This is not currently discoverable, but it will be in the near future on app pages in the Pipedream Marketplace. For the time being, if you want to know how to reference an app, please reach out.run() method to get a repo from GitHub and return it. For this example, we’ll pass static values to get the pipedreamhq/pipedream repo. Notice that we’re passing the oauth_access_token in the authorization header by referencing the $auth property of the app prop — this.github.$auth.oauth_access_token. You can discover how to reference auth tokens in the Authentication Strategy section for each app in the Pipedream Marketplace.
$summary (read more about exporting data using $.export).
0.0.4. If you fail to update the version, the CLI will throw an error.
pd publish command again to update the action in your account.
action_demo. You should see something like this:
authProvisionId for a connected GitHub account in configuredProps:
ret field of the response.