How do I return the challenge parameter value from a Slack webhook Source?

This topic was automatically generated from Slack. You can find the original thread here.

Andre Brunetta : Hi guys, I want to use a Source to receive queued Slack webhook calls, but couldn’t activate it correctly because I have to verify the url by returning the challenge.
Your URL didn't respond with the value of the challenge parameter.

How can I return that dynamic value from a source?

Jorge Cortes : Hi I guess what you need to do is to add the prop http and then call respond function something similar to this

...
  ...
  props: {
    ...
    http: {
      type: "$.interface.http",
    },
  },
  ...
  async run() {
    this.http.respond({
        challenge: "my-challenge",
        headers: {
          "content-type": "application/json",
        },
      });
  },
  ...

Andre Brunetta : Thanks , the problem is that the string “my-challenge” in your example should be a dynamic value that’s present in the payload received. I don’t know the challenge until they reach that url

Andre Brunetta : Hey any tips on this?

Dylan Pierce : Could you use an axios call within the source ‘run’ to send a request to the incoming challenge URL?

Andre Brunetta : I believe not, because the challenge should be informed directly when they reach the url to confirm the verification (instantly)

Andre Brunetta :

Dylan Pierce : Ah ok I think it’s coming back to me because I wanted to build around this Events API too.

The issue is Slack doesn’t allow you to programmatically register a URL, so the source interface URL isn’t known until the source is created

Dylan Pierce : Could you perhaps log the sources HTTP intersect URL, so after the source URL is created you can open up the source logs and use the logged URL in your Slack bot Events API webhook registration?