1

I'm trying to create a chatbox for my React website usig dialogflow. It is currently using some default code. which shows a template chatbot User interface. I need to add a close/minimise button to it? Can anyone help?

My current code for the chatbot uses this iframe

<iframe
       allow="microphone;"
        width="100%"
        height="300vh"
    src="https://console.dialogflow.com/api-client/demo/embedded/<some keycde>"
></iframe>

'''

Umashankar Das
  • 601
  • 4
  • 12

1 Answers1

2

just create a boolean to toggle the iframe jsx, like this.

import React, { useState } from "react";
import "./styles.css";
import ParentComp from "./ParentComp";
export default function App() {
  const [bool, handleBool] = useState(true);
  return (
    <div className="App">
      <ParentComp>
        <div>I am div</div>
      </ParentComp>
      {bool && (
        <iframe
          title="I frameva"
          allow="microphone;"
          width="50%"
          height="100vh"
          src="https://console.dialogflow.com/api-client/demo/embedded/<some keycde>"
        />
        // onClick={() => console.log("Toggle bool")}
      )}
    </div>
  );
}
shashank
  • 36
  • 3