Drop files here
or click to upload
import streamlit as stimport streamlit as st
import requests
import json
API_ENDPOINT = "https://emea.snaplogic.com/api/1/rest/slsched/feed/ConnectFasterInc/snapLogic4snapLogic/Bootcamp_EMEA_August_2025/CRM_retriver_Chandra%20Task"
AUTH_TOKEN = "111222"
st.set_page_config(page_title="CRM Chatbot", page_icon="💬")
st.title("CRM Chatbot 👩💼")
# Message history for chat display
if "messages" not in st.session_state:
st.session_state.messages = []
def get_bot_response(question):
headers = {"Authorization": AUTH_TOKEN, "Content-Type": "application/json"}
payload = [{"Question": question}]
try:
response = requests.post(API_ENDPOINT, headers=headers, data=json.dumps(payload), timeout=10)
response.raise_for_status()
data = response.json()
if data and isinstance(data, list) and "Response" in data[0]:
return data[0]["Response"]
else:
return "Sorry, I received an unexpected response from the server."
except requests.exceptions.RequestException as e:
return f"API error: {str(e)}"
# Chat input
user_input = st.text_input("Ask a question:", key="user_input")
if user_input:
st.session_state.messages.append({"role": "user", "content": user_input})
bot_reply = get_bot_response(user_input)
st.session_state.messages.append({"role": "bot", "content": bot_reply})
st.experimental_rerun()
# Display chat history
for msg in st.session_state.messages:
if msg["role"] == "user":
st.markdown(f"**You:** {msg['content']}")
else:
st.markdown(f"**Bot:** {msg['content']}")
st.caption("Powered by Streamlit & SnapLogic API")
import pandas as pd
import numpy as np
# Create some sample data
x = np.linspace(0, 10, 100)
y = np.sin(x)
# Add some text
st.title('Simple Streamlit App')
st.write('Welcome! This is a basic demonstration of Streamlit.')
# Display the data
st.subheader('Sample Data')
df = pd.DataFrame({
'x': x,
'y': y
})
st.dataframe(df.head())
# Create some plots
st.subheader('Line Plot')
st.line_chart(df.set_index('x'))
st.subheader('Area Chart')
st.area_chart(df.set_index('x'))
# Add interactive elements
st.subheader('Interactive Elements')
name = st.text_input('Enter your name')
if name:
st.write(f'Hello {name}!')
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?