This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.
Closed

Auto-create webhook

RuudBurgerRuudBurger Member
edited February 2016 in Archive
I would like the webhooks to be more integrated in the app. Now you have to send a user to a different site, let him manually create a webhook, copy the values and post those back in your app settings (taking the ifttt code as an example). This feels off to me.
I would be much nicer to integrate webhook in you app settings panel by just doing:
permissions": [
    "homey:cloud:webhooks"
]

in your `app.json for example.

Then all the register, unregister and other code related to managing the webhook can be removed from your app. But also, the user doesn't have to leave the settings screen of the app, as the webhook has been automatically created.

On the settings html page you can display the list of webhooks just like on webhooks.athom.com, but just the hooks for your app.
And in the app we can have new functions to get these hooks:

 Homey.manager( 'cloud' ).getWebhooks // List of all webhooks
 Homey.manager( 'cloud' ).on('trigger.webhook', function(id, data) ) // Incoming call to webhook url
 Homey.manager( 'cloud' ).on('webhook.ID_OF_THE_WEBHOOK', function(data) )
 Homey.manager( 'cloud' ).on('webhook.add', function(id) )
 Homey.manager( 'cloud' ).on('webhook.delete', function(id))


or something like that.

The integration with this would be much cleaner and easier for developers. As every developer doesn't have to create and manage their own webhook flow/html/javascript/app.js.
And as an extra, because it all automated, I can send the url, id and secret as a call (in a custom function in app.js) to my external app, so the user doesn't have to manually copy/paste the webhook properties (POST http://myexternalapp.com/api/register_webhook) of course after a confirmation of the user.


Comments

  • EmileEmile Administrator, Athom
    The things is, you need a secret anyway, and also some server-side code to compare the incoming value against..
  • RuudBurgerRuudBurger Member
    edited February 2016
    But that check can already be done in Homey.manager( 'cloud' ).on('trigger.webhook') so it only comes through when the secret is valid.
    And on my external app side, I can register the url and secret when homey creates a webhook using Homey.manager( 'cloud' ).on('webhook.add', function(id)) including the secret.
This discussion has been closed.