How to Fetch All Triggers Available for a Specific App in Salesforce Using Connect API?

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

Hi there! Most likely a stupid question, but I can’t seem to figure it out/find in the docs. I’m using the connect api, I have salesforce connected for an external user.
Now I’d like to set up some triggers, for this, I need to show to the user the list of possible triggers like in PD platform (screenshot). How can i fetch all the triggers (or sources as they are technically called) available for a specific app?
This doesn’t seem to work and just returns an empty array:

export const getTriggersPerApp = async (appSlug: string) => {
  return pipedreamBEClient.components.list({
    app: appSlug,
  });
};

This returns a few, but not all of them:

const accessToken = await pipedreamBEClient.rawAccessToken;

  const data = await fetch(
    `https://api.pipedream.com/v1/components/search?query=${appSlug}&type=source`,
    {
      headers: {
        Authorization: `Bearer ${accessToken}`,
      },
    }
  );

  return data.json();

Any help/docs pointer is appreciated. Thanks!

Hm this is working for me

import { PipedreamClient } from "@pipedream/sdk";

const client = new PipedreamClient({
  clientId: process.env.PIPEDREAM_CLIENT_ID,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET,
  projectEnvironment: process.env.PIPEDREAM_ENVIRONMENT,
  projectId: process.env.PIPEDREAM_PROJECT_ID
});

// returns just triggers for Slack

const response = await client.triggers.list({
  app: "slack",
});

As is this

// returns both triggers and actions for Slack

const response = await client.components.list({
  app: "slack",
});

~hm… SDK version issue? But you seem to be using latest as well…~
~Just to make sure i copy pasted what you shared above exactly:~

export const getTriggersPerApp = async (appSlug: string) => {
  await authorizeClientAdmin();

  const client = new PipedreamClient({
    clientId: process.env.PIPEDREAM_CLIENT_ID!,
    clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
    projectId: process.env.PIPEDREAM_PROJECT_ID!,
    projectEnvironment: "production",
  });

  return client.triggers.list({
    app: "slack",
  });
};

~Still nothing, just an empty object~

Found the problem, which is not on the PD side necessarily. The full response object is not serializable, so cannot be returned from the nextjs server action, only the respose.data can be
So what i had before didn’t work, but this does:

export const getTriggersPerApp = async (appSlug: string) => {
  await authorizeClientAdmin();

  const triggers = await pipedreamBEClient.triggers.list({
    app: appSlug,
  });

  return triggers.data;
};

thanks for help, led me to dig in the different direction :slightly_smiling_face: