Best practice many entities with triggers
How should one manage triggers when on has many users?
What is trigger_name? an enum for the type or an actual name I can change?
Are triggers and listeners per entity or per trigger type?
And where is the documentation for trigger_config.
What does owner mean in this sense> Taken from the docs
25 Replies
rare-sapphireOPβ’3w ago
also the
response = composio_toolset.get_entity().enable_trigger(
is broken because it assumes that one should use the latest connected account but one can have multiple connected accounts per entity.rare-sapphireOPβ’3w ago
I have done this but I think it can be done better?
rare-sapphireOPβ’3w ago
A problem is that the listner will filter on the entity meaning, if I have 1000 entities then all of them will trigger all the time but having to filter.
My tirgger listner lives in their own processes for every tenant
wise-whiteβ’3w ago
Here owner means the owner of the repo...in this case I think its a github username
rare-sapphireOPβ’3w ago
ah okey. now I get it. the trigger_config is the config for the underlying action
wise-whiteβ’3w ago
Yup
So what do you want??
rare-sapphireOPβ’3w ago
to be able to create a trigger for a specific entity
wise-whiteβ’3w ago
You can make a unique enitity id with respect to your platform and check at the time of connection if that account has already been connected or not...if it is then it will skip it...
So you will not face multiple connected account problem
rare-sapphireOPβ’3w ago
Well I do that but my concerns have to do with filtering vs entity specific triggers
Lets say I have 1000 entities
entity A
entity B
...
I have 1000 containers running in my cluster for each entity/user and each process has a callback for getting emails from GMAIL.
if 1 of my users gets an email then ALL of the callbacks will be triggered. The filter will take care of not getting the wrong email for the wrong user but ALL of them will activate even though only 1 user got an email
wise-whiteβ’3w ago
You can give the entity id at the time of defining the toolset like this:
wise-whiteβ’3w ago
And then use it to listen π€
rare-sapphireOPβ’3w ago
so if you check my example it is exactly what I do. I run this and if entity A gets an email then the callback for entity B still triggers, albeit the filter catch it
wise-whiteβ’3w ago
Okay, I think I am getting the issue
Try this once
rare-sapphireOPβ’3w ago
well I have tried that. it is in my example
it doesn't scope to be only for that entity when creating the trigger. I mean can even triggers be entity specific or are they only App specific?
this is the example
wise-whiteβ’3w ago
It should only trigger specific listener respective to the entity, who got the email as it's already defined in the toolset
Lemme ask with the team and will update you regarding this asap. Thanking you for your patience π
rare-sapphireOPβ’3w ago
not according to my experiance. I tried sending emails back and forth with the code I gave you and the triggers wtill triggered when sending to another entity which had its own trigger. Maybe I'm doing something wrong but I don't know what.
question, can the trigger_name be something custom or is that a fixed enum value? like "GMAIL_NEW_GMAIL_MESSAGE"
anyway I don't have 1000 users XD but was just worried how this would scale. But you are saying it should be scoped to the entity then if that is the case performance will not be an issue if only I get it to work like you describe
wise-whiteβ’3w ago
I don't think its case sensitive, but better provide in caps π
rare-sapphireOPβ’3w ago
oh I see then it is rather the action_type? trigger_name is rather a confusing name
wise-whiteβ’3w ago
How it's confusing π€
rare-sapphireOPβ’3w ago
as I user I first though I could use the trigger_name to set my own custom names and the later filter on these
wise-whiteβ’3w ago
Ohh got it, that key value confusion ne, it happens π
But the key need to be
"trigger_name"
onlyrare-sapphireOPβ’3w ago
what? I mean that I thought I could put trigger_name to be like "my-cool-gmail-trigger-123"
wise-whiteβ’3w ago
This are the config which you can but in listener's filter
wise-whiteβ’3w ago
But yea lemme get back you with the issue
rare-sapphireOPβ’3w ago
yes I saw that and in my example I used the filter but that doesn't prevent the trigger from activating on other entities emails. It just filters them out.