React
Integration Tutorial: Adding Interworky AI Agent to Your React Website


Last updated

Integration Tutorial: Adding Interworky AI Agent to Your React Website


Last updated
import { useEffect } from 'react';
const Interworky = ({ apiKey }) => {
useEffect(() => {
if (!apiKey) {
console.error('[Interworky] Missing API key');
return;
}
// create & inject the script
const s = document.createElement('script');
s.src =
'https://storage.googleapis.com/multisync/interworky/production/interworky.js';
s.async = true;
s.setAttribute('data-api-key', apiKey);
s.onload = () => {
window.Interworky?.init();
};
document.body.appendChild(s);
return () => {
document.body.removeChild(s);
};
}, [apiKey]);
return null;
};
export default Interworky;import React from 'react';
import Interworky from './components/Interworky';
const App = () => {
return (
<div>
<h1>Welcome to My Website</h1>
{/* Other application content */}
<Interworky apiKey={"YOUR_API_KEY"}/>
</div>
);
};
export default App;