To upload files, please first save the app
import streamlit as st
import requests
import urllib.parse
st.title("Customer Story Generator Chatbot")
prompt = st.text_input("Enter your prompt", "Write a customer story Elkjop")
customer_name = st.text_input("Customer name", "Elkjop")
language = st.selectbox("Language", ["English", "French", "German"], index=0)
if st.button("Generate Story"):
with st.spinner("Generating story..."):
# Encode endpoint safely
task_path = urllib.parse.quote("customer_story_speach Task")
url = f"https://emea.snaplogic.com/api/1/rest/slsched/feed/ConnectFasterInc/snapLogic4snapLogic/Bootcamp_EMEA_June_2025/{task_path}"
headers = {
"Authorization": "Bearer hZNwFVyQq0kJ6P0b43jJJzRixosEn3xX",
"Content-Type": "application/json"
}
payload = {
"Prompt": prompt,
"customer_name": customer_name,
"language": language
}
try:
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
story = response.json().get("response", "No story returned.")
st.subheader("Generated Customer Story")
st.text_area("Output", story, height=400)
except requests.exceptions.RequestException as e:
st.error(f"API call failed:\n{e}")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?