With this API, you can request recommendation content that is generated for one widget or one dashboard (first three widgets on the dashboard) in a customer account. The result returned from the recommendations API is a JSON object that contains the recommendation text associated with the selected mode.
Pre-requisites:
- AI Service enabled for customer account
- AI Service enabled for user the clientId and clientSecret is tied to
- Permission to assets listed
- Permission to use model selected (if using openAI, key needs to be configured, customer setting must allow openAI for this feature)Parse suggestion
- Returns results of parsed NLP query
Get Recommendations for a Widget
Query
GET /api/1.0/widgets/<objectId>/insights/aiRecommendations?contentFilters={content_filters}
| Parameter | Required | Comments |
|---|---|---|
| <objectId> | Yes | widget id |
| contentFilters | No | The contentFilter is a JSON array of the field name, value, and operator of filters to be applied to the widget, which allows using of the same widget as a kind of template and generates different recommendations based on configured filters. [{"fieldName": "page", "values":["Products"], "operator":"="}]Available Operators for Content Filters: "Greater than" (>), "Greater than or equals" (>=), "Less than" (<), "Less than or equals" (<=), "Not Equals" (!=), "Equals" (=), "Contains", "Does Not Contain", "Range", "like", "not like", "in", "not in", "regexp", "is null", and "is not null" Note: All operators are applied to all field types, it depends on the field type for which operator they are required and some operators may not be applied. |
| context | No | A custom prompt used to guide the recommendation output. If a recommendation widget id is passed through, that widget's configured prompt is used instead. Otherwise, this value replaces the default prompt. |
| limit | No | Number of recommendations to return. Accepts values from 1 to 10. Defaults to 5. |
Response
| HTTP Status | Response |
|---|---|
| 200 OK | Output example: |
| 400 BAD_REQUEST |
|
| 401 UNAUTHORIZED |
|
| 403 FORBIDDEN |
|
Example call:
curl -i -X GET -H "Authorization: Bearer CRA31ajr5KeV6zH5OjeoipkerP0w56O3vFVVaNRWMTCQie" 'https://staging.knowi.com/api/1.0/widgets/46871/insights/aiRecommendations?context=generate%20recommendations%20for%20general%20public%20and%20oakland%20residents&limit=10'
Get Recommendations for a Dashboard
Query
GET /api/1.0/dashboards/<objectId>/insights/aiRecommendations?contentFilters={content_filters}
| Parameter | Required | Comments |
|---|---|---|
| <objectId> | Yes | dashboard id It will take the first 3 widgets with datasets (from top to bottom) and provide recommendations. |
| contentFilters | No | The contentFilter is a JSON array of the field name, value, and operator of filters to be applied to the dashboard, which allows using of the same dashboard as a kind of template and generates different recommendations based on configured filters. [{"fieldName": "page", "values":["Products"], "operator":"="}]Available Operators for Content Filters: "Greater than" (>), "Greater than or equals" (>=), "Less than" (<), "Less than or equals" (<=), "Not Equals" (!=), "Equals" (=), "Contains", "Does Not Contain", "Range", "like", "not like", "in", "not in", "regexp", "is null", and "is not null" Note: All operators are applied to all field types, it depends on the field type for which operator they are required and some operators may not be applied. |
| context | No | A custom prompt used to guide the recommendation output. If a recommendation widget id is passed through, that widget's configured prompt is used instead. Otherwise, this value replaces the default prompt. |
| limit | No | Number of recommendations to return. Accepts values from 1 to 10. Defaults to 5. |
Response
| HTTP Status | Response |
|---|---|
| 200 OK | Output example: |
| 400 BAD_REQUEST |
|
| 401 UNAUTHORIZED |
|
| 403 FORBIDDEN |
|
Example call:
curl -i -X GET -H "Authorization: Bearer HEREISYOUR_BEARER" 'https://www.knowi.com/api/1.0/dashboards/197821/insights/aiRecommendations?contentFilters=%5B%7B%22fieldName%22%3A%22page%22%2C%22values%22%3A%5B%22Products%22%5D%2C%22operator%22%3A%22%3D%22%7D%5D'