How to Correctly Set up Pipedream Workflows for a Paid Figma Plugin and Troubleshoot Railway Database Connection Issues?

This topic was automatically generated from Slack. You can find the original thread here.

hey team, I’m bk. used pipedream around a year ago for a simple form. I’m starting to make some apps and want to learn automations quickly. Building some automations around a paid figma plugin. let me know if I got my logic correct.

  1. workflow 1 : upon plugin startup, hit a /verify GET request to check if user has an account in a postgres db, based on email. if not start a 7 day trial.
  2. workflow 2 : if they are on trial or out of trial, present them with a subscribe link to a stripe payment link.
  3. workflow 3: watch for a stripe webhook to update payment status in db (match email to figma account)
    open ques: do I need to provide an activation license?
    also I’m trying to connect my railway db and running into issues. using railway for the first time as well.

can you help with these questions?

hey team, I’m bk. used pipedream around a year ago for a simple form. I’m starting to make some apps and want to learn automations quickly. Building some automations around a paid figma plugin. let me know if I got my logic correct.

  1. workflow 1 : upon plugin startup, hit a /verify GET request to check if user has an account in a postgres db, based on email. if not start a 7 day trial.
  2. workflow 2 : if they are on trial or out of trial, present them with a subscribe link to a stripe payment link.
  3. workflow 3: watch for a stripe webhook to update payment status in db (match email to figma account)
    open ques: do I need to provide an activation license?
    also I’m trying to connect my railway db and running into issues. using railway for the first time as well.

Hey BK, I’d be happy to help you with your questions and workflows. Let’s break down each workflow and address your open questions. ### Workflow 1: Verify User and Start Trial 1. Trigger: Plugin startup. 2. Action: Make a GET request to your PostgreSQL database to check if the user exists based on their email. 3. Action: If the user does not exist, start a 7-day trial. Here’s a basic structure for this workflow: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { postgres: { type: "app", app: "postgres", }, email: { type: "string", label: "User Email", }, }, async run({ steps, $ }) { const query = `SELECT ** FROM users WHERE email = $1`; const result = await axios($, { method: "POST", url: `${this.postgres.$auth.host}/query`, headers: { Authorization: `Bearer ${this.postgres.$auth.api_key}`, }, data: { query, params: [this.email], }, }); if (result.data.length === 0) { // Start 7-day trial logic here // Example: Insert user into the database with trial status const insertQuery = `INSERT INTO users (email, status, trial_end_date) VALUES ($1, 'trial', NOW() + INTERVAL '7 days')`; await axios($, { method: "POST", url: `${this.postgres.$auth.host}/query`, headers: { Authorization: `Bearer ${this.postgres.$auth.api_key}`, }, data: { query: insertQuery, params: [this.email], }, }); } return result.data; }, }); ### Workflow 2: Present Subscribe Link 1. Trigger: User is on trial or out of trial. 2. *Action: Present a subscribe link to a Stripe payment link. Here’s a basic structure for this workflow: ``` import { axios } from “@pipedream/platform”; export default defineComponent({ props: { stripe: { type: “app”, app: “stripe”, }, email: { type: “string”, label

, they’re asking if the workflows 1, 2 and 3 logic makes sense

To provide a meaningful answer, I need more context about the specific logic of workflows 1, 2, and 3. Could you please describe the triggers and actions involved in each workflow? This will help me understand the overall logic and determine if it makes sense. Here are some questions to guide you: 1. Workflow 1: - What is the trigger for this workflow? - What actions or code steps are included in this workflow? 2. Workflow 2: - What is the trigger for this workflow? - What actions or code steps are included in this workflow? 3. Workflow 3: - What is the trigger for this workflow? - What actions or code steps are included in this workflow? With this information, I can better assess the logic of your workflows and provide more accurate feedback.

this is the context:

  1. workflow 1 : upon plugin startup, hit a /verify GET request to check if user has an account in a postgres db, based on email. if not start a 7 day trial.
  2. workflow 2 : if they are on trial or out of trial, present them with a subscribe link to a stripe payment link.
  3. workflow 3: watch for a stripe webhook to update payment status in db (match email to figma account)

To achieve the workflows described, you’ll need to set up three separate workflows in Pipedream. Below are the detailed steps and code snippets for each workflow: ### Workflow 1: Verify User and Start Trial 1. Trigger: HTTP request 2. Action: Check user in PostgreSQL and start trial if not found import { axios } from "@pipedream/platform"; import { Client } from "pg"; export default defineComponent({ props: { email: { type: "string", label: "User Email", }, pg: { type: "app", app: "postgres", }, }, async run({ steps, $ }) { const client = new Client({ connectionString: this.pg.$auth.connection_string, }); await client.connect(); const res = await client.query("SELECT ** FROM users WHERE email = $1", [this.email]); if (res.rows.length === 0) { // User not found, start a 7-day trial await client.query("INSERT INTO users (email, trial_start) VALUES ($1, NOW())", [this.email]); return { message: "Trial started for user" }; } else { return { message: "User already exists" }; } }, }); ### Workflow 2: Present Subscribe Link 1. Trigger: HTTP request or Scheduler (depending on your needs) 2. Action: Check trial status and present Stripe payment link ``` import { axios } from “@pipedream/platform”; import { Client } from “pg”; export default defineComponent({ props: { email: { type: “string”, label: “User Email”, }, pg: { type: “app”, app: “postgres”, }, stripe: { type: “app”, app: “stripe”, }, }, async run({ steps, $ }) { const client = new Client({ connectionString: this.pg.$auth.connection_string, }); await client.connect(); const res = await client.query(“SELECT ** FROM users WHERE email = $1”, [this.email]); if (res.rows.length > 0) { const user = res.rows[0]; const trialEnd = new Date(user.trial_start); trialEnd.setDate(tr

did you provide the SSL CA Bundle, SSL Private Key, and SSL Client Certificate when connecting your PostgreSQL connection?

nope. I don’t know much about dbs but I did not configure this stuff. I found this on the railway discord comms. the postgres databases railway deploys for you have self signed certificates, if that's not something power bi supports then you might not be able to use it

can you help?

You’ll need to set SSL Verification Mode with your Postgresql to Skip Verification , as that is the only mode that would work with self-signed certificates.

Yep, seems to connect so going to give this a stab and see how far I get. ty!

I’m a bit lost. I checked if this user exists, if user does not exist in db, we want to create a db entry with the fid and start trial with todays’ date and return a 200. if user can’t be added to a db, we return a 422.

I also want the webhook to be webhookurl/check-trail vs just a /.

Hi , could you file a support ticket at Support - Pipedream so we can take a look at your workflow?

I think this is a generic question, I don’t really know how to check a db for a value and perform a diff action and send a diff request based on the value? I heard branching is coming soon but how do ppl handle this today? I’ve watched tons of youtube but still can’t figure it out. Also, don’t have a paid account so can’t file support. Which I don’t want to get if I have 0 customers. lol.

Oh, it just means that users in the Advanced plan have priority support. You should be able to send a support ticket there

Regarding your question, I don’t understand it fully. I think I would benefit from your workflow context.

But regarding the if/else generic pattern, you need a custom code step to do that. You are correct that the builder does not support branching yet (will soon)