https://discord.gg/botpress logo
not sure what to ask
# 🤝help
m
I dont know what its called or what to "search", I am new to chat bots... On a website sometimes a chat bot has a little call to action or a little notification to bring your eyes to the chat bot. Is there a way I can do this when a users lands on my website with botpress? is it a trigger of some sort? https://cdn.discordapp.com/attachments/1387244588053299281/1387252541045084160/image.png?ex=685cab1b&is=685b599b&hm=d67248cd104fb5944bd1b5741a8b1ecc3ab7002c77d267a8086954c2418fedf9&
ehhh got something working 🙂
m
b
can you send the code please
m
sure! I was actually thinking of hosting it on a CDN so anyone could just use it and style as they needed. New to chat bots, I need to start selling to clients before I go down that rabbit hole 🤣 I will let you know this is a nextjs project so I dont know how "wordpress works" if you are using it there but ill still share the code
Copy code
javascript
  const messages = [
    "👋 Hi! Need help with computer issues?",
    "I can help troubleshoot technical problems instantly! 💻",
  ];
// ####################################################
// just some logic for the animations for the chat bubbles but they coould just be static

  useEffect(() => {
    if (!isMounted || !showBubbles) return;

    const timeouts: NodeJS.Timeout[] = [];

    messages.forEach((_, index) => {
      const timeout = setTimeout(() => {
        setVisibleMessages((prev) => [...prev, index]);
      }, index * 1500);

      timeouts.push(timeout);
    });

    return () => {
      timeouts.forEach((timeout) => clearTimeout(timeout));
    };
  }, [isMounted, showBubbles, messages.length]);

//######################################################

      {showBubbles && (
        <div id="chatbase-message-bubbles">
          <div className="close-button" onClick={closeBubbles}>
            ✕
          </div>
          {visibleMessages.map((messageIndex) => (
            <div key={messageIndex} className="message-bubble-container">
              <div className="message-bubble" onClick={toggleWebchat}>
                {messages[messageIndex]}
              </div>
            </div>
          ))}
        </div>
      )}
Copy code
css

/* Message bubbles container */
        #chatbase-message-bubbles {
            position: fixed;
            bottom: 85px;
            right: 1rem;
            border-radius: 10px;
            font-family: sans-serif;
            font-size: 16px;
            z-index: 2147483644;
            cursor: pointer;
            flex-direction: column;
            gap: 8px;
            max-width: 70vw;
            display: block;
        }

        /* Close button */
        .close-button {
            position: absolute;
            top: -7px;
            right: -7px;
            font-weight: bold;
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 2147483645;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            text-align: center;
            font-size: 12px;
            cursor: pointer;
            background-color: rgb(224, 224, 224);
            color: black;
            box-shadow: rgba(150, 150, 150, 0.15) 0px 6px 24px 0px,
                rgba(150, 150, 150, 0.15) 0px 0px 0px 1px;
            transition: all 0.2s ease;
        }

        .close-button:hover {
            background-color: rgb(200, 200, 200);
            transform: scale(1.1);
        }
Copy code
css
        /* Message bubble container */
        .message-bubble-container {
            display: flex;
            justify-content: flex-end;
            margin: 8px 0;
        }

        /* Individual message bubble */
        .message-bubble {
            background-color: white;
            color: black;
            box-shadow: rgba(150, 150, 150, 0.2) 0px 10px 30px 0px,
                rgba(150, 150, 150, 0.2) 0px 0px 0px 1px;
            border-radius: 10px;
            padding: 20px;
            margin: 8px;
            font-size: 14px;
            opacity: 1;
            transform: scale(1);
            transition: opacity 0.5s ease, transform 0.5s ease,
                box-shadow 0.3s ease;
            cursor: pointer;
            animation: messageSlideIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
            max-width: 280px;
        }

        .message-bubble:hover {
            transform: scale(1.02) translateY(-2px);
            box-shadow: rgba(150, 150, 150, 0.3) 0px 15px 40px 0px,
                rgba(150, 150, 150, 0.3) 0px 0px 0px 1px;
        }

        /* Animation keyframes */
        @keyframes messageSlideIn {
            0% {
                opacity: 0;
                transform: translateY(20px) scale(0.9);
            }

            100% {
                opacity: 1;
                transform: translateY(0) scale(1);
            }
        }

        /* Responsive design */
        @media (max-width: 768px) {
            #chatbase-message-bubbles {
                max-width: 85vw;
                right: 0.5rem;
            }

            .message-bubble {
                max-width: 240px;
                padding: 16px;
                font-size: 13px;
            }
        }
I can convert to plain html for wordpress also
2 Views