Initialization

The initialization of the PlayAI SDK requires two or more parameters:

  1. gameID: This is a unique identifier assigned to your game. It is mandatory for the initialization process.

  2. gameContainer: This is a CSS selector that targets the HTML element where the game will be rendered. This parameter is also mandatory.

  3. playAIStyles or demo (optional): This is an object that allows you to customize the appearance of the action bar or a string field to render the demo version of the SDK. If the playAIStyles parameter is provided, it will be used for customization. If not, and the demo parameter is provided, it will be used to render the demo version of the SDK. The demo value can be recording or onboarding. If neither is provided, the SDK will apply a default style to the action bar.

  4. demo (optional): This is a string field that, when provided, will render the SDK in demo mode with the specified styles. The value can be recording or onboarding. This parameter is used when you want to apply custom styles and also render the SDK in demo mode.

Here are examples of how you can initialize the PlayAI SDK:

import PlayAI from '@playai/sdk';

const playAI = new PlayAI('ba95fea8-c151-4168-ba19-331694c7a241', '.game-container');
const playAI = new PlayAI('ba95fea8-c151-4168-ba19-331694c7a241', '.game-container', {
  actionBar: {
    backgroundColor: '#f5f5f5',
    textColor: '#000000',
    borderRadius: '10px',
  },
  playAIIcon: {
    color: '#f5f5f5',
    hover: {
      color: '#000000',
    }
  },
});
const playAI = new PlayAI('ba95fea8-c151-4168-ba19-331694c7a241', '.game-container', 'recording');
const playAI = new PlayAI('ba95fea8-c151-4168-ba19-331694c7a241', '.game-container', 'onboarding');
const playAI = new PlayAI('ba95fea8-c151-4168-ba19-331694c7a241', '.game-container', {
  actionBar: {
    backgroundColor: '#f5f5f5',
    textColor: '#000000',
    borderRadius: '10px',
  },
  playAIIcon: {
    color: '#f5f5f5',
    hover: {
      color: '#000000',
    }
  },
}, "onboarding");

Last updated