@sarujan/s_bot_creator 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +10 -21
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -13,23 +13,14 @@ export const BotWidget = ({ botId }) => {
13
13
  const [input, setInput] = useState('');
14
14
  const msgEndRef = useRef(null);
15
15
 
16
- // useEffect(() => {
17
- // // 1. Fetch config for colors and branding
18
- // fetch(`https://api.botbuilder.ai/v1/config/${botId}`)
19
- // .then(res => res.json())
20
- // .then(data => {
21
- // setConfig(data);
22
- // setMessages([{ role: 'model', text: data.greetingMessage }]);
23
- // });
24
- // }, [botId]);
25
- // Temporarily replace your useEffect fetch with this to test UI:
26
16
  useEffect(() => {
27
- setConfig({
28
- primaryColor: '#007bff',
29
- name: 'Test Bot',
30
- greetingMessage: 'Hello! I am working.'
31
- });
32
- setMessages([{ role: 'model', text: 'Hello! I am working.' }]);
17
+ // 1. Fetch config for colors and branding
18
+ fetch(`http://127.0.0.1:8000/api/config/${botId}`)
19
+ .then(res => res.json())
20
+ .then(data => {
21
+ setConfig(data);
22
+ setMessages([{ role: 'model', text: data.greetingMessage }]);
23
+ });
33
24
  }, [botId]);
34
25
 
35
26
  useEffect(() => {
@@ -44,13 +35,13 @@ export const BotWidget = ({ botId }) => {
44
35
  setMessages(prev => [...prev, userMsg]);
45
36
  setInput('');
46
37
 
47
- const res = await fetch('https://api.botbuilder.ai/v1/chat', {
38
+ const res = await fetch('http://127.0.0.1:8000/api/chat/', {
48
39
  method: 'POST',
49
40
  headers: { 'Content-Type': 'application/json' },
50
- body: JSON.stringify({ botId, message: input })
41
+ body: JSON.stringify({ botId, message: input, history: messages })
51
42
  });
52
43
  const data = await res.json();
53
- setMessages(prev => [...prev, { role: 'model', text: data.text }]);
44
+ setMessages(prev => [...prev, { role: 'model', text: data.response }]);
54
45
  };
55
46
 
56
47
  if (!config) return null;
@@ -108,5 +99,3 @@ export const BotWidget = ({ botId }) => {
108
99
  document.body
109
100
  );
110
101
  };
111
-
112
- export default BotWidget;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarujan/s_bot_creator",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "No code Rag bot React widget",
5
5
  "main": "index.js",
6
6
  "type": "module",