Public page, that users can chat with the account owner - but can't see each other

Hey everyone, hope you are all safe and well.

We are adding a new page to our existing app, I’d like users to be able to share a unique public page with some job info, then for anyone they share this page to to be able to comment/chat with the page/account owner.

Importantly, they can only see their own chat + the account owners responsive.

Also importantly, I can administer this in the account owners logged in section, where they can choose which visitor is messaging to reply to.

I know it’s possible, just not sure the best way to structure this?

1 Like

Bumping this back up.

What I’m essentially trying to achieve with an embedded ‘chat’ function built in Bubble is that of when you visit a website that has a customer support chat widget, i’m an anonymous visitor until I pass my email, and I can only ever see the chat support agent and my replies.

Has anyone achieved anything similar in Bubble? Really stuck on the best way to reliably administer this.

Noting my flow - on page load, soft-gate lead capture, this converts a ‘lead’ in the DB, for the anonymous visitor, but i’m not creating a ‘user’ thing.

Probably in the permissions area you set some conditional up for visibility like “current user is logged in and user related to chat message is current user”

This would require that each chat message or conversation has a user data field relating to a user data type.

Thanks @boston85719, the issue i’m coming up against is that the ‘lead’ is not a user, so I’ve tried to use the set state feature, to set that data type, but as they are not ‘logged in’ it’s not proving to be super reliable.

I’ve been able to restrict both sides to only seeing their own messages, and even on the logged in side a new button with the ‘leads’ name appears, which can be clicked to set the state of each new lead - but I can’t get the two-way private comms working, yet…

in theory this is a simple use case, I just haven’t figured it out yet

@matthew2, I think this assumption is probably tripping you up. Any visitor to your page is an anonymous user. They aren’t a registered user in your application however if they start a chat with your platform they will be the creator of that chat and any messages they create so you can use references like ‘Search for Chat’s where the creator is current user’ even when they are browsing anonymously.

With this in mind you can create the chat function exactly like you would for two logged in users.

Interesting @eli that might well be the blocker for me, let me follow this approach, thank you!

1 Like

@eli for the conditions, would you consider this appropriate to display both the ‘page creator user’ but also the anonymous user who created a message on this page, so it only displays these two.

Screen Shot 2020-05-12 at 8.54.46 am

The issue I see here, is that this will display perhaps the anonymous user ‘created by’ post, but, it will also show all messages from the demo’s page creator, instead of just the messages sent to this anonymous user.

That is good if you merge them in two different sources.

@matthew2 Ah, no, so you want to have a Chat thing, right, and then associate that chat to your user. When a user submits an initial message search for a ‘Chat’ that has been created by that user. If none exists, create one and then create a new message associated to that chat. All future messages from that user should be associated to that chat record.

Then you search your messages by finding the correct chat. Does that make sense?

If you do:filtered you can set an advanced condition: Parent User is This User

We don’t really want to create a new user in the DB, for someone who is just a ‘lead’ - so this wouldn’t necessarily work that way?

What I had tried to create was a ‘Chat Link’ thing, which then included the ‘Parent User’ and also the ‘Lead’ thing, but again, kept falling just short of it working.

The user already exists on the page whether or not you create one in your application.

Thanks Eli, apologies, just trying to get my head around it.

Hey! Sorry, would you mind elaborating what you mean merge them in two diff sources?

No problem, I get it! I’ll come back later if you haven’t solved. Have to run for a bit.

1 Like

So, would this be the correct structure to make this work?

‘Chat’ thing (the linkage) (this has a ‘list of chat messages’, the lead thing, page thing and parent user thing linked).
Chat Message thing
‘Page’ thing (this displaying the page created by the parent user, where the embedded chat appears)
‘Lead’ thing (this is the lead that’s created when the anonymous visitor converts on the soft gate)

When a anonymous visitor lands on the page, they get the soft gate. When they complete this:

  1. New ‘Chat’ thing is created, linking the Page thing, the Lead Thing and the Parent User of the Page Thing.
  2. I then set the state of the chat group to ‘Chat’ thing’s ‘Lead’
  3. When anonymous visitor creates a message the workflow first creates the chat message and modifies the ‘chat thing’ and adds the chat message to the list of chat messages, and adds the ‘lead’ state to the chat message.

When the logged in user (who has created the page) visits the page, he in theory will see the chat messages and can select between each lead to see and reply to only their messages.

When they create a new message, I create the chat message and modify the ‘Chat’ thing, then add the chat message to list of messages.

On the anonymous visitor side, when I want to get the source for the repeating group - I search for the ‘Chat’ thing, and not the chat messages things with the constraint ‘Created by current user’ and ‘Page Parent User’ this should in theory show messages from both?

Would I display the same on the page owner’s side (logged in user) but instead, it wiuld be created by current user + created by ‘lead’ thing?

And to switch repeating groups, for the individual chat streams I could replace using custom states, to just showing the above for each lead?

Yep, that is the basic idea. I’m not sure what the ‘Lead’ state is that you are referring to but it doesn’t sound like it would interfere in the process.

The only thing I would note here is that for anonymous chat using a list of messages on the chat thing should be fine. For chat scenarios that have potential for hundreds of messages in a single chat conversation it would likely be more performant to simply store a link to the chat on the message thing.

Re displaying the chat for the anonymous user, yes, your search would be for the chat record created by the current user and then get the messages belonging to that specific chat record. No need to filter for the message creator once you have the chat record as it will only contain messages from the current user or the parent pages user.

For the admin side you can list your leads in an RG and when you click on the lead display the connected chat somewhere in a state, group data source, or similar and get your messages from that chat.

I’m not sure how long Bubble stores the anonymous user, I’ve heard it’s three days but I’ve never tested it. I have a test running now though thanks to this conversation :slight_smile:

1 Like

Looks like I may have this sorted finally, I’m not sure it’s 100% perfect, but right now on the current version appears to be working fine. Thank you for all your help.

2 Likes

Hi eli

When an anonymous user creates something are we supposed to see some kind of unique ID for that user in the created by entry?

In my app when a non registered user creates something it is saved properly in the database, but the created by field is empty.