Umashankar Das
Umashankar Das

Reputation: 601

Custom UI for dialogbox chatbot in React

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>

'''

Upvotes: 1

Views: 403

Answers (1)

shashank
shashank

Reputation: 36

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>
  );
}

Upvotes: 2

Related Questions