awork-io / awork

The awork Github repo supports you with awork integration and api questions. Here you can find links to further documentation, a FAQ with the most frequently asked questions and great code examples to get started even faster.
https://www.awork.com
11 stars 0 forks source link

[Question]: Dynamic Payload in Automation Webhooks? #122

Closed TB-effective closed 1 year ago

TB-effective commented 1 year ago

What is your question?

We are trying to push comments on tasks elsewhere via Webhooks. It was trivial to set up the webhook to be triggered "When a comment has been added to a task then..." via settings. Just for testing, we set up an endpoint on pipedream.net, and we can see the events being pushed there. However, it seems we can only push some static string as payload (request body), but we would like to receive the actual comment submitted by the user on the endpoint.

What is the correct syntax to interpolate data from the particular event that triggered the webhook into the payload, and which variables are available for interpolation? We have looked all over the documentation, but haven't been able to find any information on this, but if we missed it, a simple pointer to the place where this is documented would suffice. We have also tried various common ways like $COMMENT, {{COMMENT}}, {{task_comment}}, but all we ever receive are those literal strings. Is this not supported at all for your webhooks?

TIA!

Do you have a trace id of the call?

2QnGVtaan96AKhY3TuEidZO2kel

sebastianrosch commented 1 year ago

Hi @TB-effective we recommend using a tool like Zapier or similar to parse and transform the webhook data into the format you need. I hope this helps.

TB-effective commented 1 year ago

Hi @TB-effective we recommend using a tool like Zapier or similar to parse and transform the webhook data into the format you need. I hope this helps.

Thanks for the response, but it does not. The question is how do we get that info into the payload sent by the webhook in the first place. Once we have it, we can easily transform it forward backward or sideways, but if we don't have it we can't make it up. Again: How do we get the actual comment text into the payload that gets pushed to the remote endpoint?

nilzzzzzz commented 1 year ago

Hi @TB-effective ,

i just tested the task_comment_added webhook with the result attached. As you can see that in entity-> formattedMessage the content of my comment is included.

image

Do you see other behavior?

Perhaps you do not know https://webhook.site/, makes it quite easy to test webhooks.

TB-effective commented 1 year ago

Hi @TB-effective ,

i just tested the task_comment_added webhook with the result attached. As you can see that in entity-> formattedMessage the content of my comment is included.

Thanks for your additional response!

I am not getting this formtattedMessage (nor entity for that matter) at all. Maybe we are not talking about the same thing, how do you make the webhook transfer the whole event? If we can get this it's all we need of course. But when I set up the webhook in the Web GUI under Automations ("When a comment has been added to a task then trigger webhook with the url, body and authentication header"), it forces me to include a body, and that body is then all I get as request body, none of the actual event data. (An authentication header is also mandatory, but that's harmless, I can just include a dummy for testing.)

Do you see other behavior?

We only get the literal body we had to include when setting up the webhook. In the most recent examples,

{Test: "This is a test, comment: {{task_comment}}"}

Perhaps you do not know https://webhook.site/, makes it quite easy to test webhooks.

Well, as I mentioned, we tested via pipedream.com which is very similar (though I just noticed I wrote pipedream.net by mistake), but to exclude the possibility of the receiving end being at fault, I now tested this same webhook with webhook.site as you suggested, with the same result: The only data in the request body is the literal body we were forced to provide when setting it up:

awork_webhook_comment_added-2021-06-06

If we can get the whole event data as in your example, we're done, but we don't see how to achieve that. OTOH, as long as we have to provide a response body, we need to know how to interpolate event data into that response.

(Edit: typo)

nilzzzzzz commented 1 year ago

Hi @TB-effective ,

okay, now i get it. You did not mention before that you used the automations, so i thought you talked about our Webhook integration. The Automations are not allowing any interpolation but just posting a static value.

So i recommend that you use for this use case our webhook integrations if you want to use the payload of the entity.

https://support.awork.io/en/articles/5415462-webhooks

Does that help? Is that an option?

TB-effective commented 1 year ago

Aaah ok, yes that makes sense now! I didn't realize those were two different things, after going through the integrations we now see the whole event object with all info we need. Thanks for clarifying this! :-)

TB-effective commented 1 year ago

We did go over the documentation you linked, but somehow missed that what was done in that video was different from the Automations.

TB-effective commented 1 year ago

PS: I updated the title accordingly, and closing. Thanks again @nilzzzzzz!