Manage game data

Create new Game Objects

Game Objects page

You can quickly create Game Objects through the Console. Simply navigate to Game Objects, enter the name of your Game Object using shift+enter.

Group objects into Tags

Next, you'll need to organize our Game Objects into Tags, which are collections of Game Objects. Group objects into Tags to input them into Games later on.

You can then load your Tags as inputs into games. Let's create a Tag under Tags page

Create a Tag under the Tags page by clicking shift + enter

Input tagged objects into game

After creating our Tag, tag them by returning to the Game Objects page, bulk selecting, selecting the Hobbies tag, and then load them as inputs into our hobbies-ranker game.

Importing data

Prepare your records

Your data must be in a format the 2bttns platform can understand. Once you've decided on your game objects, we'll need to prepare your records for import.

Format your JSON

Already have data you'd like to input into 2bttns? Let's walk through how to format your data to import through API or the Console interface.

Import JSON Structure
 const outputShape: OutputShape = { gameObjects: [
    {
      id: '',
      name: '', // REQUIRED
      description: '',
      tagIds: []
    }
  ],
  tags: [
    {
      id: '',
      name: '',
      description: ''
    }
  ]
};
Game Object Type
interface GameObject {
  id: string;
  name: string;
  description: string;
  tagIds: string[];
  [key: string]: any;
}

How 2bttns Helps

We've got you covered. 2bttns comes with a Formatter to effortlessly transform any JSON into the specified data model.

Using the formatter

Example: Personalize Coffee Shop Drinks to Moods ☕️ 😁

You're building a creative coffee shop experience where the menu dynamically adapts to how customers are feeling. Using 2bttns, we can categorize menu items by mood, ensuring each customer finds the perfect drink to match their current state of mind.

drinks-moods.json
{
    "coffee_shop_drinks": [
        {
            "mood": "Energetic",
            "drinks": [
                "Espresso",
                "Iced Coffee",
                "Cold Brew"
            ]
        },
        {
            "mood": "Focused",
            "drinks": [
                "Espresso",
                "Latte",
                "Iced Coffee"
            ]
        },
        {
            "mood": "Relaxed",
            "drinks": [
                "Cappuccino",
                "Latte"
            ]
        },
        {
            "mood": "Content",
            "drinks": [
                "Cappuccino",
                "Iced Latte"
            ]
        },
        ...
    ]
}

Run the following script anywhere to use the Formatter

npx @2bttns/objects
Running the @2bttns/objects formatter script

After selecting Format Data, pass in your JSON

Formatter prompt
? 📁 Enter the path of the input JSON file:
› /Users/you/Downloads/drinks-mood.json

Input the path to the list object in your JSON containing your Game Objects. In this case, coffee_shop_drinks is the object containing our list of Moods objects:

Formatter prompt
✔ 🔍 Select the path in JSON where the data to be converted is located:
· coffee_shop_drinks

The Formatter will ask you questions to create a ready-to-upload JSON. Here's how it works:

Formatter prompts
✔ ⭐️ Which key in your JSON corresponds to "id" with value type "string"?
 👉 Enter "none" if none exists. 
 · none
 
✔ ⭐️ Which key in your JSON corresponds to "name" with value type "string"?
 👉 Enter "none" if none exists.
 · mood

✔ ⭐️ Which key in your JSON corresponds to "description" with value type "string"?
 👉 Enter "none" if none exists.
 · none

✔ ⭐️ Which key in your JSON corresponds to "tagIds" with value type "object"?
 👉 Enter "none" if none exists.
 · none

✔ 📁 Enter the path where you want to save the output JSON file (e.g., /your/path/name/): 
 press ENTER for current directory
 · /Users/you/Downloads

✔ 📁 Enter the output file name (e.g., my-output.json):
· output.json

✅ Output JSON file saved successfully! ✅

Here's an outline of each field and its corresponding data mapping:

Key
Value
Definition

id

string

A unique uuid representing a game object. Formatter will generate one if none.

name

string*

The name of game object. This is what users see and score when playing a round of 2bttns.

description

string

A description of the game object

tagIds

object

Each ID corresponds to the parent collection that a game object is part of. You can group Game Objects into Tags using the Console.

*Required

Viola! 🪄 And here's the resulting output JSON:

ready-to-upload.json
{
  "gameObjects": [
    {
      "id": "clso4o94h0001xk9sfsjwdf0q",
      "name": "Focused",
      "description": "",
      "tagIds": []
    },
    {
      "id": "clso4o94h0004xk9sgbw84w0i",
      "name": "Comforted",
      "description": "",
      "tagIds": []
    },
    {
      "id": "clso4o94h0007xk9shfrm4izk",
      "name": "Reflective",
      "description": "",
      "tagIds": []
    },
    ...
  ],
  "tags": [
    {
      "id": "",
      "name": "",
      "description": ""
    }
  ]
}

How to import

You can import your data either through API/SDK or the Console interface.

Import with Console

You can drag and drop your JSON of Game Objects in. Navigate to your Console and click on the Actions button.

Console > Game Objects > Actions > Import from JSON

Import with API

You can also import your JSON through the API using the following endpoint:

Import Data

post

Import 2bttns data from a JSON file.

Authorizations
Body
jsonBase64stringRequired

Base64 encoded JSON file to import

allOrNothingbooleanOptional

If true, the import will fail if any part of it fails.

If false, the import will continue even if some parts fail.

Default: false
generateNewIdsbooleanOptional

Generate new IDs for imported data and remap all references to them, instead of using existing IDs.

This may result in duplicate entries with similar content but different IDs.

Default: false
Responses
200
Successful response
application/json
post
POST /api/import-data HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 65

{
  "jsonBase64": "text",
  "allOrNothing": false,
  "generateNewIds": false
}
{
  "results": {
    "tags": {
      "successes": 1,
      "failures": 1
    },
    "gameObjects": {
      "successes": 1,
      "failures": 1
    },
    "games": {
      "successes": 1,
      "failures": 1
    }
  },
  "allOrNothingFailed": true,
  "logMessages": [
    {
      "type": "info",
      "message": "text"
    }
  ]
}

Last updated

Was this helpful?