Actions20
- User Actions
- Course Actions
- Enrollment Actions
- Grade Actions
- Message Actions
Overview
This node interacts with the Moodle Learning Management System (LMS) to perform various operations on different resources such as users, courses, enrollments, grades, messages, and system information. Specifically, for the Message resource with the Get Messages operation, it retrieves messages associated with a specified user. It supports filtering messages by type (sent, received, or both), read status (all, read only, unread only), and pagination controls (limit and offset).
Common scenarios:
- Retrieving all messages sent to or from a particular user.
- Filtering messages to show only unread or read messages.
- Paginating through large sets of messages for a user.
Practical example:
An administrator wants to audit communications for a specific user. They can use this node to fetch all messages that user has sent or received, filter to only unread messages, and limit the results to the most recent 20 messages.
Properties
Name | Meaning |
---|---|
User ID | The numeric ID of the user whose messages you want to retrieve. |
Message Filters | A collection of filters to refine the message retrieval: |
- Message Type | Choose which messages to retrieve: • Both (Sent and Received) • Received • Sent |
- Read Status | Filter messages by read status: • All (read and unread) • Read Only • Unread Only |
- Limit | Maximum number of messages to retrieve (default 20). |
- Offset | Number of messages to skip before starting to collect the result set (default 0). |
Output
The output is an array of message objects in JSON format. Each message object includes the standard Moodle message fields plus an additional _messageDirection
property indicating whether the message was "sent" or "received" relative to the specified user.
Example structure snippet:
{
"id": 123,
"useridfrom": 45,
"useridto": 67,
"text": "Hello!",
"timecreated": 1680000000,
"_messageDirection": "received"
}
- Messages are sorted by creation time descending (most recent first).
- If both sent and received messages are requested, the combined list is limited to the specified maximum.
- No binary data output is produced by this operation.
Dependencies
- Requires a valid connection to a Moodle instance with web services enabled.
- Needs an API key credential configured in n8n for authenticating requests to Moodle's REST API.
- The Moodle web service must support the legacy messaging functions (
core_message_get_messages
). - For best results with messaging, newer Moodle versions (3.6+) support conversations APIs, but this operation uses the legacy message API.
Troubleshooting
No messages found:
Common reasons include:- Messages may be stored in conversations rather than legacy messages; consider using "Get Conversations" and "Get Conversation Messages" operations instead.
- The user might not have any messages matching the selected filters (direction, read status).
- Permissions or roles may restrict access to message data.
- Newly sent messages might not appear immediately; try filtering by "Sent" messages with the sender's user ID.
Unexpected response format:
If the response does not contain amessages
array, verify the Moodle version and web service configuration.API errors related to function availability:
If the legacy message API is disabled or unsupported, the node will log errors. Consider upgrading Moodle or switching to conversation-based message retrieval.Rate limits or large data sets:
Use theLimit
andOffset
filters to paginate results and avoid timeouts or large payloads.
Links and References
- Moodle Web Services API documentation:
https://docs.moodle.org/dev/Web_services_API_functions - Moodle Messaging API (legacy):
https://docs.moodle.org/dev/Message_API - Moodle Conversations API (recommended for modern versions):
https://docs.moodle.org/dev/Conversations_API - n8n Documentation on Credentials and HTTP Request Nodes:
https://docs.n8n.io/nodes/credentials/
https://docs.n8n.io/nodes/nodes-library/n8n-nodes-base/http-request/