get

http://api.brainshop.ai/get?bid=[bid]&key=[key]&uid=[uid]&msg=[msg]

Description

This API returns a contextual reply (robot message) to a user message. You should use this API to deploy a brain to your own system.

Note: If you're using the depreciated domain api.brainshop.ai for the API, we encourage you to migrate it to api.acobot.net for better performance.

Parameters

  • bid: The brain ID.
  • key: The access key for the brain.
  • uid: The ID you assign to end user.
  • msg: The message from user.

To obtain the bid and key for a brain,

  1. Click the brain in the left side bar.
  2. Click Settings tab.

The bid and key can be found there.

Return Values

This API returns a JSON string structured as below

{
  "cnt":"[value]"
}

The JSON includes only one datum, 'cnt', the content of reply given by the brain. The reason to use JSON for a single datum here is we are extending the API and it will deliver more data in the future. The below is an example of possible JSON with more data.

{
  "cnt":"[value]",
  "scr":"[value]",
  "tts":"[value]",
  "face":"[value]"
}

To display the reply to end users, you need to convert JSON to an object or array (decoding) and then extract the content from the "cnt" data. You may search for the specific method to decode a JSON in your programming language.