Use Botsonic Chatbot With Rest API
Botsonic is a great product of Writesonic. I used it to create a chatbot using ChatGPT 4 model, and then request API with Python. However, there are some obstacles you may need to overcome.
Business Plan
On the pricing page, you can see that the free and plus plans are unable to access the API. You need to upgrade to the business plan.
The Right Way To Send A Request
Perhaps Botsonic evolves too fast, so some documents are outdated. For example, when you generate a Rest API, get the Endpoint and API token, and then click “View docs” button to redirect to the documents.
You will get a sample code. Everything seems perfect.
However, when you run the code in your Python editor, you will get an 422 error message:
"detail":"Invalid Token" "detail":["loc":["body"],"msg":"field required","type":"value_error.missing"]
The solution is in the next tab, API Reference. On this page, you can find some required parameters that are not mentioned in the sample code. For example, chat_id and chat_history are required, you need to add them to the JSON.
Here is the complete Python code and response:
import uuid
import requests
endpoint = "your endpoint"
token = "your token"
payload =
"input_text": "How to develop these skills? please answer.",
"chat_id": str(uuid.uuid4()),
"chat_history": [
"sent": True,
"message": "required history message"
]
headers =
"accept": "application/json",
"content-type": "application/json",
"token": token
response = requests.post(endpoint, json=payload, headers=headers)
print(response)
#
print(response.text)
#
# "answer":"To develop skills like humor, cleverness, and extensive knowledge for live streaming, engage in diverse reading, practice improvisation, study successful streamers, participate in workshops or courses on communication and comedy, and consistently interact with your audience to refine your approach based on feedback.","sources":[],"chat_history":["message":"How to develop these skills? please answer in English.","sent":true,"sources":null,"generated_images":null,"message":"To develop skills like humor, cleverness, and extensive knowledge for live streaming, engage in diverse reading, practice improvisation, study successful streamers, participate in workshops or courses on communication and comedy, and consistently interact with your audience to refine your approach based on feedback.","sent":false,"sources":[],"generated_images":null],"generated_images":null,"follow_up_questions":["What resources are needed to develop skills?","What is the process to develop skills?"]
https://aronhack.com/use-botsonic-chatbot-with-rest-api/?feed_id=44&_unique_id=6601af49e9ef0