Socket
Socket
Sign inDemoInstall

chat-embed

Package Overview
Dependencies
0
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    chat-embed

Create and manage chats easily


Version published
Weekly downloads
15
decreased by-77.27%
Maintainers
1
Install size
419 kB
Created
Weekly downloads
 

Readme

Source

chat-embed

Create and manage chats easily

How to use

Svelte

<script lang="ts">
    import Chat, * as chat from 'chat-embed/svelte';

    const handleMessage = async (event) => {
        const message = event.detail;
        if (message.fromUser) {
            chat.typing();

            setTimeout(() => {
                chat.send({
                    type: 'text',
                    content: cleanedText
                });
            }, 1000)
        }
    }
</script>

<Chat on:message={handleMessage} />

Others

import createChat from 'chat-embed';

const chat = createChat({ embed: document.body })

IIFE

<script src="https://www.unpkg.com/chat-embed/dist/index.iife.js"></script>
<script type="text/javascript">
    const chat = window.chatEmbed({ embed: document.body })
</script>

API

Create chat

On creating a chat, you can define the theme, the receiver and a widget, all three are optional.

const chat = window.chatEmbed({
    embed: document.body,
    receiver: {
        image: 'https://i.imgur.com/RZQ8tQ9.png',
        name: 'Jupiter Apple',
        status: 'online',
        round: '100%'
    },
    theme: {
        primaryColor: '#f54242'
    },
    widget: {
        right: false,
        size: "60px",
        round: "50%",
        background: "#f54242",
        image: "https://i.imgur.com/RZQ8tQ9.png",
        animated: true,
        popupMessage: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit!',
        notification: {
            background: "#f54242",
            color: "#FFFFFF",
        }
    }
})

Chat methods

chat.addReceiver(receiver); // Add a function to handle chat messages
chat.typing(); // Starts typing animation
chat.toggle(); // Toggle chat opening
chat.clear(); // Clear all chat messages
chat.setInput(show); // Enable or disable input
chat.send(message); // Send a message on chat

FAQs

Last updated on 18 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc