Quick overview
This scheduled workflow pulls Instagram influencers from Postgres, fetches each creator’s latest post via Unipile, evaluates caption and image relevance with OpenAI, and—when qualified—generates and publishes a like and comment through Unipile while updating the influencer record in Postgres.
How it works
- Runs daily on a schedule.
- Reads Instagram influencer records from a Postgres database and processes them one by one.
- Uses the Unipile API to fetch up to five recent posts per influencer and selects the latest post, skipping creators with no recent post or posts that were already commented on.
- Analyzes the post caption with OpenAI to determine language, category, sentiment, and a relevance score, and analyzes the preview image with OpenAI vision.
- Combines the text and image evaluations and continues only when OpenAI recommends engaging and the creator relevance score is at least 70.
- Generates a 15–30 word professional comment with OpenAI, checks that the post has not already been processed, then likes the post and publishes the comment via the Unipile API.
- Updates the influencer record in Postgres with the post URL, last commented post ID, and timestamp.
Setup
- Add Postgres credentials and ensure your database contains an
_influencer table with the fields used in the workflow (including username, influncrerProviderId, and lastCommentedPostId).
- Add a Unipile API credential (HTTP Header Auth) and replace the hard-coded
account_id values with your own Unipile Instagram account IDs.
- Add OpenAI credentials for both the text-generation models and the vision-capable model used for image analysis.
- Confirm the schedule trigger time (timezone Asia/Kolkata) matches when you want the agent to run.