I’m heavily plagiarizing Danny’s beemail about the same, but I thought maybe there are people more likely to use the forum than read a beemail? Plus having this written down somewhere in public is probably good?
We have a baby step towards our meta integration that we’re ready for some beta testers for.
Let’s say you have a weight goal and a weighins goal and you want the weighins goal to automatically get a +1 when you add a datapoint to your weight goal. (We definitely recommend this for beeminding weight, btw.)
Previously you could do that with IFTTT but now you can do it with just Beeminder. ! Just that it’s a little obscure for now, while we figure out the best way to expose this to the hoi polloi.
To spell out the way to use this, assume your username is bob and you have these two goals:
Main goal: http://bmndr.co/bob/weight
Meta goal: http://bmndr.co/bob/weighins
Just go to the Settings tab for your main goal, scroll down to the DATA section, look for the Webhook field, and paste in the URL of your meta goal. That’s it. Now your meta goal will get an automatic +1 when you add data to your main goal.
Technical details
What I did was add a Beeminder API endpoint that is a webhook receiver, so that rather than having to host your own server to receive pushes from that webhook callback, you could just point Beeminder at itself… so when you put http://beeminder.com/bob/weighins
in that field, we’re actually transforming that into the following Beeminder API URL:
https://www.beeminder.com/api/v1/users/bob/webhook.json?goal=weighins&token=TOKEN
We could technically have done this without the new API endpoint, by just changing the validation to allow a Beeminder API URL in that webhook field and then you’d use the API’s datapoints resource as the webhook URL, which is a bit more direct, without adding new API endpoints. But this way we can add features to that webhook receiver in the future, things that would be more like our IFTTT macros, or let you do more things with that pushed data. Anyway.
We also implemented a loop detection step (thanks to @theospears and @poisson and @rperce in the community Discord for helping with that) to the validation on the webhook URL field, so you can’t create obvious infinite loops, having two Beeminder goals (or a cycle of them) pushing data to each other in an infinite loop.
Gotchas
One potential thing with this is that if you have an autodata goal pushing to a meta goal and the autodata goal has plenty of safety buffer but it’s a beemergency on the meta goal, Beeminder is unaware of the urgency on the autodata goal and may not fetch data fast enough. (Normally Beeminder is careful to do a final fetch of autodata before derailing you.) As long as you’re aware of this you can just hit the fetch button on the autodata (main) goal to make sure it’s fresh in time.
(Which probably makes it sound more complicated than it is. It’s really the same principle of “this goal is red, what does it need / where does its data come from? I better make sure that data is the latest data!” And to be clear, there’s no delay between the main goal getting data and the meta goal getting its +1 so this is only an issue for an autodata goal that may be waiting on data from the autodata source and a meta goal waiting on that autodata goal. We’re working on making the main goal aware of the meta beemergency and do more frequent auto-fetches so you can safely think about this potential gotcha even less than this.)