Closed anna-geller closed 4 months ago
I would add to this that it seems that Kestra doesn't give back the whole body: in the Slack documentation they show an example with Python:
slack_signing_secret = 'MY_SLACK_SIGNING_SECRET' // Set this as an environment variable
>>> 8f742231b10e8888abcd99yyyzzz85a5
request_body = request.body()
>>> token=xyzz0WbapA4vBCDEFasx0q6G&team_id=T1DC2JH3J&team_domain=testteamnow&channel_id=G8PSS9T3V&channel_name=foobar&user_id=U2CERLKJA&user_name=roadrunner&command=%2Fwebhook-collect&text=&response_url=https%3A%2F%2Fhooks.slack.com%2Fcommands%2FT1DC2JH3J%2F397700885554%2F96rGlfmibIGlgcZRskXaIFfN&trigger_id=398738663015.47445629121.803a0bc887a14d10d2c447fce8b6703c
👉 we can see a response_url
that is not exposed by Kestra trigger.body
(see issue description above) 🤔
More generally speaking: this feature can be generalized to any server to server handshake where one HTTP call expect a specific response.
In that sense, the last addition of outputs
properties in flow/subflow coupled with http.Trigger/webhook is the way to go: let people customize HTTP response from flow triggered by webhook/http.Trigger
cc @anna-geller @Skraye
I've made a quick Loom to show how I can handle Slack events with a small Python API (handling POST request); let me know if it helps; happy to give feedback if needed :)
https://www.loom.com/share/289c4c40623b458cae2182b51ac236fd?sid=ca489edd-6922-4dde-b142-839f4b3d6a44
TL;DR; What would be lovely: allow users to set custom body for the webhook response 🙏
In my case I would love to see something like:
id: slack-event
namespace: dev
tasks:
- id: hello
type: io.kestra.core.tasks.log.Log
message: Kestra team wishes you a great day! 👋
outputs:
- id: challenge
value: {{ trigger.body.challenge }} # this being exposed by webhook HTTP response
triggers:
- id: webhook
type: io.kestra.core.models.triggers.types.Webhook
key: "test"
Ludo mentioned it would be complex so for now, we implement it in the form of a tutorial https://kestra.io/docs/tutorials/slack-webhook#example-automation-ai-chatbot
if insufficient for the users, we can reopen later with the flow outputs solution suggested by @Ben8t:
id: slack-event
namespace: dev
tasks:
- id: hello
type: io.kestra.core.tasks.log.Log
message: Kestra team wishes you a great day!
outputs:
- id: challenge
value: {{ trigger.body.challenge }} # this being exposed by webhook HTTP response
triggers:
- id: webhook
type: io.kestra.core.models.triggers.types.Webhook
key: "test"
Feature description
It would be great to support Slack Events API directly from a webhook trigger.
For now the biggest challenge it seems is that Slack expects our webhook to send a plain text response with a
challenge
attribute returned from the initial API response https://api.slack.com/events/url_verificationHere is an example payload that Slack sends:
Related to https://github.com/kestra-io/plugin-notifications/issues/110
This is our attempt to solve the issue with @Ben8t but all events that we configured resulted in no executions being created. It might be due to the challenge but hard to tell/troubleshoot:
For now, the webhook response will be one of the following HTTP status codes: