Giter VIP home page Giter VIP logo

chatterbox's Introduction

Chatterbox

Chatterbox lets you securely embed Hydrogen within any website.

Chatterbox client screenshot

Requirements

To use Chatterbox you will need:

  • A homeserver which supports Token-authenticated registration. Currently the only known implementation is Synapse (which is available as a service from element.io).
  • An account on that homeserver which can create registration tokens. Synapse requires the account to be an admin.

Develop Instructions


  1. Clone the repo.
  2. Install dependencies (you only need to do this once):
    yarn install
  3. Modify config.json in public directory with your homeserver details.
    (See types/IChatterboxConfig.ts for the format)
  4. Start develop server:
    yarn start

Build Instructions


Follow the develop instructions above (steps 1-3), then:

  • Build chatterbox app into /target directory:
    yarn build

Embed Instructions


Assuming that the build output (inside /target) is hosted at <root> (eg: chatterbox.element.io), copy and paste the following snippet before the closing </body> tag:

	<script>
		window.CHATTERBOX_CONFIG_LOCATION = "path_to_config";
	</script>
	<script src="<root>/assets/parent.js" type="module" id="chatterbox-script"></script>

Testing

Chatterbox comes with a suite of integration tests, using cypress.

You can run them by doing

yarn cypress install
yarn cypress open

Ensure you copy the cypress/fixtures/demoInstance.sample.json file to cypress/fixtures/demoInstance.json and edit the keys accordingly.

Homeserver requirements & configuration

Chatterbox makes use of the Token-authenticated registration feature, and as such your homeserver implementation will need to support it.

Synapse

Synapse has supported this feature since at least 1.52.0. You can enable token registration in homeserver config with:

registration_requires_token: true

You will also need to manually create a registration token with the create token API. You must use the access token of an administrator for this. See the Synapse documentation for help.

$ curl --data '{ "uses_allowed": 50 }' -H 'Authorization: Bearer YOUR_ADMIN_TOKEN' 'https://your-homeserver/_synapse/admin/v1/registration_tokens/new'
200 OK
{
    "token": "defg",
    "uses_allowed": 50,
    "pending": 0,
    "completed": 0,
    "expiry_time": null
}

Note that you can use uses_allowed to set how many chatterbox users can register via this token before no more will be permitted. You can then use the value of token in the response inside your config.json.

chatterbox's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chatterbox's Issues

Add links to chatterbox marketing site / purchase chatterbox, and matrix.org

The chatterbox footer should include links to the Element enterprise chatterbox marketing material (for potential customers using chatterbox to find out more about it and purchase it), and to matrix.org, for those that want to find out more about Matrix.

I suggest the following:
43f1279d-bf15-489d-ba9d-d71cef8ce2ee

@steveloynes -- what is the best link to use for the chatterbox link (presumably linking to the new marketing site material)?

Additional mode of operation: Responder group

According to Rick's statement of what should be included in v1, it appears as though Chatterbox only currently supports "Join Room" (from Rick's Figma).

So this issue is about requesting the development of the "Responder group" operation mode, which involves (assuming my understanding is correct):

  • The ability for one or more configured users to be invited to a room with the Chatterbox user.
  • The ability to toggle between (via configuration):
    • All responder users being invited to a room (with the Chatterbox user).
    • One randomly selected responder user being invited to a room (with the Chatterbox user).

Hide intitial invites from chatterbox timeline

Related to #18. The current chatterbox timeline when initiating a session is probably a little cluttered and complex from an end-user point of view:

image

It would be great if we could hide / not display the timeline messges for the chatterbox user room join. Additionally we should either hide invite messages (as they are probably a little redundant form the end user point of view, or hide that they were invited by the chatterbox user (as they won't have taken any action to do so, and this could be quite confusing).

image

Or:

image

Public registration token

I have just installed chatterbox on my server. I find it very interesting. But what I ask myself all the time: if my registration
token is visible, how do I prevent someone from writing a bot that registers millions of users on my server?

Document homeserver requirements and prerequisites to use Chatterbox

Is your feature request related to a problem? Please describe.
The documentation in this repo is pretty sparse, and in my attempts to play with it in my own deployment I've identified that my homeserver needs to allow registration, and that I will also need to presumably generate a registration token to be used to create new users (a feature that is pretty rare to encounter for most homeserver operators, since registration tokens are not supported by arguably the most popular Matrix clients element-[web|android|ios]). Unfortunately, I'm finding these things out simply by rather a lot of trial and error and watching the announcement video trying to glean any information I can, rather than from the setup instructions.

Describe the solution you'd like
I would like detailed information about prerequisites to use Chatterbox included in the setup instructions.

Describe alternatives you've considered
Use an alternate project - but then I'm not using chatterbox :)

Provide credentials for a know user

Describe the solution you'd like
Currently all chat users are "new" users. With the application token new users are created. In our environment we have all our clients registered in Matrix. By making the config.json endpoint dynamic (should send cookie credentials retrieving it) we could provide a predefined session token in the config for the known user. This helps us to identify the user (#63) and detect the preferred language for our bot.

Chatterbox fails to load when room.fillGap() fails after creating a new room

Describe the bug

  • Be logged into Chatterbox from a previous session.
  • Click on the chatterbox icon, no chat window is rendered yet.
  • Chatterbox creates a new DM (apparently doesn't know about any previous ones)
  • Room is created. Chatterbox then tries to fill the room gaps (which don't exist yet, /messages returns an empty chunk)
  • An error is recorded: room.fillGap(): Invalid end token in response
  • The chatterbox icon hides itself

Screenshots

image

  • Browser: Chromium
  • Version: 103

Kind is undefined

Describe the bug

When a new user tries to chat with me from my page, it seems that the registration on my homeserver is too slow and the user is greeted with an error. Reloading the page or pressing the chat button again corrects the problem. It seems like some race condition from the chat app while waiting for the user registration to complete.

To Reproduce

  • The first time a user visits my page and click the chat icon, the chat box will produce the following error:

    Something went wrong…can't access property "kind", i is undefined

  • In the console, I can see repeatated calls to the register endpoint of my server

  • Reloading the page OR pressing the chat button again will make chat work properly

Expected behavior
The chat window to load properly on first key press without any error.

Screenshots
image

image

image

Desktop (please complete the following information):

  • OS: Windows
  • Browser Firefox Developer
  • Version 103.0b7 (64-bit

Additional context
Same behavior in different browsers and on different devices.

Add license

Chatterbox doesn't have a license, we should fix that :)

Mobile browser hides close button

Describe the bug
A clear and concise description of what the bug is.

To Reproduce

  1. Open chat support in the browser

Expected behavior
Show the close bar

Screenshots
Screenshot_20220819-145212
Screenshot_20220819-145309

Smartphone (please complete the following information):

  • Device: Android
  • OS: 12
  • Browser Firefox
  • Version 103.2.0

It seems not to calculate the address bar with the available height of the screen.

Notifications when the user limit is reached

Reading the wiki:

The registration module also (optionally) checks the MAU count of chatterbox users and if the count matches/exceeds the allowed maximum number of users, it will block the registration token until the count drops or the maximum is increased (to reduce the chances of bill-shock for the EMS customer).

-- https://gitlab.matrix.org/new-vector/internal/-/wikis/Chatterbox

I was curious what actually happens when you run into the limit.

The screenshot explains some of it:

Monthly Active Users

You will be charged based upon the number of people using Chatterbox each month.

If you go over your configured limit, Chatterbox will not present itself to users until you increase the limit. You can change your limits by modifying the configuration below.

Questions

  • Do we also notify agents that they're currently at/over the limit?
    • It would be weird to sit there as an agent with no incoming tickets and no way to tell what's going on.
    • How do we notify?
    • Does the notification include instructions for how to increase the maximum?
  • Is there a courtesy reminder/warning when you reach a threshold of your MAU limit?
  • Do we provide a graph of your MAU over time?
    • As a chatterbox owner, this would better help forecast if the limit needs to be raised.

Clicking on an image in chatterbox seems to break it

Describe the bug

When clicking on an image sent by a participant, I was served an nginx 404 page in Chatterbox's iframe. Upon hitting the "Previous" button in said iframe the frame is empty:

image

To Reproduce
Steps to reproduce the behavior:

  1. Send an image
  2. Click on it

Expected behavior
Not sure, are images supposed to be clickable?

Chatterbox doesn't work on private tabs on FireFox

no persisted storage, database can be evicted by browser [vendor.7c61eada.js:3:46921](https://chatterbox.hss.element.io/assets/vendor.7c61eada.js)
Uncaught (in promise) Error: load failed: IDBRequest failed on .: (name: InvalidStateError) (code: 11) A mutation operation was attempted on a database that did not allow mutations.
    login https://chatterbox.hss.element.io/assets/main.67b6c3b0.js:1
[main.67b6c3b0.js:1:3822](https://chatterbox.hss.element.io/assets/main.67b6c3b0.js)

z-index

Describe the bug
In our website we work with layers (z-index) and the button is attached at the body. In our case behind the carousel.

Expected behavior
It should be visible or be able to tune the z-index because even 1000 might be to low if it is set fixed.

Preview site

It would be cool if we could bundle a standard looking website that includes the chatterbox iframe as a sort of preview. Doesn't need to be fancy, but the idea is a customer can navigate to chatterbox.element.io/preview and see an example of what their site would look like.

We would likely need to specify the config in the URL, somehow.

Use crypto.getRandomValues() instead of Math.random()

Using Math.random() here seems wrong given it's not suited for cryptographic purposes

https://github.com/vector-im/chatterbox/blob/3c8df045579bce9682bd03e44b0e86f6fbb6a8d6/src/random.ts#L17-L29

I haven't looked into it very deeply, but it seems to me this is actually used for stuff that should use cryptographically strong random values

https://github.com/vector-im/chatterbox/blob/3c8df045579bce9682bd03e44b0e86f6fbb6a8d6/src/viewmodels/AccountSetupViewModel.ts#L40-L62

Open new case

When the following occurs:

  1. chatterbox is opened
  2. a room is created and invite_user is invited
  3. a useful (?) chat is had
  4. invite_user leaves
  5. how does one initiate a new chat with invite_user? how does one start over?

Chatterbox instance in EMS for public demo / testing

Can we please set up a new instance of Chatterbox for general public testing / demo of the product.

  • The instance should be on a live EMS domain, and associated with a live EMS host.
  • The instance should have a simple auto-responder (similar to the staging demo instance)
  • The instance should have the ability / credentials to log in as an admin to view and respond to demo interactions, if needed

Once the instance is set up it can embedded into a simple, stand-alone html page (like the one for the demo staging instance) and be publicised.

Later (as soon as possible) the instance should be embedded along-side content in the Element marketing site (Steve and marketing will need to drive this last bit, once everything else is up and running).

Announce leave events

Chatterbox currently does not log when a user leaves the room, this would be useful so users don't just talk into the void.

Create rooms with a specific space

Describe the solution you'd like
It would be great if you could configure a space for the chatterbox to create the rooms in. This would allow clients on the support providing side to group support-related rooms together.

Describe alternatives you've considered
The only alternatives I see is either to just have internal team rooms mixed with support rooms with external people or to manually move the support rooms to the space once I am invited to them.

Hide chatterbox user avatar

If the user doesn't have an avatar, opt to not show anything over the current placeholder icon. Chatterbox users cant set avatars yet so it feels a little redundant.

TOFU (Trust on first use) + Verification

Is your feature request related to a problem? Please describe.

E2EE is of very limited use if you can’t prove whether you’re talking to the right person or a MITM.

Describe the solution you'd like

Ability to view the olm public keys of the user you’re talking to, and be warned if they change, and have the option to verify them via device verification (and/or via some other out-of-band verification channel, e.g. an ID server)

This is quite subtle given trusting the website hoster to embed a non-malicious chatterbox means that even with verification, there's a risk of a malicious chatterbox being inserted into the mix if the host website wants to MITM its users. Suggestions welcome on how best to solve this one, as verification is useless if you can't trust the endpoint...

Additional context
https://news.ycombinator.com/item?id=32020476
https://twitter.com/MTRNord/status/1545089701698306050

Chatterbox doesn't always follow the correct flow when presented with multiple registration flows.

E.g. Chatterbox seems to pick the first flow it is given by the registration API.

// (env) ➜  synapse curl -X POST --data '{}' https://cb-staging.ems.host/_matrix/client/v3/register
{
    "session": "ruZGCVZpMIHmvVDUMvOsEmZM",
    "flows": [
        {
            "stages": [
                "m.login.terms",
                "m.login.dummy"
            ]
        },
        {
            "stages": [
                "m.login.terms",
                "m.login.email.identity"
            ]
        },
        {
            "stages": [
                "m.login.terms",
                "m.login.registration_token"
            ]
        }
    ],
    "params": {
        "m.login.terms": {
            "policies": {
                "privacy_policy": {
                    "version": "1.0",
                    "en": {
                        "name": "Privacy Policy",
                        "url": "https://cb-staging.ems.host/_matrix/consent?v=1.0"
                    }
                }
            }
        }
    }
}

The above is an example of a flow from a host with public registration enabled. Chatterbox should ideally be opting to use flow 3, rather than flow 1.

Default (local-echo) display name for chatterbox users

Currently, chatterbox displays fairly long and unweildy user IDs for new users by default (as shown in the screenshot below). It would be good to be able to set a default value to be shown as the display name of the chatterbox user in the local client if one has not been specified (e.g. displayname === undefined or displayname === matrixUserId).

Ideally this would simply be a local representation of the display name in the client, rather than setting the Matrix display name for the chatterbox users, as this would result in all chatterbox users appearing the same in full Matrix clients like Element-web, and could cause confusion, for example in the Element-web left panel.

For now it would be good for the default, local display name for chatterbox users to be "Me". However, it would be good for this to be easily changable in futture, as we may wish to use other values like "Guest" etc., instead.

image

image

vm2 is undefined error

Describe the bug
Attempt to run the application locally with yarn start resulted in an error in the chatterbox window when starting a new chat.

Full error:

Something went wrong…
vm2 is undefined

This occurred while running mountView@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:4779:12.

render/<@http://localhost:3000/src/ui/views/ChatterboxView.ts:13:65
mapView/<@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:5231:31
_addReplaceNodeBinding@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:5179:26
mapView@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:5220:17
render@http://localhost:3000/src/ui/views/ChatterboxView.ts:13:9
mount@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:5027:25
mountView@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:4777:17
view@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:5217:12
mapView/<@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:5233:21
binding@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:5184:35
update@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:5051:9
_updateFromValue@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:4976:10
emit/<@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:10481:32
emit@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:10481:16
emitChange@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:20356:12
_showTimeline@http://localhost:3000/src/viewmodels/RootViewModel.ts:62:10
_setupNavigation/<@http://localhost:3000/src/viewmodels/RootViewModel.ts:29:74
emit@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:1082:8
emitIfChanged@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:20043:12
applyPath@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:19928:48
push@http://localhost:3000/node_modules/.vite/deps/hydrogen-view-sdk.js?v=37b91674:19914:17
completeRegistration@http://localhost:3000/src/viewmodels/AccountSetupViewModel.ts:70:21

To Reproduce
Steps to reproduce the behavior:

  1. clone repository
  2. modify public/config.json with server information, token information, invite_user value
  3. execute yarn start to run test server
  4. visit localhost:3000 and begin chat
  5. chat window returned error above
  6. invite_user user is successfully invited to a chat with the newly generated user, but web-chat user cannot interact with the conversation

Screenshots
If applicable, add screenshots to help explain your problem.
image
image

Desktop (please complete the following information):

  • OS: Arch Linux
  • Browser Firefox
  • Version 102.0.1

Additional context
All changes I've made are contained in the config.json. Full diff is below:

diff --git a/public/config.json b/public/config.json
index 62a90b9..53d1cba 100644
--- a/public/config.json
+++ b/public/config.json
@@ -1,18 +1,18 @@
 {
-    "homeserver": "https://your-homeserver.com",
+    "homeserver": "https://synapse.mssj.me",
     "auto_join_room": "Internal matrix id of the room",
     "username_prefix": "foobar",
     "header": {
         "title": "Your Fancy Title",
-        "avatar": "https://link_to_avatar/awesome.png"
+        "avatar": "https://www.mssj.me/images/logo.png"
     },
     "footer": {
         "chatterbox_link": "https://element.io/solutions/chatterbox-embedded-live-chat-for-customer-service",
         "matrix_link": "https://matrix.org"
     },
-    "token": "Valid Token to be used with Token Authenticated Registration",
-    "invite_user": "@botuser:your-homeserver.com",
+    "token": "REDACTED",
+    "invite_user": "REDACTED",
     "encrypt_room": false,
-    "avatar": "https://link_to_avatar/avatar.png",
+    "avatar": "https://www.mssj.me/images/logo.png",
     "disable_composer_until_operator_join": true
 }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.