😼Stream Conversation (REST)

For now, the endpoint only accept POST request to chat with your bot. Websocket Request is coming soon.

Endpoint

The endpoint to access this history summary is working with a POST request, this time the API Token is not necessary.

https://www.owlbot.ai/api/chatbot/ask

Parameters needed

This post request required at least 3 parameters :

Property
Type
Description

prompt

string

Required. The question ask to the chatbot (can not exceed 3000 characters)

chatbotUuid

uuid

Required. The UUID of the chatbot your speaking with.

session

uuid

Required. The UUID of the session your in.

The session parameter can be :

  • "anonymous" : in this case, you will not be able to manage user conversation history and to get sources from the answer provided by chatbot. Each question asked by users are treated separately and user can not see his own history when ending session.

  • uuid : in this case, you have to provide a valid and unique UUID to distinguish every users. In this case, you will be able to recover each user history and to get sources.

Examples

In Vanilla Javascript

 async function _sendMessage(message) {
   
    let post = { prompt: message, chatbotUuid: "3c895cd5-1298-4f30-8417-XXXX", 
    session: "d48a5374-e952-4c5f-8c0f-XXXXXXX"}
    
    const response = await fetch(`https://www.owlbot.ai/api/chatbot/ask`, {
      method: 'POST',
      body: JSON.stringify(post),
    })

    if (!response.ok) {
      throw new Error(response.statusText)
    }

    const data = response.body
    if (!data) {
      return
    }

    const reader = data.getReader()
    const decoder = new TextDecoder()
    let done = false

     let answer = "";

    while (!done) {
      const { value, done: doneReading } = await reader.read()
      done = doneReading
      const chunkValue = decoder.decode(value)
      answer  += chunkValue 
        return answer  
      })

    }

    if (done) {
      answer   = ''

      console.log('done')
    }
  }

Last updated