NAV Navbar
Logo
cURL javascript

FPT.AI API - 2.0

Introduction

FPT.AI is a conversational platform that allows developers to add a natural language interface to any app or any device. Common applications include:

There are two main components:

FPT.AI is available as a set of open APIs and SaaS products using latest cloud technologies. We offer a free tier for individual developers and comprehensive service packages for enterprise

Tutorial: Fresh food app

Creating application

Suppose you are a programmer and you want to earn extra income by selling fresh, organic foods from your hometown. Due to busy work, you are thinking of using chatbots for receiving orders.

After a week, you have programmed the application to connect with Facebook Messenger, now you need a natural language processing service and you’d like to try FPT.AI for this purpose.

You go to https://developers.fpt.ai to register an account. After receiving the notification email, you click the confirmation link in the email to activate the account.

After logging in to developers.fpt.ai, you start creating the app:

Create application

Create application

After creating the app, you go into the details of the app to start creating train data

Application detail

Creating Intents

To be able to train, you need to create at least 2 intents (as in the notice message).

Create new intent

Create new intent

Create new intent

Create two intents as below:

Create new intent

Creating Entities

Create new entity type

Create new entity type

Create new entity type

Create two entity types like this:

Create new entity type

Creating Samples

Create new sample

Create new sample

Click sample to mark named entities:

Create new sample

Create new sample

Create new sample

Add a few samples to the intent ‘product_info’:

Create new sample

Add some samples for intent ‘purchase’:

Create new sample

Creating Synonyms

TBD

Start training

After completing training samples, go back to the application detail interface:

Start training

Testing

After the training is completed (usually after a few minutes), refresh the page and use the test function:

Create new sample

History

After the testing is completed, review history of recognition:

Create new sample

Create new sample

Create new sample

Conclusion

So now you know how to use the interface of FPT.AI to create an application, to create intents/entities, to create training samples and to test the recognition.

Next, you can use the APIs listed below to do all of this programmatically (except for creating the application - you still have to create application manually to get the API token).

General

Authentication

Every API request sent to FPT.AI must have an Authorization HTTP header with the token of application.

Authorization: Bearer your_application_token

Example request

curl -X GET \
  https://api.fpt.ai/v1/intents \
  -H 'Authorization: Bearer your_application_token'

You application token is retrieved from your app:

Authen App Token

Error Code

FPT.AI response has list of error codes below:

Example response

{
    "code": "error_code",
    "message": "Not found"
}

Intent

List

Gets the list of all available intents for the application.

Example request

curl -X GET \
  https://api.fpt.ai/v2/intent \
  -H 'Authorization: Bearer your_application_token'

Example response

[
    {
        "code": "4qhvn1n1stx2tqs3i2i89uaw0xe6uaoh",
        "app_code": "ryca8xy0bza17j0f2xiv00ljg8j8gscs",
        "label": "purchase",
        "description": "Purchase",
        "created_time": "2018-01-11T09:07:03Z"
    },
    {
        "code": "ppmrtdpcuoxcxd0mg65lg4312pdg3u2e",
        "app_code": "ryca8xy0bza17j0f2xiv00ljg8j8gscs",
        "label": "product_info",
        "description": "Product information",
        "created_time": "2018-01-11T09:05:49Z"
    }
]

Request

GET https://api.fpt.ai/v2/intent

Parameters

Parameter Required Description
n/a n/a n/a

Response

Returns a list of available intents for the application.

Create

Creates a new intent with the given parameters.

Example request

curl -X POST \
  https://api.fpt.ai/v2/intent \
  -H 'Authorization: Bearer your_application_token' \
  -d '{
        "label":"product_info",
        "description":"Product information"
      }'

Example response

{
    "code": "ppmrtdpcuoxcxd0mg65lg4312pdg3u2e",
    "app_code": "ryca8xy0bza17j0f2xiv00ljg8j8gscs",
    "label": "product_info",
    "description": "Product information",
    "created_time": "2018-01-11T16:05:49.2237404+07:00"
}

Request

POST https://api.fpt.ai/v2/intent

Parameters

Parameter Required Description
label yes name of the intent, must use a-z0-9_
description yes description of the intent

Response

Returns a JSON object represents the created intent.

Get

Gets an intent with the given name.

Example request

curl -X GET \
  https://api.fpt.ai/v2/intent/product_info \
  -H 'Authorization: Bearer your_application_token'

Example response

{
    "code": "ppmrtdpcuoxcxd0mg65lg4312pdg3u2e",
    "app_code": "ryca8xy0bza17j0f2xiv00ljg8j8gscs",
    "label": "product_info",
    "description": "Product information",
    "created_time": "2018-01-11T09:05:49Z"
}

Request

GET https://api.fpt.ai/v2/intent/:intent_label

Parameters

Parameter Required Description
intent_label yes name of the intent

Response

Returns a JSON object that represents the intent.

Delete

Deletes an intent specified by name.

Example request

curl -X DELETE \
  https://api.fpt.ai/v2/intent/product_info \
  -H 'Authorization: Bearer your_application_token'

Example response

HTTP 200 OK

Request

DEL https://api.fpt.ai/v2/intent/:intent_label

Parameters

Parameter Required Description
intent_label yes name of the intent

Response

Returns HTTP Status 200 if the request succeed.

Update

Updates an intent specified by its name with the given parameters. You can update the description only.

Example request

curl -X PUT \
  https://api.fpt.ai/v2/intent/product_info \
  -H 'Authorization: Bearer your_application_token' \
  -d '{
    "description":"New Description"
  }'

Example response:

{
    "code": "ppmrtdpcuoxcxd0mg65lg4312pdg3u2e",
    "app_code": "ryca8xy0bza17j0f2xiv00ljg8j8gscs",
    "label": "product_info",
    "description": "New Description",
    "created_time": "2018-01-11T09:05:49Z"
}

Request

PUT https://api.fpt.ai/v2/intent/:intent_label

Parameters

Parameter Required Description
description yes new description of the intent

Response

Returns a JSON object that represents the updated intent.

Entity

List

Gets the list of all available entities for the application.

Example request

curl -X GET \
  https://api.fpt.ai/v2/entity \
  -H 'Authorization: Bearer your_application_token'

Example response

[
    {
        "code": "7j0lqsf2phw10oik1vkckl0dlf1k9msz",
        "app_code": "ryca8xy0bza17j0f2xiv00ljg8j8gscs",
        "label": "qty",
        "type": 1,
        "description": "Quantity",
        "created_time": "2018-01-11T09:22:40Z"
    },
    {
        "code": "qj9rbjqjazy8w73fr1h2q71zqct6dsz8",
        "app_code": "ryca8xy0bza17j0f2xiv00ljg8j8gscs",
        "label": "product_name",
        "type": 1,
        "description": "Product name",
        "created_time": "2018-01-11T09:18:31Z"
    }
]

Request

GET https://api.fpt.ai/v2/entity

Parameters

Parameter Required Description
n/a n/a n/a

Response

Returns a list of available entities for the application.

Create

Creates a new entity with the given parameters.

Example request

curl -X POST \
  https://api.fpt.ai/v2/entity \
  -H 'Authorization: Bearer your_application_token'
  -d '{
          "label":"product_name",
          "description":"Product name",
          "type": 1
      }'

Example response

{
    "code": "qj9rbjqjazy8w73fr1h2q71zqct6dsz8",
    "app_code": "ryca8xy0bza17j0f2xiv00ljg8j8gscs",
    "label": "product_name",
    "type": 1,
    "description": "Product name",
    "created_time": "2018-01-11T16:18:31.1608251+07:00"
}

HTTP Request

POST https://api.fpt.ai/v2/entity

Parameters

Parameter Required Description
label yes name of the entity, must use a-z0-9_
description yes description of the entity
type yes type of the entity, value: 1: keyword & freetext; 2: keyword; 3: freetext

Response

Returns a JSON object represents the created entity.

Get

Gets an entity with the given name.

Example request

curl -X GET \
  https://api.fpt.ai/v2/entity/product_name \
  -H 'Authorization: Bearer your_application_token'

Example response

{
    "code": "qj9rbjqjazy8w73fr1h2q71zqct6dsz8",
    "app_code": "ryca8xy0bza17j0f2xiv00ljg8j8gscs",
    "label": "product_name",
    "type": 1,
    "description": "Product name",
    "created_time": "2018-01-11T09:18:31Z"
}

HTTP Request

GET https://api.fpt.ai/v2/entity/:label

Parameters

Parameter Required Description
label yes name of the entity

Response

Returns a JSON object that represents the intent.

Delete

Deletes an entity specified by name.

Example request

curl -X DELETE \
  https://api.fpt.ai/v2/entity/product_name \
  -H 'Authorization: Bearer your_application_token'

Example response

HTTP 200 OK

HTTP Request

DEL https://api.fpt.ai/v2/entity/:label

Parameters

Parameter Required Description
label yes name of the entity

Response

Returns HTTP Status 200 if the request succeed.

Update

Updates an entity specified by its name with the given parameters. You can update the description only.

Example request

curl -X PUT \
  https://api.fpt.ai/v2/entity/product_name \
  -H 'Authorization: Bearer your_application_token'
  -d {
    "description":"New Description",
    "type":1
}

Example response

{
    "code": "qj9rbjqjazy8w73fr1h2q71zqct6dsz8",
    "app_code": "ryca8xy0bza17j0f2xiv00ljg8j8gscs",
    "label": "product_name",
    "type": 1,
    "description": "New Description",
    "created_time": "2018-01-11T09:18:31Z"
}

Request

PUT https://api.fpt.ai/v2/entity/:label

Parameters

Parameter Required Description
description yes new description of the entity
type yes type of the entity, value: 1: keyword & freetext; 2: keyword; 3: freetext

Response

Returns a JSON object that represents the updated entity.

Sample

List

Gets the list of all available samples.

Example request

curl -X GET \
  https://api.fpt.ai/v2/sample \

Example response:

[
    {
        "code": "2fcli497oqfbrvte2nevm5ft962y5svp",
        "app_code": "0xtqlndqkmuht0z1xcgzg0eyplz1jztk",
        "content": "Sample text 1",
        "created_time": "2017-10-24T13:47:17Z",
        "intent_label": "intent_label",
        "entities": [
            "sample_label_1",
            "sample_label_1",
            "sample_label_1",
            "sample_label_1",
            "sample_label_1"
        ]
    },
    {
        "code": "538dpdl7klrw9rhj4n4lqbxxarwl59cj",
        "app_code": "0xtqlndqkmuht0z1xcgzg0eyplz1jztk",
        "content": "sample text 2",
        "created_time": "2017-10-25T11:33:04Z",
        "intent_label": "intent_label_2",
        "entities": null
    },
    {
        "code": "670opm030i7c8hizwmiraewgrf5th4nx",
        "app_code": "0xtqlndqkmuht0z1xcgzg0eyplz1jztk",
        "content": "sample text 3",
        "created_time": "2017-10-25T11:38:30Z",
        "intent_label": "intent_label_3",
        "entities": null
    }
]

Request

GET https://api.fpt.ai/v2/sample

Parameters

Parameter Required Description
n/a n/a n/a

Response

Returns a list of available samples.

Create

Creates new sample.

Example request

curl -X POST \
  https://api.fpt.ai/v2/sample \
  -d '{
        "content": "Do you have fresh checken eggs?"
      }'

Example response

{
    "code": "inde8872kkv40g6jga8eyszfm0dz47vz",
    "app_code": "ryca8xy0bza17j0f2xiv00ljg8j8gscs",
    "content": "Do you have fresh checken eggs?",
    "created_time": "2018-01-11T16:00:44.025515Z"
}

HTTP Request

POST https://api.fpt.ai/v2/sample

Parameters

Parameter Required Description
content yes content of the sample

Response

Returns a JSON object represents the created sample.

Get

Gets an sample with the given sample code.

Example request

curl -X GET \
  https://api.fpt.ai/v2/sample/2fcli497oqfbrvte2nevm5ft962y5svp \
  -H 'Authorization: Bearer your_application_token'

Example response

{
    "code": "2fcli497oqfbrvte2nevm5ft962y5svp",
    "app_code": "0xtqlndqkmuht0z1xcgzg0eyplz1jztk",
    "content": "Sample text 1",
    "created_time": "2017-10-24T13:47:17Z",
    "intent": {
        "intent_sample_code": "il6pc9dvz1t8px2weebep60ygczav4b2",
        "intent_code": "7sdsWZJDQp",
        "sample_code": "2fcli497oqfbrvte2nevm5ft962y5svp",
        "intent_label": "intent_label"
    },
    "entities": [
        {
            "entity_sample_code": "7apu89e0co3hmcjai036yh695xqhsktv",
            "entity_code": "vfxpyqk5v9rn49zfcxf74hdra9h6zqx8",
            "sample_code": "2fcli497oqfbrvte2nevm5ft962y5svp",
            "parent_code": "",
            "value": "SomeValue",
            "start": 2,
            "end": 5,
            "created_time": "",
            "label": "sample_label_1",
            "Type": 1
        },
        {
            "entity_sample_code": "gudgybpeqxjokerfmrd96jxbjx5ngeae",
            "entity_code": "vfxpyqk5v9rn49zfcxf74hdra9h6zqx8",
            "sample_code": "2fcli497oqfbrvte2nevm5ft962y5svp",
            "parent_code": "",
            "value": "SomeValue",
            "start": 2,
            "end": 5,
            "created_time": "",
            "label": "sample_label_1",
            "Type": 1
        }
    ]
}

Request

GET https://api.fpt.ai/v2/sample/:sample_code

Parameters

Parameter Required Description
sample_code yes code of the sample

Response

Returns a JSON object that represents the sample.

Delete

Deletes an sample specified by its code.

Example request

curl -X DELETE \
  https://api.fpt.ai/v2/sample/2fcli497oqfbrvte2nevm5ft962y5svp \
  -H 'Authorization: Bearer your_application_token'

Example response

{
  "message": "Deleted"
}

Request

DEL https://api.fpt.ai/v2/sample/:sample_code

Parameters

Parameter Required Description
sample_code yes code of the sample

Response

Returns HTTP Status 200 if the request succeed.

Update

Updates an sample with the given parameters.

Example request

curl -X PUT \
  https://api.fpt.ai/v2/sample/2fcli497oqfbrvte2nevm5ft962y5svp \
  -H 'Authorization: Bearer your_application_token' \
  -d '{
    "content": "Sample text content updated"
}'

Example response

{
    "code": "2fcli497oqfbrvte2nevm5ft962y5svp",
    "app_code": "0xtqlndqkmuht0z1xcgzg0eyplz1jztk",
    "content": "Sample text content updated",
    "created_time": "2017-10-24T13:38:59Z"
}

Request

PUT https://api.fpt.ai/v2/sample/:sample_code

Query Parameters

Parameter Required Description
sample_code yes code of the sample
content yes content of the sample

Response

Returns a JSON object that represents the updated sample.

Intent-Sample mapping - Create

Maps an intent with a sample.

Example request

curl -X POST \
  https://api.fpt.ai/v2/intent-sample \
  -d '{
    "intent_code": "dds324dsfasd32zxfsd",
    "sample_code": "dfg34875s2345jkxcv3"
}'

Example response

{
    "intent_sample_code": "0X8pYfI0vWUR0uuVspjiaJRIQcf30e96",
    "intent_code": "dds324dsfasd32zxfsd",
    "sample_code": "dfg34875s2345jkxcv3"
}

HTTP Request

POST https://api.fpt.ai/v2/intent-sample

Parameters

Parameter Required Description
intent_code yes code of the intent
sample_code yes code of the sample

Response

Returns a JSON object represents the created intent-sample mapping.

Intent-Sample mapping - Delete

Unmap an intent from a sample by intent_sample_code.

Example request

curl -X DELETE \
  https://api.fpt.ai/v2/intent-sample/0X8pYfI0vWUR0uuVspjiaJRIQcf30e96 \
  -H 'Authorization: Bearer your_application_token'

Example response

{
    "code": 200,
    "message": "Deleted"
}

Request

DEL https://api.fpt.ai/v2/intent-sample/:intent_sample_code

Parameters

Parameter Required Description
intent_sample_code yes code of the map between intent and sample

Response

Returns a JSON object represents the result of deleting intent-sample mapping.

Intent-Sample mapping - Import

Create multiple intent-sample mappings.

Example request

curl -X POST \
  https://api.fpt.ai/v2/intent-sample/import_intent_samples \
  -d '[ 
          {
              "intent": "intent_1",
              "sample": "sample text 1"
          },
          {
              "intent": "intent_2",
              "sample": "sample text 2"
          }
      ]'

Example response

{
    "message": "Imported"
}

HTTP Request

POST https://api.fpt.ai/v2/intent-sample/import_intent_samples

Parameters

Parameter Required Description
content yes list of intent-sample mappings (JSON format)

Response

Returns a JSON object represents the created intent-sample mapping.

Entity-Sample mapping - Create

Maps an entity with a sample via tagging words and start/end position of that tagging words in the sample.

Example request

curl -X POST \
  https://api.fpt.ai/v2/entity-sample \
  -d '{
    "entity_code":"vfxpyqk5v9rn49zfcxf74hdra9h6zqx8",
    "sample_code":"2fcli497oqfbrvte2nevm5ft962y5svp",
    "value":"SomeValue",
    "start":2,
    "end":5
}'

Example response

{
    "entity_sample_code": "7apu89e0co3hmcjai036yh695xqhsktv",
    "entity_code": "vfxpyqk5v9rn49zfcxf74hdra9h6zqx8",
    "sample_code": "2fcli497oqfbrvte2nevm5ft962y5svp",
    "parent_code": "",
    "value": "SomeValue",
    "start": 2,
    "end": 5,
    "created_time": "2017-10-27T15:08:16Z"
}

HTTP Request

POST https://api.fpt.ai/v2/entity-sample

Parameters

Parameter Required Description
entity_code yes code of the entity
sample_code yes code of the sample
value yes tagging words
start yes star position of tagging words in the sample
end yes end position of tagging words in the sample

Response

Returns a JSON object represents the created entity-sample mapping.

Entity-Sample mapping - Delete

Unmap an entity from a sample by entity_sample_code.

Example request

curl -X DELETE \
  https://api.fpt.ai/v2/entity-sample/7apu89e0co3hmcjai036yh695xqhsktv \
  -H 'Authorization: Bearer your_application_token'

Example response

{
    "code": 200,
    "message": "Deleted"
}

Request

DEL https://api.fpt.ai/v2/entity-sample/:entity_sample_code

Parameters

Parameter Required Description
entity_sample_code yes code of the map between entity and sample

Response

Returns a JSON object represents the result of deleting entity-sample mapping.

Train

All

Requests FPT.AI to train/re-retrain for both intent model and entity model for the application.

Note: You MUST have at least 2 intents and 2 samples to train.

Example request

curl -X POST \
  https://api.fpt.ai/v2/train \
  -H 'Authorization: Bearer your_application_token' \

Example response

{
    "message": "training request is accepted",
    "status": [
        {
            "code": "vfxpyqk5v9rn49zfcxf74hdra9h63xs6",
            "app_code": "0xtqlndqkmuht0z1xcgzg0eyplz1jztk",
            "type": 2,
            "state": 1,
            "message": "xyz",
            "model_file": "model_path",
            "accuracy": 0,
            "precision": 0,
            "recal": 0,
            "f1": 0,
            "created_time": "2017-10-25T16:56:54Z",
            "finished_time": "0001-01-01T00:00:00Z"
        },
        {
            "code": "vfxpyqk5v9rn49zfcxf74hdra9h6zqx8",
            "app_code": "0xtqlndqkmuht0z1xcgzg0eyplz1jztk",
            "type": 1,
            "state": 0,
            "message": "abc",
            "model_file": "model_path",
            "accuracy": 0,
            "precision": 0,
            "recal": 0,
            "f1": 0,
            "created_time": "2017-10-25T16:52:45Z",
            "finished_time": "0001-01-01T00:00:00Z"
        }
    ]
}

Request

POST https://api.fpt.ai/v2/train

Parameters

Parameter Required Description
n/a n/a n/a

Response

Returns a JSON message represents the training status.

Intent

Requests FPT.AI to train/re-retrain intent model for the application.

Note: You MUST have at least 2 intents to train.

Example request

curl -X POST \
  https://api.fpt.ai/v2/train/intent \
  -H 'Authorization: Bearer your_application_token' \

Example response

{
    "message": "training request is accepted"
}

Request

POST https://api.fpt.ai/v2/train/intent

Parameters

Parameter Required Description
n/a n/a n/a

Response

Returns a JSON message represents the training status.

Entity

Requests FPT.AI to train/re-retrain entity model for the application.

Example request

curl -X POST \
  https://api.fpt.ai/v2/train/entity \
  -H 'Authorization: Bearer your_application_token' \

Example response

{
    "message": "training request is accepted"
}

Request

POST https://api.fpt.ai/v2/train/entity

Parameters

Parameter Required Description
n/a n/a n/a

Response

Returns a JSON message represents the training status.

Status

Get current training status.

Example request

curl -X GET \
  https://api.fpt.ai/v2/train/status \
  -H 'Authorization: Bearer your_application_token' \

Example response

{
    "status": 0
}

Request

POST https://api.fpt.ai/v2/train/entity

Parameters

Parameter Required Description
n/a n/a n/a

Response

Returns a JSON message represents the training status:

Predict

All

Requests FPT.AI to predict for both intents of and entities in the given text.

Example request

curl -X POST \
  https://api.fpt.ai/v2/predict \
  -H 'Authorization: Bearer your_application_token' \
  -d '{
  "content": "do you have fresh chicken eggs?",
  "save_history": false
}'

Example response

{
    "status": {
        "code": 200,
        "message": "Predict All successful",
        "module": "",
        "api_code": 0,
        "err_code": 0
    },
    "data": {
        "intents": [
            {
                "label": "product_info",
                "confidence": 0.99
            },
            {
                "label": "purchase",
                "confidence": 0.005
            }
        ],
        "entities": [
            {
                "start": 18,
                "end": 30,
                "value": "chicken eggs",
                "real_value": "chicken eggs",
                "entity": "product_name",
                "subentities": []
            }
        ]
    }
}

Request

POST https://api.fpt.ai/v2/predict

Parameters

Parameter Required Description
content yes text to predict
save_history no save to history

Response

Returns a JSON object that contains predicted intents and entities with confidence values.

Intent

Requests FPT.AI to predict for intents of the given text.

Example request

curl -X POST \
  https://api.fpt.ai/v2/predict/intent \
  -H 'Authorization: Bearer your_application_token' \
  -d '{
  "content": "do you have fresh chicken eggs?"
}'

Example response

{
    "status": {
        "code": 200,
        "message": "Predict Intents successful",
        "module": "",
        "api_code": 0,
        "err_code": 0
    },
    "data": {
        "intents": [
            {
                "label": "product_info",
                "confidence": 0.99
            },
            {
                "label": "purchase",
                "confidence": 0.005
            }
        ]
    }
}

Request

POST https://api.fpt.ai/v2/predict/intent

Paramenters

Parameter Required Description
content yes text to predict
save_history no save to history

Response

Returns a JSON object that contains predicted intents with confidence values.

Entity

Requests FPT.AI to predict for entities in the given text.

Example request

curl -X POST \
  https://api.fpt.ai/v2/predict/entity \
  -H 'Authorization: Bearer your_application_token' \
  -d '{
  "content": "I'd like to purchase some fresh vegetable",
  "save_history": false
}'

Example response

{
    "status": {
        "code": 200,
        "message": "Recognize Entities successful",
        "module": "",
        "api_code": 0,
        "err_code": 0
    },
    "data": {
        "entities": [
            {
                "start": 32,
                "end": 41,
                "value": "vegetable",
                "real_value": "vegetable",
                "entity": "product_name",
                "subentities": []
            }
        ]
    }
}

Request

POST https://api.fpt.ai/v2/predict/entity

Paramenters

Parameter Required Description
content yes text to predict

Response

Returns a JSON object that contains predicted entities with confidence values.

Keyword

List

Gets the list of all available keywords for the entity.

Example request

curl -X GET \
  https://api.fpt.ai/v2/keyword/entity_label \
  -H 'Authorization: Bearer your_application_token'

Example response

[
    {
        "code": "m7hu5iywe8sz7n9puleell0kn1dpv4rl",
        "entity_code": "vfxpyqk5v9rn49zfcxf74hdra9h6zqx8",
        "value": "keyword 1",
        "synonym": "[]"
    },
    {
        "code": "s90q14jnvh8hb7fe5xfhdskmmr1emuro",
        "entity_code": "vfxpyqk5v9rn49zfcxf74hdra9h6zqx8",
        "value": "keyword 2",
        "synonym": "[\"syn1\", \"syn2\"]"
    }
]

Request

GET https://api.fpt.ai/v2/keyword/:entity_label

Parameters

Parameter Required Description
entity_label yes label of the entity

Response

Returns a list of available keywords for the entity.

Create

Creates a new keyword of the entity with the given parameters.

Example request

curl -X POST \
  https://api.fpt.ai/v2/keyword/entity_label \
  -H 'Authorization: Bearer your_application_token' \
  -d '{
    "value": "keyword",
    "synonym": "[\"synonym\"]"
}'

Example response

{
    "code": "lpnakotptlo06bhnz9ttzfgaielxxi7j",
    "entity_code": "vfxpyqk5v9rn49zfcxf74hdra9h6zqx8",
    "value": "keyword",
    "synonym": "[\"synonym\"]"
}

Request

POST https://api.fpt.ai/v2/keyword/:entity_label

Parameters

Parameter Required Description
entity_label yes label of the entity
value yes keyword
synonym no list of synonyms for the keyword

Response

Returns a JSON object represents the created keyword for the entity.

Get

Gets an keyword of entity with the given keyword code.

Example request

curl -X GET \
  https://api.fpt.ai/v2/keyword/entity_label/lpnakotptlo06bhnz9ttzfgaielxxi7j \
  -H 'Authorization: Bearer your_application_token'

Example response

{
    "code": "lpnakotptlo06bhnz9ttzfgaielxxi7j",
    "entity_code": "vfxpyqk5v9rn49zfcxf74hdra9h6zqx8",
    "value": "keyword",
    "synonym": "[\"synonym\"]"
}

Request

GET https://api.fpt.ai/v2/keyword/:entity_label/:keyword_code

Parameters

Parameter Required Description
entity_label yes label of the entity
keyword_code yes code of the keyword

Response

Returns a JSON object that represents the keyword.

Delete

Deletes an intent specified by name.

Example request

curl -X DELETE \
  https://api.fpt.ai/v2/keyword/entity_label/lpnakotptlo06bhnz9ttzfgaielxxi7j \
  -H 'Authorization: Bearer your_application_token'

Example response

{
    "message": "Deleted"
}

Request

DEL https://api.fpt.ai/v2/keyword/:entity_label/:keyword_code

Parameters

Parameter Required Description
entity_label yes label of the entity
keyword_code yes code of the keyword

Response

Returns a JSON object that represents deleting result.

Update

Updates an keyword specified by its code with the given parameters.

Example request

curl -X PUT \
  https://api.fpt.ai/v2/keyword/entity_label/lpnakotptlo06bhnz9ttzfgaielxxi7j \
  -H 'Authorization: Bearer your_application_token' \
  -d '{
    "value": "keyword",
    "synonym": "[\"synonym\"]"
}'

Example response:

{
    "code": "lpnakotptlo06bhnz9ttzfgaielxxi7j",
    "entity_code": "vfxpyqk5v9rn49zfcxf74hdra9h6zqx8",
    "value": "keyword",
    "synonym": "[\"synonym\"]"
}

Request

PUT https://api.fpt.ai/v2/keyword/:entity_label/:keyword_code

Parameters

Parameter Required Description
entity_label yes label of the entity
keyword_code yes code of the keyword
value yes value of the keyword
synonym yes list of synonyms for the keyword

Response

Returns a JSON object that represents the updated keyword.

History

List

Gets list of predict history.

Example request

curl -X GET \
  https://api.fpt.ai/v2/predict/history \
  -H 'Authorization: Bearer your_application_token'

Example response

[
    {
        "id": "1",
        "app_code": "37sdVS88sdnb73vasdjdkjfyz",
        "sample_code": "",
        "text": "good morning",
        "intent": "",
        "result_data": "{\"entities\":[],\"intents\":[{\"label\":\"hiii\",\"confidence\":0.637029},{\"label\":\"dd\",\"confidence\":0.362971}]}",
        "created_time": "2017-08-11 11:39:34",
        "is_deleted": "0"
    },
    {
        "id": "1",
        "app_code": "37sdVS88sdnb73vasdjdkjfyz",
        "sample_code": "fdfdf743539ndfjdb892334hdf",
        "text": "say some thing",
        "intent": "hiii",
        "result_data": "{\"entities\":[],\"intents\":[{\"label\":\"hiii\",\"confidence\":0.637029},{\"label\":\"dd\",\"confidence\":0.362971}]}",
        "created_time": "2017-08-11 11:39:34",
        "is_deleted": "0"
    }
]

Request

GET https://api.fpt.ai/v2/predict/history

Parameters

Parameter Required Description
n/a n/a n/a

Response

Returns a list of available predict history.

Delete

Deletes a predict history.

Example request

curl -X DELETE \
  https://api.fpt.ai/v2/predict/history/1 \
  -H 'Authorization: Bearer your_application_token'

Example response

{
    message: 'Deleted'
}

Request

DEL https://api.fpt.ai/v2/predict/history/:history_id

Parameters

Parameter Required Description
history_id yes id of the predict history

Response

Returns HTTP Status 200 if the request succeed.

Update

Updates a predict history specified by its id with the given parameters.

Example request

curl -X PUT \
  https://api.fpt.ai/v2/predict/history/1 \
  -H 'Authorization: Bearer your_application_token' \
  -d '{
    "intent_label": "hello",
    "sample_code": "fdfdf743539ndfjdb892334hdf"
}'

Example response:

{
    "id": "1",
    "app_code": "37sdVS88sdnb73vasdjdkjfyz",
    "sample_code": "fdfdf743539ndfjdb892334hdf",
    "text": "say some thing",
    "intent": "hello",
    "result_data": "{\"entities\":[],\"intents\":[{\"label\":\"hiii\",\"confidence\":0.637029},{\"label\":\"dd\",\"confidence\":0.362971}]}",
    "created_time": "2017-08-11 11:39:34",
    "is_deleted": "0"
}

Request

PUT https://api.fpt.ai/v2/predict/history/:history_id

Parameters

Parameter Required Description
history_id yes id of the predict history
intent_label yes label of the intent
sample_code yes code of the sample

Response

Returns a JSON object that represents the updated predict history.

QnA

Get answer

Get answer from QnA for provided question. If the confident score is below defined threshold, then it will return three most matching answers

Example request

curl -X GET \
  'https://qna.fpt.ai/api/bot/answer?text=Xin%20chao' \
  -H 'Authorization: <application code>'

Example response (single answer)

[
    {
        "question": "Xin chao",
        "answer": "Xin chào bạn tôi là trợ lí ảo",
        "source": "fptai"
    }
]

Example response (multiple answers)

[
    {
        "question": "matching question 1...",
        "answer": "answer 1...",
        "source": "elasticsearch"
    },
    {
        "question": "matching question 2...",
        "answer": "answer 2...",
        "source": "elasticsearch"
    },
    {
        "question": "matching question 3...",
        "answer": "answer 3...",
        "source": "elasticsearch"
    }
]

Request

GET https://qna.fpt.ai/api/bot/answer

Query string

Parameter Required Description
text yes User question

HTTP header

Header Required Description
Authorization yes Application code

Response

Returns a JSON object that contain an array of answers for provided question. Each answer has following fields:

Field Description
question Question in system that match with user question
answer Answer for that question
source Source that provide the result, can be fptai or elasticsearch

Migration

  1. Go to FPT AI V1
  2. Select your app
  3. Click button EXPORT SAMPLE
  4. Open exported file in Excel, after that, click File menu and Save as XLSX format.
  5. Go to FPT AI V2
  6. Use your registered email instead of username to login to FPT AI V2
  7. Create new app
  8. Open your app and click button IMPORT SAMPLE, select XLSX file to import
  9. Select each sample and tag entity if need
  10. Click button TRAIN
  11. Type any sentence you want to test on Try it now area.