This repository contains real-life use cases for Open edX Events.
Project description
A ready-to-use repository demonstrating how to use Open edX Events for building workflows and automating integrations. It serves as a starting point for more advanced use cases. Explore Real-Life Use Cases for Open edX Events to see more complex implementations from the Open edX Community
Purpose
This repository demonstrates how to connect Open edX registration, enrollment, and grade change events to external tools via n8n, enabling easier automation workflows through this third-party service.
This project is based on the original Open edX Events 2 Zapier project and has been adapted by Abstract Technology to send events to n8n webhooks.
Open edX Events are a powerful feature that allows developers to listen to key events in the Open edX platform and trigger custom actions based on them. This can be useful for a variety of use cases, such as:
Sending welcome emails to new users
Logging new enrollments to external CRMs
Triggering events like email follow-ups for grade updates
By sending key event data to n8n, Open edX users can leverage the integration ecosystem of n8n without additional development effort.
Getting Started with Development
Please first see the Open edX documentation for guidance on Python development in this repo.
Then follow the steps below to set up your development environment:
# Clone the repository
git clone git@github.com:Abstract-Tech/openedx-events-2-n8n.git
# Mount it to lms container
tutor mounts add openedx-events-2-n8n /openedx-events-2-n8n
# Install dependencies
tutor local run lms pip install -e /openedx-events-2-n8n
Deploying
See the Usage section below for instructions on how to deploy this plugin. Also, see the Tutor documentation for more information on deploying extra requirements.
Getting Help
Documentation
Refer to the Open edX Events documentation to learn about implementing and working with events. This documentation details how to use the repository to integrate with third-party services, such as n8n Webhooks, through events.
You can review the rendered documentation at https://abstract-tech.github.io/openedx-events-2-n8n/.
Features
Event Handlers: Listen to Open edX Events using Django signals and send data to n8n.
Webhook Integration: Send event data to n8n webhooks for further processing.
Customizable: Easily extend the repository to handle additional events or integrate with other services.
Ready-to-Use: Install the package and configure webhooks to start sending events to n8n.
Supported Events
Event Name |
Event Type |
Description |
|---|---|---|
org.openedx.learning.student.registration.completed.v1 |
Triggered when a user completes registration in the LMS. |
|
org.openedx.learning.course.enrollment.created.v1 |
Triggered upon successful course enrollment. |
|
org.openedx.learning.course.persistent_grade_summary.changed.v1 |
Triggered when a persistent grade summary is updated. This happens when a grade changes in a course. |
How Does it Work?
Each of the above events is handled by Django Signal handlers. When these signals are emitted, they are intercepted by handlers defined in the repository, which transform and forward the event data to a n8n webhook.
Django Signal Handlers
In the file handlers.py, handlers listen to Django signals using the standard receiver decorator:
from django.dispatch import receiver
from openedx_events.signals import STUDENT_REGISTRATION_COMPLETED
@receiver(STUDENT_REGISTRATION_COMPLETED)
def send_user_data_to_webhook(signal, sender, user, metadata, **kwargs):
n8n_payload = {
"user": asdict(user),
"event_metadata": asdict(metadata),
}
requests.post(
settings.N8N_REGISTRATION_WEBHOOK,
json=flatten_dict(n8n_payload),
timeout=N8N_REQUEST_TIMEOUT,
)
The receiver decorator listens to the STUDENT_REGISTRATION_COMPLETED signal.
The handler function send_user_data_to_webhook extracts the user and metadata from the signal.
The N8N_REGISTRATION_WEBHOOK URL is configured as a Django settings by using a Tutor plugin.
The extracted data is formatted into a payload and sent to the n8n webhook for further processing.
App Configuration (apps.py)
The Django app is configured using an AppConfig to automatically register handlers on startup.
class OpenedxEvents2N8nConfig(AppConfig):
name = "openedx_events_2_n8n"
def ready(self):
from openedx_events_2_n8n import handlers
Usage
To use this plugin, follow these steps:
Install the plugin in your Open edX image using Tutor’s OPENEDX_EXTRA_PIP_REQUIREMENTS configuration setting:
OPENEDX_EXTRA_PIP_REQUIREMENTS:
- git+https://github.com/Abstract-Tech/openedx-events-2-n8n.git@X.Y.Z
Launch the Open edX platform to apply the changes:
tutor local launch
Create and enable an Inline Tutor plugin to configure the n8n webhooks:
# Location plugins/n8n.py
from tutor import hooks
hooks.Filters.ENV_PATCHES.add_item(
(
"openedx-lms-common-settings",
"""
N8N_REGISTRATION_WEBHOOK = "https://<your-n8n-domain>/webhook/<registration-path>"
N8N_ENROLLMENT_WEBHOOK = "https://<your-n8n-domain>/webhook/<enrollment-path>"
N8N_PERSISTENT_GRADE_COURSE_WEBHOOK = "https://<your-n8n-domain>/webhook/<grade-path>"
"""
)
)
tutor plugins enable n8n
Configure n8n webhooks to receive JSON event data, follow the instructions available in the n8n documentation.
Trigger the events by registering a new user, enrolling in a course, or updating a grade in the Open edX platform.
To send event data to other services or APIs, simply configure more webhooks in the Django settings. The handlers are intentionally generic, ensuring they work seamlessly with different kinds of services. You can also add more event handlers to the handlers.py file to listen to additional events.
How to Extend this Repository
This repository is a starting point for Open edX developers:
You can add new event handlers by following the structure in handlers.py.
Custom logic can be implemented to fit your organization’s data flow requirements using n8n, third-party APIs, or internal services.
For details on extending Open edX with Open edX Events, see also:
The openedx-events-2-n8n repository is here to make integrations simple and sustainable, giving developers the tools to create effective Open edX workflows with external services like n8n.
More Help
If you’re having trouble, we have discussion forums at https://discuss.openedx.org where you can connect with others in the community.
Our real-time conversations are on Slack. You can request a Slack invitation, then join our community Slack workspace.
For anything non-trivial, the best path is to open an issue in this repository with as many details about the issue you are facing as you can provide.
https://github.com/Abstract-Tech/openedx-events-2-n8n/issues
For more information about these options, see the Getting Help page.
License
The code in this repository is licensed under the AGPL 3.0 unless otherwise noted.
Please see LICENSE.txt for details.
Contributing
Contributions are very welcome. Please read How To Contribute for details.
This project is currently accepting all types of contributions, bug fixes, security fixes, maintenance work, or new features. However, please make sure to discuss your new feature idea with the maintainers before beginning development to maximize the chances of your change being accepted. You can start a conversation by creating a new issue on this repo summarizing your idea.
The Open edX Code of Conduct
All community members are expected to follow the Open edX Code of Conduct.
People
This repository is currently being maintained by the Abstract Technology team. See the CODEOWNERS file for details.
Reporting Security Issues
Please do not report security issues in public. Contact the Abstract Technology maintainers privately before publishing details.
Change Log
Unreleased
[0.2.0] - 2024-01-24
Added
Modernize repo and readme with latest Open edX Events updates.
Make receivers trigger tasks to implement retry mechanism.
[0.1.0] - 2021-09-13
Added
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openedx_events_2_n8n-0.2.0.tar.gz.
File metadata
- Download URL: openedx_events_2_n8n-0.2.0.tar.gz
- Upload date:
- Size: 29.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfd16524ff9840346a4fdf747145788207bbfdd92ce1b3622e7c66219bfd574a
|
|
| MD5 |
9ff2fe8a4d96390a48d1add95ddc0f5d
|
|
| BLAKE2b-256 |
efd002fb5e81d3b687e0ab5092fe32b49950ec096af3b454017b8091d08754a1
|
Provenance
The following attestation bundles were made for openedx_events_2_n8n-0.2.0.tar.gz:
Publisher:
publish-pypi.yml on Abstract-Tech/openedx-events-2-n8n
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openedx_events_2_n8n-0.2.0.tar.gz -
Subject digest:
cfd16524ff9840346a4fdf747145788207bbfdd92ce1b3622e7c66219bfd574a - Sigstore transparency entry: 2006968369
- Sigstore integration time:
-
Permalink:
Abstract-Tech/openedx-events-2-n8n@bc8b5caceafb2b7eaf202ca4f2b74a9431c59b2f -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Abstract-Tech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@bc8b5caceafb2b7eaf202ca4f2b74a9431c59b2f -
Trigger Event:
push
-
Statement type:
File details
Details for the file openedx_events_2_n8n-0.2.0-py2.py3-none-any.whl.
File metadata
- Download URL: openedx_events_2_n8n-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 28.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92ccc518fe28abfcf5d4d9c88478a16c81801f13ad1ec862d823df8d7a0c90ce
|
|
| MD5 |
f6583d1e4069bf9358432f95ce9849b2
|
|
| BLAKE2b-256 |
c7cd5440b3ad2884265fc69c3316dada47e9606ca79235d2578f5517d6769892
|
Provenance
The following attestation bundles were made for openedx_events_2_n8n-0.2.0-py2.py3-none-any.whl:
Publisher:
publish-pypi.yml on Abstract-Tech/openedx-events-2-n8n
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openedx_events_2_n8n-0.2.0-py2.py3-none-any.whl -
Subject digest:
92ccc518fe28abfcf5d4d9c88478a16c81801f13ad1ec862d823df8d7a0c90ce - Sigstore transparency entry: 2006968463
- Sigstore integration time:
-
Permalink:
Abstract-Tech/openedx-events-2-n8n@bc8b5caceafb2b7eaf202ca4f2b74a9431c59b2f -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Abstract-Tech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@bc8b5caceafb2b7eaf202ca4f2b74a9431c59b2f -
Trigger Event:
push
-
Statement type: