How to Automate API Calls for Every New Image Uploaded to Imagekit without Triggers, and Retrieve Full File URL for Use with GPT4V API?

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

I would like to make an API call for every new image that’s uploaded to imagekit. But there are no imagekit triggers. Can you help me think of a way to build this automation? I need to get the full file URL for every uploaded imagekit URL (with the .png extension) so I can feed this to a GPT4V API call

Given that there are no pre-built ImageKit triggers in Pipedream and your requirement to make an API call for every new image uploaded to ImageKit, you can approach this automation by using a generic webhook as a trigger and ImageKit’s webhook functionality to notify your Pipedream workflow of new uploads. Here’s a step-by-step guide to set this up: 1. Create a Pipedream Workflow with a Webhook Trigger: - Go to your Pipedream dashboard and create a new workflow. - Select the HTTP / Webhook trigger. This will provide you with a unique URL that you’ll use to receive notifications from ImageKit. 2. Configure ImageKit to Send Webhooks to Pipedream: - Log in to your ImageKit dashboard and navigate to the Webhooks section. - Create a new webhook and paste the Pipedream webhook URL you obtained in the previous step. - Set the webhook to trigger on the event of a new image upload. 3. Filter for Images with a .png Extension in Pipedream: - After setting up the webhook trigger, add a new Node.js code step to your Pipedream workflow to filter events for images with a .png extension. export default defineComponent({ async run({ steps, $ }) { const imageUrl = steps.trigger.event.url; // Assuming `url` is the key that contains the image URL if (!imageUrl.endsWith('.png')) { $.flow.exit('Ignoring non-png image'); } return { imageUrl }; }, }); 4. Make an API Call to GPT4V API with the Image URL: - Next, add another Node.js code step to make the API call to GPT4V with the filtered image URL. import { axios } from "@pipedream/platform"; export default defineComponent({ async run({ steps, $ }) { const imageUrl = steps.previous_step.imageUrl; // Replace `previous_step` with the actual step ID const response = await axios($, { method: "POST", url: "https://api.gpt4v.example.com/analyze", // Replace with the actual GPT4V API endpoint data: { imageUrl, }, }); return response; }, }); Please replace `"https://api.gpt4v.example.com/

how do I configure the webhook to fire when a new image is uploaded? I’ve created a new webhook in Imagekit using a pipedream webook request URL, but uploading a file doesn’t fire it

To configure a webhook to fire when a new image is uploaded to ImageKit and you’ve already created a new webhook in ImageKit using a Pipedream webhook request URL, but it doesn’t fire upon uploading a file, you might need to ensure a few things are correctly set up: 1. Verify the Webhook URL: Ensure that the webhook URL you’ve provided in ImageKit is correct and is pointing to the Pipedream source designed to catch webhooks. Double-check for any typos or errors in the URL. 2. Check Webhook Configuration in ImageKit: Make sure that the webhook is correctly configured to trigger on the event of a new image upload. There might be specific settings or event types you need to select when setting up the webhook in ImageKit. 3. Inspect Webhook in Pipedream: In Pipedream, ensure that your webhook source is correctly set up to listen for incoming requests. If you’re using a custom workflow to process the webhook, verify that the trigger is correctly configured to listen to the Pipedream webhook URL. 4. Test the Webhook Manually: You can test the webhook manually by sending a test request to the Pipedream webhook URL using tools like curl or Postman. This can help determine if the issue lies with the webhook setup in ImageKit or the handling in Pipedream. 5. Review Logs: Check the logs in both ImageKit and Pipedream. Pipedream should log incoming requests to your webhook URL, which can help you debug if the requests are being received but not processed as expected. 6. Contact Support: If you’ve verified all the above and the webhook still doesn’t fire upon uploading an image, consider reaching out to ImageKit and Pipedream support for further assistance. For Pipedream, you can visit Support - Pipedream for more support options. If you’re looking for a specific code example or further assistance with configuring the webhook in Pipedream, please provide more details about your current setup or the steps you’ve taken so far.