For your Softr Marketplace or Community, in addition to adding AtomChat’s default chat layouts, you can also start a one-on-one chat with a user directly from their profiles.
We’ll show you how ?



<script>
document.addEventListener("DOMContentLoaded", function() {
var clearInt = setInterval(function(){
if(window.logged_in_user && window.logged_in_user['airtable_record_id']) {
let urlStr = document.location.pathname;
let params = (new URL(document.location)).searchParams;
let recordId = params.get("recordId");
if(recordId === null)
{
let urlArr = urlStr.split('/');
recordId = urlArr[urlArr.length - 1];
}
var pageAttr = "";
var btnName = 'Chat now';
if($('a:contains('+btnName+')').length > 0) {
pageAttr = $('a:contains('+btnName+')').attr("href").split("://")[1];
if(pageAttr != "") {
$('a:contains('+btnName+')').attr("href","#")
$('a:contains('+btnName+')').attr('onclick', 'javascript:jqcc.cometchat.launch({uid:"' + recordId + '"})');
clearInterval(clearInt);
}
}
}
},500);
});
</script>

ENCODE_URL_COMPONENT()Pass the record_id field name from Airtable to the ENCODE_URL_COMPONENT() function. Please refer to the following -
https://YOUR_WEBSITE_URL.softr.app/chat-test?userid="& ENCODE_URL_COMPONENT({airtable_record_id})
Please don't forget to add your website URL to this code. <script>
var url_string = window.location.href
var url = new URL(url_string);
var userid = url.searchParams.get("userid");
var setTimeForLaunch = setTimeout(function(){
if(typeof CometChathasBeenRun != undefined){
jqcc.cometchat.launch({"uid":userid});
}
},3000);
/* To close already opened chatbox on before window unload */
window.addEventListener("beforeunload", function (event) {
jqcc('#cometchat_synergy_iframe')[0].contentWindow.postMessage('CLOSE_CHATBOX','*');
});
/* Postmessage to iframe to check whether chatbox is loaded or not */
var setTimeToCheckChatbox = setInterval(function(){
if(typeof CometChathasBeenRun != undefined){
if(typeof(jqcc('#cometchat_synergy_iframe')[0]) != 'undefined'){
jqcc('#cometchat_synergy_iframe')[0].contentWindow.postMessage('OPENED_CHATBOX_'+JSON.stringify({"UID":userid}),'*');
}
}
},2500);
/* If chatbox is not loaded then use launch JS API to launch the chatbox */
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
var eventer = window[eventMethod];
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
eventer(messageEvent,function(e) {
if(typeof(e.data) != 'undefined' && typeof(e.data) == 'string') {
if(e.data.indexOf('LOAD_CHATBOX_')!= -1){
var controlparameters = e.data.slice(13);
controlparameters = JSON.parse(controlparameters);
console.log("loaded")
jqcc.cometchat.launch({"uid":controlparameters.UID})
clearInterval(setTimeToCheckChatbox);
}
}
});
</script>


var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
var eventer = window[eventMethod];
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
eventer(messageEvent,function(e) {
if(typeof(e.data) != 'undefined' && typeof(e.data) == 'string') {
if(e.data.indexOf('CLOSE_CHATBOX')!= -1){
if($(".cometchat_user_closebox").length > 0){
$(".cometchat_user_closebox").click();
}
}
if(e.data.indexOf('OPENED_CHATBOX_')!= -1){
var controlparameters = e.data.slice(15);
controlparameters = JSON.parse(controlparameters);
if(typeof jqcc.cometchat.getActiveId == 'function' && jqcc.cometchat.getActiveId().length == 0){
e.source.postMessage('LOAD_CHATBOX_'+JSON.stringify({"UID":controlparameters.UID}),'*');
}
}
}
});
We've got you! Please Contact Us if you need any help or have questions.
You can also schedule a remote session with our team of experts!
Happy to help :)