A sample webtask.io application that receives emails from IFTTT and searches them for tracking numbers and stores them. An aditional two cronjobs can be used to update and send an email when the package arrives.
Several secrets are configurable:
MAIL_USER
- user for authenticationMAIL_PASSWORD
- password for authenticationMAIL_SERVICE
- if using a well known service for nodemailer this sets itMAIL_HOST
- server settingMAIL_PORT
- server settingMAIL_SECURE
- server setting
MAIL_SG_API_KEY
- set the Sendgrid API Key
MAIL_FROM_ADDRESS
- From address to use (alternativelyMAIL_USER
will be used).MAIL_TO
- Where to send the email (alternativelyMAIL_USER
will be used).MAIL_SUBJECT
- Custom subject to use for email being sent.
There are many configuration options. See configCarriers
for details.
To use this webtask:
- Create an IFTTT Gmail (or other provider) applet that makes a "Maker Webhook" POST call and includes the
BodyPlain
ingredient as the body element of a json{"body": "BodyPlain"}
. - Create a cron to update (needs
command=cron-update
) which gets the tracking information from various APIs - Create another cron to send the emails (uses
command=cron-email
)
Tadah! Get notified when packages arrive!
If you need to clear the webtask storage use command=clear
and if you want to see what's in the storage use command=dump
.
Other than the TODOs in the code, there are a few overall tasks left:
- Security: Oh god I really need to review the security model for this, althogh it behaves sufficiently like a black box (should leak nothing useful to anyone that stumbles into it on the wild)
- Cleanup the config code.
- The
cron-update
code saves state too many times. (Possible solutionasync
module) - Now that I think about it, some mail packages get stuck in the initial state for a really long time, date tracking should be added so that old tracking numbers can be automatically deleted.
- Handle errors better.
A ton of stuff is untested because I don't have enough "in transit" packages in varied states.
A short list:
- Most tracking number detection is actually untested, depending on shipit's validation
- Only USPS and Amazon APIs are tested, but the configuration should be straightforward.
- Meta commands (through webtask's CRON) are untested
Some stuff is definitely broken:
- Amazon client in shipit seems to be broken.
- There is a deprecation warning because of sailrish/shipit#32