JSON changes as the trigger for job ads

Hi! I have the JSON API, approx. 8000 records with details of job ads like title, company name or date when it was created. I would like to make a scenario that when simply there is new job posted in JSON, I am getting the message on Telegram. I managed the second part but the trigger is still problematic for me. I was trying with first making a http request with Basic Authorization in headers then to search for rows where the date in column “created At” was later or equal to now and it was triggered every 15 minutes but still, it was not triggered when there was a new record in JSON and when there was no new job ad, every 15 minutes it was sending me the same job ads.

So do you have any solution to make a scenario where JSON changes act as the trigger for next steps and I will be able to get details of the job ad where changes in column createdAt where made? :smile:

I think your first solution could work.
Can you post your sceanrio here? Maybe the filter was not quite correct.

What do you mean with “the JSON API”?
Some software have the option to add webhooks to events and make.com has the option to create an Webhook endpoint.
image
This would make your life easy.

1 Like

I think there is a problem with establishing connection JSON to Webhook. With the assistance of ChatGPT, I have tried to do it through this Python script:

import requests
import time

# URL address of your API
api_url = "https://api.mysite.pl/records/active"

# Authorization for your API
headers = {
    "Authorization": "Basic tokentokentoken"
}

# Webhook URL address in Integromat
webhook_url = "https://hook.eu2.make.com/mywebhookfrommake"

try:
    # Fetch data from your API using the provided authorization
    response = requests.get(api_url, headers=headers)

    # Check if the request was successful
    if response.status_code == 200:
        # Parse JSON data from the response
        all_records = response.json()

        # Sort the data based on the publication date (in ascending order)
        sorted_records = sorted(all_records, key=lambda x: x["publishedAt"])

        # Select only the earliest added record (first in the sorted list)
        earliest_record = sorted_records[0]

        # Send a POST request with the data of the earliest record to the webhook
        post_response = requests.post(webhook_url, json=earliest_record)

        # Check if the POST request was successful
        if post_response.status_code == 200:
            print("POST request was successful.")
        else:
            print(f"Error while sending POST request: {post_response.status_code} - {post_response.text}")

    else:
        print(f"Error while fetching data from your API: {response.status_code} - {response.text}")

except requests.exceptions.RequestException as e:
    print(f"An error occurred while executing the request: {e}")

And I have tried to do it through this scenario:

I have started it and I was waiting, and waiting, and waiting :smiley: Nothing happend.

The scenario in make.com looks good. If you don’t get a webhook response it’s not a make.com problem anymore.
I can’t really help you with the srcipt. On first glance it looks like it could work, but I don’t know how your Sofware/database looks.

2 Likes

Well yeah, that’s what I thought about the scenario. The data structure looks like this:

{
	"slug": "171304",
	"title": "Facebook and Google Ads Specialist",
	"requiredSkills": [
		"Google Analytics",
		"Facebook Ads"
	],
	"Type": "remote",
	"Time": "full_time",
	"publishedAt": "2023-07-23T14:00:15.656Z",
}

And there are approx. 9 000 records.

If we go back and try filter it out. It could look something like this:

  1. Input to JSON for testing purpose
  2. Setup time Filter for new items.
    image
    After you run it every 15 minutes and you should get only the new ones.

Here the Blueprint to it:
blueprint (22).json (10.9 KB)

3 Likes

Thanks, @Levin, for help! It turned out that due to our server has a different time zone than our website (two hours difference), what helped me was making a simple HTTP request every hour and making a filter on publishedAt Datetime operators: Later or equal to addMinutes(now;60).

1 Like

Heya @artur :wave:

I just wanted to quickly jump in and say thank you for sharing what did the trick for you. Great to see that you were able to figure this out on your own. :muscle:

FYI I marked your reply as a solution for any folks searching for similar info in the future. This way, they’ll know where to look and the community will stay neat and tidy :broom:

Keep up the great work :seedling: