Feedback widget implementation on website

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Implementing a Feedback Widget on a Website

A Feedback Widget is a floating button or embedded panel through which users send short messages, ratings, or screenshots without navigating to a separate page. The main value is minimal friction: users don't leave the context.

Minimal Implementation

The widget consists of three parts: trigger button, form, API submission.

// feedback-widget.ts
interface FeedbackPayload {
  type: 'bug' | 'idea' | 'other';
  message: string;
  url: string;
  userAgent: string;
  timestamp: string;
}

class FeedbackWidget {
  private container: HTMLElement;
  private isOpen = false;
  private endpoint: string;

  constructor(endpoint: string) {
    this.endpoint = endpoint;
    this.container = this.createWidget();
    document.body.appendChild(this.container);
  }

  private createWidget(): HTMLElement {
    const wrapper = document.createElement('div');
    wrapper.innerHTML = `
      <style>
        .fw-btn {
          position: fixed;
          bottom: 24px;
          right: 24px;
          background: #3b82f6;
          color: #fff;
          border: none;
          border-radius: 24px;
          padding: 10px 18px;
          font-size: 14px;
          cursor: pointer;
          box-shadow: 0 4px 12px rgba(59,130,246,.4);
          z-index: 9999;
          transition: transform .15s;
        }
        .fw-btn:hover { transform: translateY(-2px); }
        .fw-panel {
          position: fixed;
          bottom: 72px;
          right: 24px;
          width: 320px;
          background: #fff;
          border: 1px solid #e5e7eb;
          border-radius: 12px;
          padding: 20px;
          box-shadow: 0 8px 30px rgba(0,0,0,.12);
          z-index: 9999;
          display: none;
          font-family: system-ui, sans-serif;
        }
        .fw-panel.open { display: block; }
        .fw-title { font-weight: 600; margin: 0 0 12px; font-size: 15px; }
        .fw-types { display: flex; gap: 8px; margin-bottom: 12px; }
        .fw-type {
          flex: 1; padding: 6px; border: 1px solid #e5e7eb;
          border-radius: 6px; background: none; cursor: pointer;
          font-size: 12px; transition: border-color .1s, background .1s;
        }
        .fw-type.active {
          border-color: #3b82f6; background: #eff6ff; color: #1d4ed8;
        }
        .fw-textarea {
          width: 100%; box-sizing: border-box;
          border: 1px solid #e5e7eb; border-radius: 6px;
          padding: 8px; font-size: 13px; resize: vertical;
          min-height: 80px; font-family: inherit;
        }
        .fw-textarea:focus { outline: 2px solid #3b82f6; border-color: transparent; }
        .fw-submit {
          margin-top: 10px; width: 100%; padding: 9px;
          background: #3b82f6; color: #fff; border: none;
          border-radius: 6px; cursor: pointer; font-size: 14px;
        }
        .fw-submit:disabled { opacity: .6; cursor: not-allowed; }
        .fw-success { text-align: center; padding: 20px; color: #16a34a; font-size: 14px; }
      </style>
      <button class="fw-btn" aria-label="Leave feedback">💬 Feedback</button>
      <div class="fw-panel" role="dialog" aria-label="Feedback form">
        <p class="fw-title">What would you like to tell us?</p>
        <div class="fw-types">
          <button class="fw-type active" data-type="bug">🐛 Bug</button>
          <button class="fw-type" data-type="idea">💡 Idea</button>
          <button class="fw-type" data-type="other">💬 Other</button>
        </div>
        <textarea class="fw-textarea" placeholder="Describe what happened..." rows="3"></textarea>
        <button class="fw-submit">Send</button>
      </div>
    `;

    const btn = wrapper.querySelector<HTMLButtonElement>('.fw-btn')!;
    const panel = wrapper.querySelector<HTMLElement>('.fw-panel')!;
    const textarea = wrapper.querySelector<HTMLTextAreaElement>('.fw-textarea')!;
    const submit = wrapper.querySelector<HTMLButtonElement>('.fw-submit')!;
    let selectedType: FeedbackPayload['type'] = 'bug';

    btn.addEventListener('click', () => {
      this.isOpen = !this.isOpen;
      panel.classList.toggle('open', this.isOpen);
      if (this.isOpen) textarea.focus();
    });

    wrapper.querySelectorAll<HTMLButtonElement>('.fw-type').forEach(typeBtn => {
      typeBtn.addEventListener('click', () => {
        wrapper.querySelectorAll('.fw-type').forEach(b => b.classList.remove('active'));
        typeBtn.classList.add('active');
        selectedType = typeBtn.dataset.type as FeedbackPayload['type'];
      });
    });

    submit.addEventListener('click', async () => {
      const message = textarea.value.trim();
      if (!message) { textarea.focus(); return; }

      submit.disabled = true;
      submit.textContent = 'Sending...';

      try {
        await this.send({ type: selectedType, message });
        panel.innerHTML = '<div class="fw-success">✅ Thank you for your feedback!</div>';
        setTimeout(() => {
          panel.classList.remove('open');
          this.isOpen = false;
        }, 2000);
      } catch {
        submit.disabled = false;
        submit.textContent = 'Error — try again';
      }
    });

    // close on Escape
    document.addEventListener('keydown', e => {
      if (e.key === 'Escape' && this.isOpen) {
        this.isOpen = false;
        panel.classList.remove('open');
      }
    });

    return wrapper;
  }

  private async send(data: Pick<FeedbackPayload, 'type' | 'message'>) {
    const payload: FeedbackPayload = {
      ...data,
      url: window.location.href,
      userAgent: navigator.userAgent,
      timestamp: new Date().toISOString(),
    };

    const res = await fetch(this.endpoint, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify(payload),
    });

    if (!res.ok) throw new Error(`HTTP ${res.status}`);
    return res.json();
  }
}

// initialization
new FeedbackWidget('/api/feedback');

Server-Side (Node.js/Express)

// routes/feedback.ts
import { Router } from 'express';

export const feedbackRouter = Router();

feedbackRouter.post('/', async (req, res) => {
  const { type, message, url, userAgent, timestamp } = req.body;

  if (!message || message.length > 2000) {
    return res.status(400).json({ error: 'Invalid message' });
  }

  // save to database
  await db.feedback.create({
    data: { type, message, url, userAgent, timestamp },
  });

  // Slack notification (optional)
  if (process.env.SLACK_WEBHOOK) {
    await fetch(process.env.SLACK_WEBHOOK, {
      method: 'POST',
      body: JSON.stringify({
        text: `*New feedback [${type}]*\n${message}\nPage: ${url}`,
      }),
    });
  }

  res.json({ ok: true });
});

Timeline

Basic widget without screenshots — one to two days of development, including server endpoint and Slack notifications. Adding screenshot capability via html2canvas or native Screen Capture API increases the timeline to three to four days.