FAQs

Submitting and retrieving Frequently Asked Questions

Last updated: 28 October 2022

Existing, predefined FAQs can be indexed. When a question is posted, Viko will first perform a semantic search of all indexed FAQs. If no suitable match can be found, Viko will then try to extract or generate an answer using documents for context. For more information please read the introductory document explaining FAQs and Answered Questions (AQs)

Contents

  1. Put FAQ
  2. Get FAQ
  3. Delete FAQ
  4. List FAQ folders
  5. List FAQs
  6. List AQs - Frequent, previously asked questions (FAQ candidates)

The examples in this document use the stubbed endpoint. Remember to swap over to the real endpoint !

PUT FAQ

Update a predefined FAQ or index a new FAQ with a developer supplied id.

Request

PUT https://api.viko.ai/v1-beta/{tenancy}/faqs/{folder}/{id} (note: no trailing slash)

Request headers

Content-Type application/json (required)
X-Api-Key (required)

Request body

{
  question: string (required)
  answer: string (required)
  context: string (optional)
  link: string (optional)
}

Response

Status 202 (Accepted)

Response body

{
  question: string (required)  
  answer: string (required)
  context: string (optional)
  link: string (optional)  
}

Example

$ curl \
  --header 'X-Api-Key: replaceme' \
  --header 'Content-Type: application/json' \
  --request PUT 'https://stub.viko.ai/v1-beta/acme/faqs/shipping/1' \
  --data-raw '{
    "question": "how much is next day shipping",
    "answer": "$4.95",
    "context": "We offer free standard delivery and premium next day delivery",
    "link": "https://acme.com/shipping.html"
  }'
{
  "question": "how much is next day shipping",
  "answer": "$4.95",
  "context": "We offer free standard delivery and premium next day delivery",
  "link": "https://acme.com/shipping.html"
}

Get FAQ

Request

GET https://api.viko.ai/v1-beta/{tenancy}/faqs/{folder}/{id} (note: no trailing slash)

Request headers

X-Api-Key (required)

Response

Status 200 (Ok)

Response body

{
  question: string (required)
  answer: string (required)
  context: string (optional)
  link: string (optional)  
}

Example

$ curl \
  --header 'X-Api-Key: replaceme' \
  'https://stub.viko.ai/v1-beta/acme/faqs/shipping/1'
{
  "question": "how much is next day shipping?",
  "answer": "$4.95",
  "context": "We offer free standard delivery and premium next day delivery",
  "link": "https://acme.com/shipping.html"
}

Delete FAQ

Request

DELETE https://api.viko.ai/v1-beta/{tenancy}/faqs/{folder}/{id} (note: no trailing slash)

Request headers

X-Api-Key (required)

Response

Status 202 (Accepted)

Response body

{
  status: "deleted" (required)
  id: string (required)
}

Example

$ curl \
  --header 'X-Api-Key: replaceme' \
  --request DELETE 'https://stub.viko.ai/v1-beta/acme/faqs/shipping/1'
{
  "status": "deleted",
  "id": "1"
}

List FAQ folders

Request

GET https://api.viko.ai/v1-beta/{tenancy}/faqs/ (note: trailing slash)

Request headers

X-Api-Key (required)

Response

Status 200

Response body

{
  folders: [
    {
      name: string
      count: number
    }
  ],
  total: number (required) // total FAQs in the index
}

Example

$ curl \
  --header 'X-Api-Key: replaceme' \
  'https://stub.viko.ai/v1-beta/acme/faqs/'
{
  "folders": [
    {
      "name": "shipping",
      "count": 1
    }
  ],
  "total": 1
}

List FAQs

Request

GET https://api.viko.ai/v1-beta/{tenancy}/faqs/{folder}/ (note: trailing slash)

Query parameters

limit (optional - integer)
offset (optional - integer)

Request headers

X-Api-Key (required)

Response

Status 200
Body JSON object

{
  folder: string (required)
  faqs: [
    {
      id: string (required)
      question: string (required)
      answer: string (required)
      context: string (optional)
      link: string (optional)
    }
  ],
  total: number
}

Example

$ curl \
  --header 'X-Api-Key: replaceme' \
  'https://stub.viko.ai/v1-beta/acme/faqs/shipping/?limit=10&offset=0'
{
  "folder": "shipping",
  "faqs": [
    {
      "id": "1",
      "question": "how much is next day shipping?",
      "answer": "$4.95",
      "context": "We offer free standard delivery and premium next day delivery",
      "link": "https://acme.com/shipping.html"      
    }
  ],
  "total": 1
}

List Answered Questions (AQs)

Request

GET https://api.viko.ai/v1-beta/{tenancy}/aq/

Request headers

X-Api-Key: (required)

Response

Status: 200

Response body

{
  aqs: [
    {
      question: string (required)
      answer: string (required)
      count: number (required) // number of times question was asked
    }
  ],
  total: number
}

Example

$ curl \
  --header 'X-Api-Key: replaceme' \
  'https://stub.viko.ai/v1-beta/acme/aqs/'
{
  "aqs": [
    {
      "question": "How much is next day shipping",
      "answer": "$4.95",
      "count": 5
    }
  ],
  "total": 1
}

Try Viko

Want to see Viko in action? Try our interactive demos