Page cover

React

Integration Tutorial: Adding Interworky AI Agent to Your React Website

Step-by-Step Guide:

1. Log into the Interworky Dashboard

• After creating your Interworky account, log into the Interworky dashboard.

• Navigate to the Integration Page.

Integration Page - Interworky Dashboard
  1. Locate the Embed Code

  • In the Integration Page, locate the Embed Code section.

  • Capture your api-key next to data-api-key=

Integration Page (Copied) - Interworky Dashboard
  1. Create the Interworky Component

Create Interworky Component in your react project, copy and paste the code below

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;
  1. Add the Interworky Component to your Application

  • Include the Interworky component in your application where you want the assistant to be initialized.

For example, you can include it in your App.jsx or a specific page component.

Use the API Key from step 2

See Example below:

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;

And Tadaa 🎉, you just integrated Interworky AI Agent into your React project.

If you have any questions about the Interworky React Integration, please reach out to our support team at hello@interworky.com. We're here to help!

Last updated