Webhook event type change_specific_column_value

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 :slight_smile: .

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?

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.

1 Like

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

1 Like

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 :slight_smile:

This saves a lot of back and forth traffic.

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 :slight_smile:

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 :slight_smile:

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 :slight_smile:

1 Like

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