Skip to main content

API Triggers

Integration of triggers via SDK. Work methods.

Method List






Rules for Working with Triggers

How trigger activation occurs:

  • The player enters the game or saves the game.
  • On the server, the fulfillment of conditions is checked.
  • The SDK receives a response from the server and notifies the developer.
  • A notification of trigger activation is sent.
  • When reward is claimed:
  • A notification of trigger reward claimed is sent.
  • A notification of reward receipt is sent.
  • A notification of achievement receipt is sent.
  • A notification of purchase accrual is sent.

How trigger rewards are claimed:

  • If automatic reward claiming is enabled, rewards, purchases or achievements are recieved to the player when conditions are met.
  • If manual claiming is selected, the gp.triggers.claim() method must be called at any time in order to obtain all of the trigger rewards.
  • When rewards are manually claimed, a request is made to save the player and all rewards are credited to the server and player variables are modified.

Since data consistency and bonus issuance are provided by us, there is no need to participate in the process at the code level.

It is enough for you to only subscribe to events of awarding rewards and wait for the trigger to activate.


Claim Reward

+Lazy Sync Request

To claim a reward for a trigger, you need to pass the ID or tag of the trigger.

// By ID
gp.triggers.claim({ id: '646929f98abe970f54fb6274' });
// By Tag
gp.triggers.claim({ tag: 'LEVEL_10' });

The method returns the trigger, activation status, and reward confirmation:

const { trigger, isActivated, isClaimed } = await gp.triggers.claim({ tag: 'LEVEL_10' });


Trigger List


You have access to the entire trigger list immediately upon launching the game. See trigger fields.

gp.triggers.list.forEach((trigger) => {
// trigger.tag
// trigger.isAutoClaim
// trigger.description
// trigger.conditions
// trigger.bonuses

Activated Trigger List


You have access to the entire list of activated triggers when the player is ready.

gp.triggers.activatedList.forEach((triggerId) => {
// Trigger ID as a string

// Getting a trigger by ID
const { trigger, isActivated, isClaimed } = gp.triggers.getTrigger(triggerId);

Get Information About Trigger


The method returns trigger and activation status:

// By ID
const { trigger, isActivated, isClaimed } = gp.triggers.getTrigger('646929f98abe970f54fb6274');
// By Tag
const { trigger, isActivated, isClaimed } = gp.triggers.getTrigger('LEVEl_10');

// The trigger may not exist, make sure it exists
if (trigger) {, isActivated, isClaimed);


Trigger Activated

gp.triggers.isActivated(idOrTag) FREE

// By ID
const isActivated = gp.triggers.isActivated('646929f98abe970f54fb6274');
// By Tag
const isActivated = gp.triggers.isActivated('LEVEl_10');

// Check
if (isActivated) {
// LEVEl_10 trigger is activated

Reward Claimed

gp.triggers.isClaimed(idOrTag) FREE

// By ID
const isClaimed = gp.triggers.isClaimed('646929f98abe970f54fb6274');
// By Tag
const isClaimed = gp.triggers.isClaimed('LEVEl_10');

// Check
if (isClaimed) {
// LEVEl_10 bonuses of the trigger is claimed


Trigger Activated

Callback returns trigger:

gp.triggers.on('activate', ({ trigger }) => {
// Information about the trigger is available

Reward Claimed

Callback returns trigger:

gp.triggers.on('claim', ({ trigger }) => {
// Information about the trigger is available

Reward Claim Failed

The callback returns an error. See error codes:

gp.triggers.on('error:claim', (err) => {
// check error code


Trigger Fields

idstringReward ID646929f98abe970f54fb6274
tagstringTag for selecting the trigger. You can use it instead of IDLEVEL_10
descriptionstringTrigger descriptionReach level 10
isAutoClaimbooleanThe reward is automatically claimed when the trigger is activatedtrue
conditionsCondition[][]List of trigger conditions[]
bonusesBonus[]List of bonuses[]

Condition Fields

typeConditionTypeType of conditionPLAYER_FIELD
keystringVariable key to comparelevel
operatorConditionOperatorType of comparison operatorEQ
valuenumber[] / string[] / boolean[]Values to be checked, combined with OR[10,20]

Full example of condition structure:

// Conditions AND on player fields

// player.level >= 10
const playerLevelGte10: Condition = {
key: 'level',
operator: 'GTE',
value: [10],

// player.class === 'rouge' || player.class === 'mage'
const playerRogueOrMage: Condition = {
key: 'class',
operator: 'EQ',
value: ['rogue', 'mage'],

// player.level >= 10 && (player.class === 'rouge' || player.class === 'mage')
const playerANDConditions: Condition[] = [playerLevelGte10, playerRogueOrMage];

// Conditions AND on player statistics
// playerStats.activeDays >= 5
const activeDaysGTE5: Condition = {
type: 'PLAYER_STAT',
key: 'activeDays',
operator: 'GTE',
value: [5],

// playerStats.playtimeAll >= 36000
const playtimeAllGTE360000: Condition = {
type: 'PLAYER_STAT',
key: 'playtimeAll',
operator: 'GTE',
value: [36000],

// playerStats.activeDays >= 5 && playerStats.playtimeAll >= 36000
const playerStatsANDConditions: Condition[] = [activeDaysGTE5, playtimeAllGTE360000];

// Conditions OR
// Trigger activates if either conditions are met for player fields or player stats
const triggerORConditions: Condition[][] = [playerANDConditions, playerStatsANDConditions];

Condition Types


PLAYER_FIELDCheck against player fields
PLAYER_STATCheck against player statistics
ENTITY_STATCheck against stats from external modules, such as events or schedulers

Comparison Operator Types


NENot equal
GTGreater than
LTLess than
GTEGreater than or equal to
LTELess than or equal to

Bonus Fields


typeBonusTypeType of bonusREWARD
idnumberBonus ID1122

Example of bonus structures:

const bonuses: Bonus[] = [
type: 'REWARD',
id: 941,
type: 'PRODUCT',
id: 31,

Bonus Types



Error Codes

ErrorError Description
trigger_not_foundTrigger with the provided ID or tag not found
trigger_not_activatedTrigger is not activated
trigger_already_claimedReward has already been claimed
undefinedUnexpected error (check the console for details)

Stay in Touch

Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.

GamePush Community Telegram: @gs_community.

For your suggestions e-mail: [email protected]

We Wish you Success!