
HubSpot 聊天机器人
用 FlowHunt 为您的 HubSpot 聊天机器人赋能。更好地控制回复、数据源和对话流程。
解锁 FlowHunt 聊天机器人的高级功能:通过流变量个性化、通过 URL 后缀追踪、使用事件处理器,以及控制聊天激活,打造定制化用户体验。
Flowhunt 拥有强大的功能,可让您深度定制聊天机器人的行为,并与您的网站或应用实现无缝集成。在本页中,您将学习如何进行一些高级自定义——流变量、URL 参数、事件驱动回调以及自定义聊天激活逻辑。
流变量为聊天机器人传递动态数据提供了方式,从而实现真正的个性化。您可以在这些变量中存储任何内容,比如用户数据、会话数据或者任何相关信息。
flowVariable
是 FHChatbot.initChatbot()
配置的一部分。它是一个对象,每个键值对定义了一个变量及其值。例如——传递用户的 IP 地址和用户 id:
<script type="text/javascript" id="fh-chatbot-script-8f1fd880-8e9c-4cb1-a1f2-291c0329612b">
(function(d, src, c) {
var t=d.scripts[d.scripts.length - 1],s=d.createElement('script');
s.async=true;s.src=src;s.onload=s.onreadystatechange=function(){
var rs=this.readyState;
if(rs&&(rs!='complete')&&(rs!='loaded')){return;}
c(this);
};
t.parentElement.insertBefore(s,t.nextSibling);
})(document,
'https://app.flowhunt.io/fh-chat-widget.js',
function(e){
FHChatbot.initChatbot({
chatbotId: '8f1fd880-8e9c-4cb1-a1f2-291c0329612b',
workspaceId: 'e31db667-893b-4e47-92c3-bb1f93c1b594',
headerTitle: 'URLsLab FAQ Generator',
maxWindowWidth: '700px',
"flowVariable": {
"ip": /* Code to obtain IP Address */ ,
"userId": /* Code to obtain User ID */
}
});
}
);
</script>
重要提示:
/* Code to obtain IP Address */
和 /* Code to obtain User ID */
替换为您实际获取这些值的逻辑,通常涉及访问服务端变量、本地存储,或依赖其他身份认证方式。urlSuffix
参数允许您为聊天机器人发起的每个 URL 追加查询字符串。这对于使用 Google Analytics 等分析工具追踪聊天机器人互动的来源和效果非常有价值。
如何使用 urlSuffix
只需将 urlSuffix
属性设置为您期望的查询字符串,如下所示:
<script type="text/javascript" id="fh-chatbot-script-8f1fd880-8e9c-4cb1-a1f2-291c0329612b">
(function(d, src, c) {
var t=d.scripts[d.scripts.length - 1],s=d.createElement('script');
s.async=true;s.src=src;s.onload=s.onreadystatechange=function(){
var rs=this.readyState;
if(rs&&(rs!='complete')&&(rs!='loaded')){return;}
c(this);
};
t.parentElement.insertBefore(s,t.nextSibling);
})(document,
'https://app.flowhunt.io/fh-chat-widget.js',
function(e){
FHChatbot.initChatbot({
chatbotId: '8f1fd880-8e9c-4cb1-a1f2-291c0329612b',
workspaceId: 'e31db667-893b-4e47-92c3-bb1f93c1b594',
headerTitle: 'URLsLab FAQ Generator',
maxWindowWidth: '700px',
"urlSUffix": "?utm_source=your-custom-source"
});
}
);
</script>
在此示例中,?utm_source=your-custom-source
将被追加到所有由聊天机器人发起的 URL,方便您在分析平台中追踪聊天机器人的流量。
Flowhunt 允许您设置事件处理器,在聊天机器人发生特定事件时触发自定义函数。这些处理器为用户体验提供了精细化的控制。主要的事件处理器包括:
onSessionCreated
:当新会话启动时触发(重启会话也算)。onWindowOpened
:当聊天窗口打开时触发。onWindowClosed
:当聊天窗口关闭时触发。onError
:当聊天机器人发生错误时触发。onMessageReceived
:当机器人发送信息或用户发送输入时触发。onMessageSent
:当用户发送消息时触发。如何使用事件处理器
可以通过 FHChatbot.initChatbot
返回的 fhChatbot
变量设置处理器,并添加如 fhChatbot.onSessionCreated()
的监听器。示例:
<script type="text/javascript" id="fh-chatbot-script-8f1fd880-8e9c-4cb1-a1f2-291c0329612b">
// catch event when chatbot is ready on your page
window.addEventListener("onFHChatbotReady", (e) => {
console.log("Chatbot is ready, chat button should be visible at this time ready to be clicked.");
});
(function(d, src, c) {
var t=d.scripts[d.scripts.length - 1],s=d.createElement('script');
s.async=true;s.src=src;s.onload=s.onreadystatechange=function(){
var rs=this.readyState;
if(rs&&(rs!='complete')&&(rs!='loaded')){return;}
c(this);
};
t.parentElement.insertBefore(s,t.nextSibling);
})(document,
'https://app.flowhunt.io/fh-chat-widget.js',
function(e){
const fhChatbot = FHChatbot.initChatbot({
chatbotId: '8f1fd880-8e9c-4cb1-a1f2-291c0329612b',
workspaceId: 'e31db667-893b-4e47-92c3-bb1f93c1b594',
headerTitle: 'URLsLab FAQ Generator',
maxWindowWidth: '700px',
"urlSUffix": "?utm_source=asdfsdfgsdg"
});
fhChatbot.onSessionCreated(function () {
// Custom logic when the session is created, could fire API calls, or store data
console.log("session started");
});
fhChatbot.onWindowOpened(function () {
// custom logic when the window opens, or show some content above the chat
console.log("window opened");
});
fhChatbot.onWindowClosed(function () {
// custom logic when the window is closed, or show some content above the chat
console.log("window closed");
});
fhChatbot.onError(function (e) {
// custom logic when an error is fired, could track it on error tracking tool.
console.log(e.metadata);
console.log("window error");
});
fhChatbot.onMessageReceived(function (e) {
// custom logic when the bot answered.
console.log("chatbot answered");
});
fhChatbot.onMessageSent(function (e) {
// custom logic when the user sent an input.
console.log("user sent an input");
});
}
);
</script>
每个事件处理函数都可以执行自定义逻辑,让您的聊天机器人根据用户行为实现动态响应。
应用场景:
onSessionStart
等事件追踪会话启动和机器人使用情况,发送有价值的指标数据。通过设置 showChatButton: false
,您可以隐藏默认的聊天按钮。然后,您可以根据自己的自定义逻辑以编程方式打开或关闭聊天窗口。这为界面控制提供了最大自由度。
如何实现自定义激活
FHChatbot.initChatbot()
配置中添加:showChatButton: false
。fhChatbot.openChat()
和 fhChatbot.closeChat()
方法,根据您的自定义事件控制可见性。<script type="text/javascript" id="fh-chatbot-script-8f1fd880-8e9c-4cb1-a1f2-291c0329612b">
(function(d, src, c) {
var t=d.scripts[d.scripts.length - 1],s=d.createElement('script');
s.async=true;s.src=src;s.onload=s.onreadystatechange=function(){
var rs=this.readyState;
if(rs&&(rs!='complete')&&(rs!='loaded')){return;}
c(this);
};
t.parentElement.insertBefore(s,t.nextSibling);
})(document,
'https://app.flowhunt.io/fh-chat-widget.js',
function(e){
const fhChatbot = FHChatbot.initChatbot({
chatbotId: '8f1fd880-8e9c-4cb1-a1f2-291c0329612b',
workspaceId: 'e31db667-893b-4e47-92c3-bb1f93c1b594',
headerTitle: 'URLsLab FAQ Generator',
maxWindowWidth: '700px',
"urlSUffix": "?utm_source=asdfsdfgsdg",
"showChatButton": false
});
// Example: if user clicks on a button
const customChatButton = document.getElementById("myCustomChatButton")
customChatButton.addEventListener("click", () => {
fhChatbot.openChat();
});
// Example: if user closes by using a custom close button
const customCloseChatButton = document.getElementById("myCustomCloseChatButton")
customCloseChatButton.addEventListener("click", () => {
fhChatbot.closeChat();
});
}
);
</script>
在此示例中,我们为自定义按钮添加了监听器,以打开或关闭聊天窗口。
优势:
通过流变量、URL 后缀、事件处理器和自定义聊天激活,您能用 Flowhunt 打造高度定制且富有吸引力的聊天机器人体验。这些高级选项为您微调机器人以完美匹配您的业务需求和用户期望提供了强大工具。
流变量允许您将动态数据(如用户或会话信息)传递到 FlowHunt 聊天机器人中。这使得对每个用户的对话都能实现个性化和情境感知。
使用 urlSuffix 参数为聊天机器人调用的每个 URL 添加自定义查询字符串。这样您就可以在 Google Analytics 等分析工具中轻松追踪由聊天机器人带来的流量和转化。
FlowHunt 支持事件处理器,例如 onSessionCreated、onWindowOpened、onWindowClosed、onError、onMessageReceived 和 onMessageSent,让您能够全面掌控聊天机器人驱动的用户互动。
将 'showChatButton' 设置为 false 以隐藏默认按钮,然后使用 fhChatbot.openChat() 和 fhChatbot.closeChat() 根据您的自定义逻辑或用户操作打开或关闭聊天机器人。
高级自定义让您能够个性化用户旅程、集成分析、触发动态操作,并且让聊天机器人体验无缝匹配您的网站设计和业务需求。
用 FlowHunt 为您的 HubSpot 聊天机器人赋能。更好地控制回复、数据源和对话流程。
FlowHunt 现已支持定时任务、Google Workspace、DuckDuckGo 和 DeepSeek AI。探索最新功能更新!
FlowHunt 可与所有主流客户服务解决方案集成,包括 Freshchat!通过轻松的 Freshchat 集成,实现从 AI 聊天机器人到人工支持的无缝切换。...