I need to programmatically pull the list of AEM inbox notifications of a user, with the purpose of sending them a reminder (via email) of the workflow steps waiting for them to take action on.
Can someone please send some hints, or sample code on how to get the list of inbox items.
lir Yes, there are rest endpoints exposed via which you can retrieve the inbox items in a user's inbox. One example of such request is : http://host:port/bin/workflow/inbox which will list all the work items in the inbox of the user.
For more details on using this endpoint further please refer Interacting with Workflows Programmatically .
Once you have the work items, you can use the InboxItem API "The Adobe AEM Quickstart and Web Application." to retrieve further details regarding that InboxItem object.
Can you try below methods to get task and workflow item in osgi code.
ResourceResolver resolver = request.getResourceResolver();
TaskManager taskManager = resolver.adaptTo(TaskManager.class);
Iterator<Task> ti = taskManager.getTasks(new Filter());
WorkflowSession graniteWorkflowSession = resolver.adaptTo(WorkflowSession.class);
WorkItem workItems = graniteWorkflowSession.getActiveWorkItems();
I am interested on the InboxItem-s (WorkItem-s) that belong to each and every user (who participates in a number of workflows), so I don't see how the suggestion above can help.
My final goal is that once a day, each and every user receive a reminder email, that lists all the pages/assets/etc they are expected to approve/disapprove in AEM.
So my code has to either:
1- impersonate each and every user, one by one, read their InboxItem-s and go from there.
This I think is straightforward, but seams impossible because "A system user cannot impersonate a non system AEM user"
2- access all active workflow instances, and somehow extract what each and every user is expected to approve/disapprove.
I don't know how to approach this code wise.
I hope this is clear and someone can help.
If you request http://localhost:4502/libs/cq/workflow/content/inbox/list.json as an admin, you get a list of all pending inbox items and their assignees. The code for how that list is generated is available in crx/de under /libs/cq/workflow/components/inbox/list/json.jsp
So you can model your code after the code used in that page and retrieve the results as an InboxItem array and send your notifications.
Refer to the code in crx/de for the details on retrieving the data
The logic to fetch or create data for TouchUI inbox is not at the front end as in case of classicUI but at the Java side. below is the basic flow:
-A request to '/aem/inbox' resolves to path '/libs/cq/inbox/content/inbox'
-This renders data per  which creates the html page per 
-At the same time  triggers a get request to fetch the data for the inbox page  which is handled by a servlet  and used by  to create the complete inbox page
-Further on logic goes to  and  to fetch the data per the logic