What can I do with Webhooks and how?

I finished the tutorial for Webhooks but now I’m stuck.

  app.post('/page_viewed', addon.authenticate(), function (req, res) {
      console.log("Account ID " + req.body.userAccountId + " viewed page '" +
        req.body.page.title + "' at URL '" + req.body.page.self + "'.");

I now can build a response, right? Maybe I can do something with status codes? Can someone provide an example?

Is it possible to now start interaction with the user like pop a message “Hurray it’s your 100 visit of this page”. ? I’m not sure how I can puzzle that together after all tutorials.

I need a bit start-up assistance.


Routes for webhooks registered via the atlassian-connect.json are automatically generated (at least for the most current version of ACE).
You can create callbacks by listening to the event emitter of the addon object.

addon.on("page_created", async (_event = "page_created", body: PageEvent, req: AuthenticatedRequest) => {

The res object in your example is the socket to the confluence cloud server which notified you that the event has taken place. There you should always return a 200 code to indicate that you have received the notification.
As you can see the res object isn’t event available on the event emitter because there simply is nothing you can reasonably do with it.
Webhooks are more or less unidirectional events notifying your server that a particular action has happened on the instance, it is not a connection to the user session. Therefore, you can not directly interact with the user in the same request.
You could remember a message and the next time this user initiates a connection to your addon you could display some message to him, but pushing a state form within the webhook is not possible.