Run user (id) search by tag

My goal is to send push notifications from my analysis to Run Users with a specific tag.

Then I can use the user ID to push a message as in:
await account.run.notificationCreate(“userID”, {
title: ‘Notification Alert’,
message: You received a notification for the device: ${device_name}. Variable: ${scope[0].variable}, Value: ${scope[0].value},
}).then(context.log).catch(context.log);
} else {
context.log(‘User ID not found for this device.’);
}

I have no idea:
a) how to get a list of Run Users (and their ID).
b) filtered by Tag

Can someone please help?

Thanks!
Vincent

I believe you are searching for the listUsers method of account.run

Account.run.listUsers | TagoIO SDK

You can as:

const { Account } = require('@tago-io/sdk');

const account = new Account({ token: 'account-token' })
const user_list = await account.run.listUsers({ tags: [ { key: "tag_key", value: "tag_value" }], amount: 999 })

context.log(user_list)
3 Likes

Yes, this is indeed what I was looking for.
Awesome, thanks!

1 Like