Skip to main content

Webhook event type change_specific_column_value

  • August 1, 2020
  • 7 replies
  • 5004 views

basdebruin

I noticed a new(?) eventType for the create_webhook API call: change_specific_column_value. From the name I expect this webhook fires when a specific column changes 🙂 .

I also noticed a (not very well documented) config (JSON) argument to the create_webhook call which probably needs to have the specifics for the column to watch for.

My question is: how should the config argument look like to be able to setup a webhook through the API that only fires when a specific column changes.

@dipro, @AlexSavchuk, can one of you shine a light here?

This topic has been closed for replies.

7 replies

  • New Participant
  • August 5, 2020

I did some digging (becuase I wanted to know how to) and i found out that the config is a GraphQL JSON string. The whole mutation will look like this:

mutation {
create_webhook ( board_id: 111111, url: “https://a/webhook/url”, event: change_specific_column_value config:“{"columnId":"status1"}”) {
id
board_id
}
}

where status1 is the column that you want to be notified by.


  • New Participant
  • August 5, 2020

note: the Inner " require a \\ in front of them.


basdebruin
  • Author
  • Community Expert
  • August 5, 2020

Hi @ptsgJason, Jason

You are the champ! Works like a charm. Just curious to know where you got the info from as I was unable to find any documentation on this. Especially the lack of the comma between the WebhookType and the config argument is a really good find 🙂

This saves a lot of back and forth traffic.


basdebruin
  • Author
  • Community Expert
  • August 5, 2020

For those who are adding webhooks to a board through the API (e.g. in a subscribe event from a custom trigger) take care: lot of escaping to do!

I use a function like below to inset any type of webhook to a board and returns the trigger Id. (forgive the formatting, not the best editor here 🙂

static async createWebhook(token, boardId, webhookUrl, webhookType) {
try {
const mondayClient = initMondayClient();
mondayClient.setToken(token);
const query =
mutation create_webhook($boardId: Int!, $webhookUrl: String!) { create_webhook(board_id: $boardId, url: $webhookUrl, event: +
webhookType +
) { id } } ;
const variables = { boardId, webhookUrl };
const response = await mondayClient.api(query, { variables });
return response.data.create_webhook.id;
} catch (err) {
console.log(err);
}
}

This function is called like this for an add_item webhook, with a token, a boardId, a webhookUrl (I my specific case I needed the host part dynamic) and a webhookType.

const triggerHooks = await mondayService.createWebhook(
token,
boardId,
“https://” + req.headers.host + “/vote-to-group/webhookaction”,
“change_column_value”
);

Now, for the change_specific_column_value webhook you can still use the same function but take care of all the escaping done for the last argument (webhookType). All the \\ characters in the last argument are really double-backslashes (\\\\) but lost in this code editor. At least in VSCode you need to escape the escape character 🙂

const triggerHooks = await mondayService.createWebhook(
token,
boardId,
“https://” + req.headers.host + “/vote-to-group/webhookaction”,
‘change_specific_column_value config: “{\\“columnId\\”:\\”’ + columnId + ‘\\“}”’
);

Many thanks to @ptsgJason for this find and happy webhooking 🙂


dsilva
Forum|alt.badge.img
  • Participating Frequently
  • August 25, 2020

Hey @basdebruin

Sorry for our delay in handling this! I’m glad to see this is working correctly now!
Let us know if we can help with anything else.

-Daniel


  • New Participant
  • October 29, 2020

@ptsgJason, when you states “I did some digging”; how did you do this ? 😃


basdebruin
  • Author
  • Community Expert
  • March 5, 2021

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.