{
'query': ['hi'],
'userid': '123',
'chat': ['Hi. I am here to help. What can I do for you today?'],
'next_search': {},
'search': {},
'filtered': {},
'response_status': 1,
'domain': {},
'response_code': 0,
'ff_data': {},
'options': [],
'meta_data': {},
'source_type': '',
'score': 0,
'sessionid': 'ejSKKBZ8l0vY8Ed4_212202423118',
'hist_data': {},
'summary': '',
'risk_data': {},
'risk_report': '',
'dx_report': {},
'bot_name': 'test'}
import requests
import json
# API endpoint URL
api_url = 'https://chatbot.cogxta.com/ai/chat'
# JSON data to be sent in the POST request
payload = {
'query': 'hi',
'userid': '123',
'bot_name': 'test',
'sessionid': 'ejSKKBZ8l0vY8Ed4_212202423118',
'gender': 'both',
'sources': '|Trained Schema|Q&A|Documents|Symptom Checker|Web References'
}
# Convert payload to JSON format
json_payload = json.dumps(payload)
# Set headers (if required by the API)
headers = {
'Content-Type': 'application/json'
}
try:
# Make POST request with JSON data
response = requests.post(api_url, data=json_payload, headers=headers)
# Check if the request was successful (status code 200)
if response.status_code == 200:
# Print the API response
print("API Response:")
print(response.json()) # Print the JSON response
return response.json()["chat_response"]
else:
print(f"Request failed with status code: {response.status_code}")
except requests.RequestException as e:
print(f"Request Exception: {e}")
response{};
response["Error":str(e)]
return response