Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding ifttt notifications #4

Merged
merged 2 commits into from
Nov 18, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions hackjohn.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,27 @@ def get_trailhead_df():
mmb_response = requests.post(mmb_url, json=payload)
print('middleman status code', mmb_response.status_code)
print(mmb_response.text)

## Notifications using IFTTT

# Set enable_ifttt to True to receive IFTTT notification
enable_ifttt = True
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
enable_ifttt = True
enable_ifttt = False

let's default to false since users will have to populate the ifttt fields first

event_name = 'hackjohn'
ifttt_key = 'cJLFuy0CHPBwK0wqndI2g9'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ifttt_key = 'cJLFuy0CHPBwK0wqndI2g9'
ifttt_key = 'replace-with-ifttt-key'

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neuhoffm, do you not think this is a worthwhile change? Is cJL.... a real key or just an example? We will want to do whatever is most clear to let users know that they must replace the value with their key.


# Create you own IFTTT (https://ifttt.com/create)
# Select webhooks for this and select receive a web trigger
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Select webhooks for this and select receive a web trigger
# Select webhooks for this and select "Receive a web request".

for referencem, here are some URLs that the process took me to:

https://ifttt.com/create/connect-maker_webhooks?sid=3
https://ifttt.com/create/if-receive-a-web-request?sid=9
https://ifttt.com/create/if-receive-a-web-request-then-send-a-rich-notification-from-the-ifttt-app?sid=14

# Set event name to match event_name variable above
# Create a that to respond to the event (IFTTT rich notifications allow click to call options to the reservation line.) You can add 3 values (specified below).
neuhoffm marked this conversation as resolved.
Show resolved Hide resolved
# Go to https://ifttt.com/maker_webhooks and click on documentation, copy & paste your key into the ifttt_key variable above

ifttt_hostname = 'https://maker.ifttt.com'
ifttt_url = ifttt_hostname + '/trigger/' + event_name + '/with/key/' + ifttt_key

if enable_ifttt and not space_df.empty and output_has_changed and min_report_date <= report_date:
report = {}
report["value1"] = text
report["value2"] = '209-372-0740'
response = requests.post(ifttt_url, data=report)
print('ifttt status code', response.status_code)
print(response.text)