Get notified when a learner completes Go1 content via the Enrolment Update webhook
This article explores how to utilise the Enrolment Update Webhook to get notified when a learner completes Go1 content. This method of tracking content completions allows you need to receive near real-time completion events from Go1 (a payload is sent for any user that completes a learning object), and to record these events in your application.
We recommend implementing this solution to track learner completions if you are, surfacing Go1 content within your application via authenticated links, or if you are using our SCORM packages to track learning - you may wish to implement this webhook as a catch-all to ensure the accurate capture of completion events.
To successfully set up and utilise the Enrolment Update webhook, we'll touch on the following three steps:
These steps will be outlined in greater detail within the Implementation Steps section of this article below.
How the Enrolment Update webhook works
To first understand how the enrolment update works, we'll briefly touch on the concept of Enrolments within the Go1 ecosystem. An Enrolment is an event that is recorded by Go1 whenever a user begins a new learning object within the Go1 Library (a learning object or LO is any learning resource within the Go1 library, eg. a course or video). Each created enrolment has a status associated with it of in-progress or complete, which records the users progress through the learning object.
A user can be enrolled in a learning object themselves by simply starting a new learning object resource. Or, they could be enrolled by another actor, for example by an Admin or Manager user in the Go1 web application. There is a separate webhook event that is fired whenever a learner enrols into a new learning object - this is the enrolment_create event, you can learn more about his event via our Webhook API Reference.
In this instance, we are interested in when a user progresses and completes their enrolment in the learning object - this is where the enrolment_update webhook comes in.
The enrolment_update event will trigger in two different circumstances as described below:
Below is an example payload for the enrolment_update event for a completed enrolment:
{ "type": "enrolment.update", "fired_at": "2020-08-11T07:58:20+0000", "data": { "id": "24107698", "user_id": "3940255", "lo_id": "16708031", "lo_type": "video", "taken_instance_id": "1975286", "status": "completed", "pass": "1", "result": "100", "assessments": null, "created_time": "2020-08-11T07:58:15+0000", "completed_time": "2020-08-11T07:58:20+0000", "actor_id": 3940255, "award": null }, "original": { "id": "24107698", "user_id": "3940255", "lo_id": "16708031", "lo_type": null, "taken_instance_id": "1975286", "status": "in-progress", "pass": "0", "result": "0", "assessments": null, "created_time": "2020-08-11 07:58:15", "completed_time": null, "actor_id": null, "award": null } }
Note that the payload contains the original state of the enrolment (before the update), and the new state of the enrolment (after the update has occurred). We'll discuss the attributes received in this payload in greater detail within the implementation steps below.
Before setting up a webhook, you will need a establish a service in your application that can receive the webhook payload from Go1. As part of this process, your service will need a URL that will be used as the location for Go1 to send webhook events to. This URL location will be configured when you initially create the webhook via the Go1 API. We will discuss this further in the implementation steps below.
To create the enrolment_update webhook, make a POST request to the /v2/webhooks endpoint, specifying the following values in the body:
Here is an example request (see the API Reference: POST /v2/webhooks):
curl --location --request POST 'https://api.go1.com/v2/webhooks' \ --header 'Authorization:<CUSTOMER_ACCESS_TOKEN>' \ --header 'Content-Type: application/json' \ --data-raw '{ "enrollment_create": false, "enrollment_delete": false, "enrollment_update": true, "lo_create": false, "lo_delete": false, "lo_update": false, "enabled": true, "secret_key": "", "url": "<YOUR LOCATION URL TO RECEIVE PAYLOADS FROM GO1>", "user_create": false, "user_delete": false, "user_update": false, "content_update": false, "content_decommission": false }'
A successful response will return the created webhook ID. The webhook ID can be used later to view, update or delete the webhook - see the Webhook API reference to learn more about these functions.
With the webhook created, you are now ready to receive payload events to the URL you have configured. Note that this created webhook will only apply to the customer portal that you created the webhook for (using the customer access token), if you are working with multiple customer portals, you will need to establish this webhook for each portal.
When any user completes a Go1 learning object, ie. they progress their enrolment of a learning object from in-progress to complete, the enrolment_update event will fire a payload.
{ "type": "enrolment.update", "fired_at": "2020-08-11T07:58:20+0000", "data": { "id": "24107698", "user_id": "3940255", "lo_id": "16708031", "lo_type": "video", "taken_instance_id": "1975286", "status": "completed", "pass": "1", "result": "100", "assessments": null, "created_time": "2020-08-11T07:58:15+0000", "completed_time": "2020-08-11T07:58:20+0000", "actor_id": 3940255, "award": null }, "original": { "id": "24107698", "user_id": "3940255", "lo_id": "16708031", "lo_type": null, "taken_instance_id": "1975286", "status": "in-progress", "pass": "0", "result": "0", "assessments": null, "created_time": "2020-08-11 07:58:15", "completed_time": null, "actor_id": null, "award": null } }
Within the payload, make note of the following attributes:
The Enrolment Update event can be used in various scenarios - such as tracking and recording learner completions through Go1 content within your application.
To map the enrolment update event to your application, you'll need to ensure that you have context of the following points of data:
(1) The user who has completed the learning
The webhook payload provides only the Go1 User ID, you'll need to implement a way to map the payload to the correct user in your application. How you map this to the user depends on your integration use-case, specifically how users are being created and getting access to Go1 content.
If you are creating users via our API, you should be able to capture and map the Go1 user-id at the point of creation, or you could implement a separate service to handle this using our user_create webhook event (which fires a payload with the user's details when a new user is created).
An alternate solution is to perform a secondary API request using the Go1 User Id to lookup the user's email address and map this completion via a matching email address in your application. To do this you make a GET request to /v2/users/<user-id>. This scenario is only viable if the user's email address that is created in Go1 matches the email address stored in your application.
(2) The learning object that has been completed
The webhook payload provides the Go1 learning object id (LO-ID) to identify the content that the user has completed. You will need to ensure that your application has context of the LO-ID and that you can map that to a matching object in your application to record the user's completion against.
If you have surfaced Go1 content in your application via our documented discovery concept, you should have been able to store the learning object ID in your application during this phase of work. If you require additional context of the learning object at this stage, you can query the Learning Object Details endpoint to identify and obtain the learning object details (ie. title, author, description, etc).
With these mapping principles arranged, you should now be able to take the payload, containing the Go1 User ID, the LO-ID and the enrolment completion status, and record this against the users learning in your application.