Drop files here
or click to upload
import streamlit as st
import requests
# Page configuration
st.set_page_config(page_title="CRM Chatbot", layout="centered")
st.title(":robot_face: CRM Chatbot Assistant")
# Chat history
if "chat_history" not in st.session_state:
st.session_state.chat_history = []
# Input field
user_question = st.text_input("Ask a question about CRM opportunities:")
# Send button
if st.button("Send") and user_question:
# Add user message to chat history
st.session_state.chat_history.append(("You", user_question))
# API details
url = "https://emea.snaplogic.com/api/1/rest/slsched/feed/ConnectFasterInc/snapLogic4snapLogic/Bootcamp_EMEA_August_2025/Task_TR_CRM_Retriever_Chakravarthi"
headers = {
"Authorization": "Bearer WRRH",
"Content-Type": "application/json"
}
payload = [{"Question": user_question}]
try:
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 200:
data = response.json()
bot_reply = data[0].get("Response", "No response found.")
st.session_state.chat_history.append(("Bot", bot_reply))
else:
error_msg = f"API Error {response.status_code}: {response.text}"
st.session_state.chat_history.append(("Bot", error_msg))
except Exception as e:
st.session_state.chat_history.append(("Bot", f"Request failed: {e}"))
# Display chat history
st.subheader("Conversation")
for sender, message in st.session_state.chat_history:
st.markdown(f"**{sender}:** {message}")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?