Remus Avram Posted September 30, 2017 Report Share Posted September 30, 2017 Hi all, is it possible to send custom notifications via ftrack_api? We are automating a lot with actions. But this creates also a lot of confusion. We need to communicate better to the users. We are using the pop up messages, but these are displayed only for 5 seconds. Sometimes the user is missing them, sometimes the message is going away before he/she finishes reading it. Sending notifications to the user will help a lot in understanding what is happening. Link to comment Share on other sites More sharing options...
Mattias Lagergren Posted October 3, 2017 Report Share Posted October 3, 2017 Hi Remus, this could be done in two other ways at the moment: Trigger an action dialog for the user with the information. You can just use label with markdown to get the message through. Create a job to show the user progress. As for the notification system we have ideas of revamping the notifications and at the same time give the ability to add your own. Note that this is just internal discussions at the moment. Link to comment Share on other sites More sharing options...
Remus Avram Posted October 4, 2017 Author Report Share Posted October 4, 2017 Hi @Mattias Lagergren, thanks for the thoughts. Both other ways have downsides. The Ftrack notification system is really nice and using it for custom notifications will be great. Link to comment Share on other sites More sharing options...
tokejepsen Posted October 5, 2017 Report Share Posted October 5, 2017 Quote Trigger an action dialog for the user with the information. You can just use label with markdown to get the message through. Could you elaborate on this? Trying to trigger an action dialog from a custom published event, and can't seem to get it to work. Remus Avram 1 Link to comment Share on other sites More sharing options...
Mattias Lagergren Posted October 9, 2017 Report Share Posted October 9, 2017 At the bottom of this article there is some information about triggering an action interface: http://help.ftrack.com/developing-with-ftrack/key-concepts/actions I hope this helps! Link to comment Share on other sites More sharing options...
tokejepsen Posted October 9, 2017 Report Share Posted October 9, 2017 Hey Mattias, Tried getting the examples running, but couldn't so wanted to see if you could correct my example code? import getpass import ftrack_api def callback(event): """Status change updates.""" session = ftrack_api.Session() for entity_data in event["data"].get("entities", []): if entity_data["action"] != "update": continue if "statusid" not in entity_data["keys"]: continue new_status = session.get( "Status", entity_data["changes"]["statusid"]["new"] ) # Task changes if entity_data["entityType"] == "task": if new_status["name"] == "In Progress": event = ftrack_api.event.base.Event( topic='ftrack.action.trigger-user-interface', data={ 'type': 'form', 'items': [ { 'label': 'My Boolean', 'name': 'my_boolean', 'value': True, 'type': 'boolean' } ], 'title': 'Foobar' }, target=( 'applicationId=ftrack.client.web and ' 'user.id={0}'.format( event['source']['user']['id'] ) ) ) session.event_hub.publish(event) session.commit() def register(session, **kw): """Register event listener.""" # Validate that session is an instance of ftrack_api.Session. If not, # assume that register is being called from an incompatible API # and return without doing anything. if not isinstance(session, ftrack_api.Session): # Exit to avoid registering this plugin again. return # Register the event handler subscription = ( "topic=ftrack.update and source.applicationId=ftrack.client.web and " "source.user.username={0}".format(getpass.getuser()) ) session.event_hub.subscribe(subscription, callback) When a task's status is set to "In Progress" this code should show a form for the user to interact with. Link to comment Share on other sites More sharing options...
Mattias Lagergren Posted October 10, 2017 Report Share Posted October 10, 2017 Could you try to adda a small "time.sleep(..)" after initialising the new session? It could be that the event hub is not yet connected when the event is emitted. Link to comment Share on other sites More sharing options...
tokejepsen Posted October 10, 2017 Report Share Posted October 10, 2017 Thanks Mattias I've used the shared session from ftrack-connect, and that works well. Now the question is how do you intercept the "Submit" event? Normally you look for "values" in the same event. Link to comment Share on other sites More sharing options...
tokejepsen Posted October 10, 2017 Report Share Posted October 10, 2017 Should have investigated it deeper. The event from hitting "Submit" on the dialog has a topic of "ftrack.action.launch" with the values in it. Might be nice to update the documentation with this information. import getpass import ftrack_api from ftrack_connect.session import get_shared_session def callback(event): """Status change updates.""" session = get_shared_session() for entity_data in event["data"].get("entities", []): if entity_data["action"] != "update": continue if "statusid" not in entity_data["keys"]: continue new_status = session.get( "Status", entity_data["changes"]["statusid"]["new"] ) # Task changes if entity_data["entityType"] == "task": if new_status["name"] == "In Progress": event = ftrack_api.event.base.Event( topic='ftrack.action.trigger-user-interface', data={ 'type': 'form', 'items': [ { 'label': 'My Boolean', 'name': 'my_boolean', 'value': True, 'type': 'boolean' } ], 'title': 'Foobar' }, target=( 'applicationId=ftrack.client.web and ' 'user.id={0}'.format( event['source']['user']['id'] ) ) ) session.event_hub.publish(event) session.commit() def action_launch(event): print event def register(session, **kw): """Register event listener.""" # Validate that session is an instance of ftrack_api.Session. If not, # assume that register is being called from an incompatible API # and return without doing anything. if not isinstance(session, ftrack_api.Session): # Exit to avoid registering this plugin again. return # Register the event handler subscription = ( "topic=ftrack.update and source.applicationId=ftrack.client.web and " "source.user.username={0}".format(getpass.getuser()) ) session.event_hub.subscribe(subscription, callback) subscription = ( "topic=ftrack.action.launch and " "source.user.username={0}".format(getpass.getuser()) ) session.event_hub.subscribe(subscription, action_launch) Link to comment Share on other sites More sharing options...
Remus Avram Posted January 4, 2019 Author Report Share Posted January 4, 2019 Hi @Mattias Lagergren any updates regarding this? This will help us a lot if we were able to send messages to Artists using the Ftrack notifications. Link to comment Share on other sites More sharing options...
Mattias Lagergren Posted January 8, 2019 Report Share Posted January 8, 2019 No updates as of now - as an additional workaround, have you looked into writing a message (note without parent) to the user? This should trigger a notification note = session.create('Note', { 'content': 'hey', 'user_id': author_user_id}) sesssion.create('Recipient', { 'note_id': note['id'], 'resource_id': target_user_id }) session.commit() Remus Avram 1 Link to comment Share on other sites More sharing options...
Remus Avram Posted January 8, 2019 Author Report Share Posted January 8, 2019 3 hours ago, Mattias Lagergren said: No updates as of now - as an additional workaround, have you looked into writing a message (note without parent) to the user? This should trigger a notification note = session.create('Note', { 'content': 'hey', 'user_id': author_user_id}) sesssion.create('Recipient', { 'note_id': note['id'], 'resource_id': target_user_id }) session.commit() I think this is what exactly we are looking for we will give it a try and let you know if works for us Link to comment Share on other sites More sharing options...
PeterH Posted December 23, 2020 Report Share Posted December 23, 2020 I'm coming in 2 years late, but I was attempting to do this myself and found some info which might help others: If api_user == target_user, then target_user will never receive any notification. It can only be found in the sent items of author_user. The browser notification will always be from api_user. The note itself will correctly be from author_user. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now