Connect Express: How to redirect to a new page or at least emit messages to users from a Webhook

104 views
Skip to first unread message

Michael

unread,
Sep 9, 2014, 5:33:50 AM9/9/14
to atlassian-...@googlegroups.com
Hi,

I'm using Connect Express together with Confluence. I want to redirect the user to another page in certain situations when a new page is created in Confluence. I implemented the "page_created" webhook for this:

 "modules": {
        "webhooks": [
              {
                "event": "page_created",
                "url": "/page-created"
              }
        ],


// handler
app.post('/page-created', addon.authenticate(), function(req, res) {
  // redirect or emit message to user
  // req.redirect does not work here...
  // or how can I emit messages to users from here?
}


Is there any chance to redirect the user in the "/page-created" webhook handler to another page? As I actually expected, req.redirect(url) does not work because I guess it is in the nature of how Webhooks work. But nevertheless, could you think of a possible solution for this scenario?

In case this is not possible, is there at least a way to emit messages to users in a webhook handler? I want to inform users that they can go to a specific URL in this case.


Thanks,
Michael

Travis Smith

unread,
Sep 9, 2014, 1:12:00 PM9/9/14
to atlassian-...@googlegroups.com
Michael, 

Webhooks are async; you cannot interact with the user in any way during a webhook event.

At this point, I'd suggest opening a feature request where you could provide a popup to the user. In theory this is something we could support, opening up a message/notification from a API REST request, but it would require this to be implemented in the products before it could be surfaced in Connect. 

Cheers, 

--
You received this message because you are subscribed to the Google Groups "Atlassian Connect Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connec...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-Travis

Michael

unread,
Sep 9, 2014, 1:35:57 PM9/9/14
to atlassian-...@googlegroups.com
Hi Travis,

Thank you for your response. I can see why this is not possible with webhooks, but I have seen examples where people used Sockets.IO (http://socket.io/docs/) to emit and receive custom messages. Might this be a reasonable way to send a message from a webhook to a Javascript function on the client which then could use AP.messages to show it to the user? Do you have any experiences with this?

Thanks,
Michael
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connect-dev+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
-Travis

Travis Smith

unread,
Sep 9, 2014, 1:54:12 PM9/9/14
to atlassian-...@googlegroups.com
Michael, 

I'm not as familiar with all the integration points in JIRA - but in theory you could have an invisible component loaded in each page that connects back to a socket.io server of your own. This is totally a reasonable way to handle this needed. I have worked similar solutions before, but not with Atlassian Connect. 

I'm not sure without some digging if you can do that in Confluence effectively. There is an activity tracking add-on we use internally that Sam Day wrote that does something sorta similar to do this. So off the cuff I would assume you could at least come close to what you want. 

Cheers,

To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connec...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
-Travis

Peter Brownlow

unread,
Sep 9, 2014, 5:10:42 PM9/9/14
to atlassian-...@googlegroups.com
That is indeed a totally reasonable solution. The Atlassian Confluence Stats add-on that Sam Day wrote does this - it shows an inline dialog which contains an iframe which has some javascript that uses web sockets to receive live updates. (Unfortunately this add-on is not yet public in marketplace.atlassian.com, but we use it internally and the live updates via sockets work nicely.)

I've also done this inside JIRA in the https://marketplace.atlassian.com/plugins/jira-hipchat-discussions-connect add-on (when you are viewing a ticket and someone else viewing the same ticket opens or closes the chat it also opens or closes for you).

The one restriction is that you will need an iframe running your javascript to do this. That means a web panel, dialog, inline dialog, dynamic macro or page.

You also need to make your code handle sockets disappearing a lot (because users close their tabs or disconnect from the internet while the socket is open) but it's not a big deal.

-Peter
Reply all
Reply to author
Forward
0 new messages