I have a Notion database that stores information about different tasks. For reference, my Notion database looks like this: Task name (Text), Status (Status), Assignee (Person), Due (Date), Priority (Select), Summary (Text), Explain What You Did (Text), Status Text (Formula), Overdue (Formula), Days Left (Formula). I want to use Notion to automatically send a message to Discord whenever the status of a task changes. For example, if a task goes from “Not started” to “In progress”, I want to notify my team on Discord.
To do this, I used Zaps, and this is how I set up my workflow:
- The first step is a Notion trigger, which runs whenever the “Updated Database idem” condition is met.
- The second step is a “Code by Zapier” action, which uses Python to check if the status of the task has changed. It compares the current status with the previous status, and returns True or False accordingly. Here is the code that I use:
Input: Status Text → Properties Status Text String: Not started
Code:# Define a function to check if the "Status (Text)" column values have changed
def check_status_change(input_data):
# Get the current "Status (Text)" value from the input data
current_status = input_datat"Status (Text)"]
# Get the previous "Status (Text)" value from the previous input data
# If the previous input data is not available, default to "Not started"
previous_status = (
input_data.get("previous_step.Status (Text)") or "Not started"
)
# Check if the current "Status (Text)" value is different from the previous value
if current_status != previous_status:
# If the values are different, return True to indicate a change
return True
else:
# If the values are the same, return False to indicate no change
return False
# Call the function with the input data
status_changed = check_status_change(input_data)
# Print the result to the console
print(status_changed)
# Store the result in a dictionary for output
output = {"status_changed": status_changed} - The third step is a “Filter by Zapier” action, I set it to only continue if the status_changed output from the previous step is True.
- The fourth and final step is a Discord action, which sends a message to a specific channel in Discord. The message contains the name and status of the task that has changed.
This is how I set up my Zapier workflow to automate the communication between Notion and Discord. However, I have a problem. The Discord action runs even when I don’t change the status of a task. For example, if I edit the Summary field of a task in Notion, it still sends a message to Discord. I don’t want this to happen. I want the Discord action to run if and only if the variable(s) in the Status Text field change. How can I fix this?