Generic Game

Config

{
  "name": <string>,
  "description": <string>,
  "type": "Generic"
  "gameSpecificConfiguration": {
    "contextParameters": [
      {
        "label": <string>,
        "humanizedLabel": <string>,
        "description": <string>,
        "initialValue": <string>,
        "type": <Type>,
        "displayInInbox": <boolean>
      },
      ...
    ],
    "userIntents": [
      {
        "label": <string>,
        "utterances": <MultilangVariationString>,
        "slots": [
          {
            "label": <string>,
            "type": <string>
          },
          ...
        ],
        "reactions": [
          {
            "botIntent": <string>,
            "conditions": [
              {
                "parameter": <string>,
                "operator": <string>,
                "value": <string>
              },
              ...
            ]
          },
          ...
        ]
      },
      ...
    ],
    "botIntents": [
      {
        "label": <string>,
        "nlg": <NLG>,
        "apiCall": <ApiDefinition>,  # optional
        "contextUpdates": [
          <ContextUpdate>, ...
        ]
      },
      ...
    ]
  }
}

Intent-wise update

Instead of uploading a complete game configuration, you can also update generic games by adding or deleting single intents.

Adding a user intent

POST <base>/projects/<projectId>/configurations/<configuration id>/games/<game id>/intents/user

cURL:

curl -X POST -d @user_intent.json --header "Authorization:Bearer <integration token>" https://api.mercury.ai/v1/projects/<projectId>/configurations/<configuration id>/games/<game id>/intents/user/

Example body:

[{
  "label": "Greeting",
  "reactions": [
    {
      "botIntent": "Hi"
    }
  ],
  "utterances": {
    "de": [
      "Hallo",
      "Hi",
      "Was geht?"
    ],
    "en": [
      "Hi",
      "Whats up?"
    ]
  }
}]
  • The label is the intent's unique identifier.
  • The reactions list should only contain one element. (It is a list because there can be different bot reactions depending on specific context conditions, but the definition of context parameters is not yet available via the API.)

The body can also be a list of user intents.

Response:

{"success":true}

Adding a bot intent

POST <base>/projects/<projectId>/configurations/<configuration id>/games/<game id>/intents/bot

cURL:

curl -X POST -d @bot_intent.json --header "Authorization:Bearer <integration token>" https://api.mercury.ai/v1/projects/<projectId>/configurations/<configuration id>/games/<game id>/intents/bot

Example body:

[{
  "label": "Hi",
  "contextUpdates": [],
  "nlg": {
    "de": {
      "web": [
        {
          "messages": [
            {
              "type": "Bubble",
              "delay": 0,
              "template": "text",
              "attachments": [
                {
                  "role": "NONE",
                  "text": "Hey! :)",
                  "type": "Text",
                  "format": "PLAIN"
                }
              ]
            }
          ],
          "callbacks": []
        }
      ]
    }
  }
}]
  • Again, the label is the intent's unique identifier.
  • The contextUpdates are a list of context updates, see Common datatypes.
  • The nlg field contains a list of variants per language and channel, see Common datatypes.

The body can also be a list of bot intents.

Response:

{"success":true}

Listing all intents

GET <base URL>/projects/<projectId>/configurations/<configuration id>/games/<game id>/intents

cURL:

curl --header "Authorization:Bearer <integration token>" https://api.mercury.ai/v1/projects/<projectId>/configurations/<configuration id>/games/<game id>/intents

Response:

{
  "success": true,
  "data": {
    "userIntents": [
      ...
    ],
    "botIntents": [
      ...
    ]
  }
}    

Deleting all user and bot intents

DELETE <base>/projects/<projectId>/configurations/<configuration id>/games/<game id>/intents

cURL:

curl -X DELETE --header "Authorization:Bearer <integration token>" https://api.mercury.ai/v1/projects/<projectId>/configurations/<configuration id>/games/<game id>/intents

Response:

{"success":true}