Webhook Integration and Data Handling
Ludo's webhook feature allows integration with your systems to track player activities, update game data, and sync in-game assets. This document provides a step-by-step guide to setting up a webhook.
1. Setting Up the Webhook
Navigate to the Integrations Section
In the Ludo system, go to Integrations and select Game Sync.
Create a Webhook
Click on Create Webhook and input the POST endpoint where Ludo will send data.
Ensure that the endpoint is properly configured to receive and process the following event types.
2. Webhook Payload Structure
In general, the body of a webhook contains the following parameters:
Parameter
Data Type
Description
id
String
Unique identifier for the event.
createdAt
String (ISO)
Timestamp indicating when the event was created (e.g., "2024-06-26T00:31:24Z").
type
String
The type of webhook event (e.g., player.points.updated
, item.created
).
data
Object
Contains details about the event, including specific data objects.
environment
String
Specifies the environment where the transaction was processed (test
or live
).
3. Data Object Structure
The data
object contains details relevant to the specific event. Its structure varies depending on the event type.
Common Fields in the data
Object:
Parameter
Data Type
Description
object
Object
Contains specific details of the event (e.g., player details, points, or items).
ludoPlayerId
String
Unique identifier for the Ludo player.
playerId
String
Identifier used in your system to match the player.
discordUserId
String
Discord ID of the player, if applicable.
telegramUserId
String
Telegram ID of the player, if applicable.
String
Email associated with the playerโs Ludo account.
name
String
Name of the player.
points
Array of Objects
Details of the playerโs point balances. Each object contains:
- tokenId
String
Unique identifier for the points token.
- tokenName
String
Name of the token (e.g., "Gold Points").
- amount
Integer
Total amount of points the player has for this token.
items
Array of Objects
Details of items owned by the player. Each object contains:
- itemId
String
Unique identifier for the item.
- productId
String
Identifier linking the item to a specific product.
- name
String
Name of the item (e.g., "Golden Sword").
- description
String
Description of the item.
- imageUrl
String (URL)
Link to the itemโs image.
- createdAt
String (ISO)
Timestamp when the item was created.
products
Array of Objects
Details of products owned by the player. Each object contains:
- productId
String
Unique identifier for the product.
- name
String
Name of the product.
- description
String
Description of the product.
- price
Integer
Price of the product in points.
- createdAt
String (ISO)
Timestamp when the product was created.
updatedAt
String (ISO)
Timestamp of the last update to the player's data.
createdAt
String (ISO)
Timestamp of when the player was first added to the system.
environment
String
Specifies the environment where the transaction was processed (test
or live
).
4. Supported Event Types
Category
Event Type
Description
Players
player.points.updated
Triggered when a player's points are updated.
player.items.updated
Triggered when a player gains/loses an item.
Items
item.created
Triggered when a new item is created.
item.updated
Triggered when an item is edited.
Products
product.created
Triggered when a product is created.
product.updated
Triggered when a product is updated.
5. Naming Convention for Events:
The event names follow this pattern:
{category}.{event}.{sub-event}
Example:
player.points.updated
player.items.updated
6. Example Events:
player.points.updated
Event: item.created
7. How to Display Items per Player in the Game
Ludo will send player-related data, including points, products, and items, via webhooks. To show these items for each player in your game, follow these steps:
Receive Webhook Data:
When Ludo sends a webhook with the relevant data (e.g.,
player.items.updated
), your system should process the webhook and update the playerโs items.
Update Player Items:
Ensure that you update the playerId and items in your system with the new data received from the webhook.
This will allow your players to see the updated in-game assets in real-time.
Sync with Player IDs:
The data sent by Ludo contains the
playerId
, which should match the ID in your system, allowing for seamless integration and real-time updates of player items and points.
Example Event for Updating Player Items:
Last updated