npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

paymob-chatbot-alpha

v1.0.4

Published

Embed the Paymob AI assistant into any website with a single script tag. The SDK renders a floating chat button in the bottom-right corner of your page and opens a fully-featured AI chat popup powered by Paymob.

Readme

Paymob Chatbot SDK Alpha

Embed the Paymob AI assistant into any website with a single script tag. The SDK renders a floating chat button in the bottom-right corner of your page and opens a fully-featured AI chat popup powered by Paymob.


Table of Contents


Installation

CDN (recommended)

Add the script tag before the closing </body> tag of your HTML page:

<!-- Latest version -->
<script src="https://cdn.jsdelivr.net/npm/paymob-chatbot-alpha@latest/main.js"></script>

npm

npm install paymob-chatbot-alpha
import { Chatbot } from 'paymob-chatbot-alpha';

Quick Start

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>My Store</title>
  <meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>

  <!-- Your page content -->

  <script src="https://cdn.jsdelivr.net/npm/paymob-chatbot-alpha@latest/main.js"></script>
  <script>
    const chat = new window.PaymobChatbot({
      auth: {
        token: 'your_auth_token',
        platform: 'dashboard',
        region: 'egypt',
        user_type: 'merchant',
      },
    });
  </script>
</body>
</html>

A floating chat button will appear in the bottom-right corner. Clicking it opens the Paymob AI assistant. The chatbot will display a loading screen until the auth handshake completes automatically.


Configuration Options

| Option | Type | Required | Default | Description | |---|---|---|---|---| | auth | object | ✅ Yes | — | Authentication object. Must contain exactly token, platform, region, and user_type — all strings. See The auth Object for details. | | showToggle | boolean | No | true | Show or hide the floating chat button. Set to false to control the popup entirely via open() / close(). |


The auth Object

The auth parameter is required and must be a plain object containing exactly these four string keys:

| Key | Type | Description | |---|---|---| | token | string | Your merchant authentication token issued by Paymob. | | platform | string | The platform the SDK is running on. Allowed values: "dashboard", "merchant-app", "sales-app". | | region | string | The merchant's region. Allowed values: "egypt", "uae", "oman", "ksa", "glb". | | user_type | string | The type of user initiating the session. Allowed values: "merchant", "sales". |

auth: {
  token: 'your_auth_token',
  platform: 'dashboard',
  region: 'egypt', // 'egypt' | 'uae' | 'oman' | 'ksa' | 'glb'
  user_type: 'merchant',
}

All four keys are required. If any key is missing, has the wrong type, is an empty string, or if the object contains extra keys, the SDK will not render and will log a descriptive error to the browser console instead.

Validation errors

The SDK validates the auth object at construction time. Open your browser's developer console to see the exact issue:

[PaymobChatbot] auth.token is required but missing.
[PaymobChatbot] auth.platform must be a string, got number.
[PaymobChatbot] auth.region must not be an empty string.
[PaymobChatbot] auth contains unexpected key "userId". Allowed keys: token, platform, region, user_type.

API Reference

new PaymobChatbot(options)

Creates and mounts the chat widget on the page. The widget is appended to <body> automatically.

const chat = new window.PaymobChatbot({
  auth: {
    token: 'your_auth_token',
    platform: 'dashboard',
    region: 'egypt',
    user_type: 'merchant',
  },
});

chat.open()

Opens the chat popup programmatically.

chat.open();

chat.close()

Closes the chat popup programmatically.

chat.close();

chat.destroy()

Completely removes the widget (button + popup) from the DOM and cleans up all injected styles. Useful for single-page applications when navigating away.

chat.destroy();

Usage Examples

Default — floating button + popup

const chat = new window.PaymobChatbot({
  auth: {
    token: 'your_auth_token',
    platform: 'dashboard',
    region: 'egypt',
    user_type: 'merchant',
  },
});

Hide the toggle button — programmatic control only

Use this when you want to trigger the chat from your own button or UI element.

<button id="open-chat">Talk to Paymob AI</button>

<script src="https://cdn.jsdelivr.net/npm/paymob-chatbot-alpha@latest/main.js"></script>
<script>
  const chat = new window.PaymobChatbot({
    auth: {
      token: 'your_auth_token',
      platform: 'dashboard',
      region: 'egypt',
      user_type: 'merchant',
    },
    showToggle: false,  // hides the default floating button
  });

  document.getElementById('open-chat').addEventListener('click', () => {
    chat.open();
  });
</script>

Open the chat automatically on page load

const chat = new window.PaymobChatbot({
  auth: {
    token: 'your_auth_token',
    platform: 'dashboard',
    region: 'egypt',
    user_type: 'merchant',
  },
});

// Open after a short delay
setTimeout(() => {
  chat.open();
}, 3000);

React / Next.js integration

import { useEffect, useRef } from 'react';
import { Chatbot } from 'paymob-chatbot-alpha';

export function ChatWidget({ authToken }) {
  const chatRef = useRef(null);

  useEffect(() => {
    chatRef.current = new Chatbot({
      auth: {
        token: authToken,
        platform: 'dashboard',
        region: 'egypt',
        user_type: 'merchant',
      },
    });

    // Cleanup on unmount
    return () => {
      chatRef.current?.destroy();
    };
  }, []);

  return null;
}

Vue.js integration

import { Chatbot } from 'paymob-chatbot-alpha';

export default {
  props: ['authToken'],
  mounted() {
    this.chat = new Chatbot({
      auth: {
        token: this.authToken,
        platform: 'dashboard',
        region: 'egypt',
        user_type: 'merchant',
      },
    });
  },
  beforeUnmount() {
    this.chat?.destroy();
  },
};

Browser Support

| Browser | Minimum Version | |---|---| | Chrome | 80+ | | Firefox | 75+ | | Safari | 13+ | | Edge | 80+ |


License

MIT © Paymob