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.
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.
workflow 2 : if they are on trial or out of trial, present them with a subscribe link to a stripe payment link.
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 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.
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.
workflow 2 : if they are on trial or out of trial, present them with a subscribe link to a stripe payment link.
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
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.
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.
workflow 2 : if they are on trial or out of trial, present them with a subscribe link to a stripe payment link.
workflow 3: watch for a stripe webhook to update payment status in db (match email to figma account)
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
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.
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 /.
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.
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)