Since we launched Discourse Gamification a year ago, one of the most requested features from our roadmap has been the ability to make it possible to integrate Discourse Gamification with external gamification system . Examples are plenty:
-
Integrate with existing gamification programs in companies
-
ability to award points for events that happen outside of Discourse, like IRL events, or elsewhere online, like being a customer in a community, or buying a product.
-
the ability to allow users to redeem their points for swag, products or benefits
Today, just in time for the plugin’s first anniversary, we made all of the above possible with a full API to handle custom scoring events .
This new system allows admins to:
-
Award users a custom score event
-
Award users with negative score events, to accommodate redeem or penalties events
-
Update and list custom events previously created
API
Points awarded via API will take up to 10 minutes to reflect on a user overall score for events created with the current date, and up to 24h for events created in the last 10 days. For events created with a date past the last 10 days you need to run the backfill rake task.
There are 3 different API endpoints currently.
List Events
curl http://example/admin/plugins/gamification/score_events.json -H "Api-Key: apikeyhere" -H "Api-Username: system"
You can also list specific user or date events:
curl http://example/admin/plugins/gamification/score_events.json?user_id=1&date=2023-05-01 -H "Api-Key: apikeyhere" -H "Api-Username: system"
Create Event
jo -p user_id="13" date="2023-04-14" points="15" description="May 2023 Karaoke atendee" | curl --json @- -XPOST http://example/admin/plugins/gamification/score_events -H "Api-Key: apikeyhere" -H "Api-Username: system"
Update Event
jo -p id="1" points="25" description="May 2023 Karaoke atendee" | curl --json @- -XPUT http://example/admin/plugins/gamification/score_events -H "Api-Key: apikeyhere" -H "Api-Username: system"
Last edited by @JammyDodger 2024-05-28T12:58:56Z
Check document
Perform check on document: