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?
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.
This would make your life easy.
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}")
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.
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).
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.
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