You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于为FlowiseAI聊天机器人添加即时提问按钮功能的咨询

为FlowiseChatbot添加预设提问按钮的实现方案

核心实现路径

基于FlowiseChatEmbed的扩展能力,你可以通过以下几种方式实现预设提问按钮功能:

1. 静态数组配置预设问题

修改聊天嵌入代码的配置项,加入预设问题数组,再通过前端代码渲染按钮并绑定发送事件:

// 初始化Flowise聊天组件
const chatbot = new FlowiseChatEmbed({
  chatflowid: "你的聊天流ID",
  apiHost: "你的API地址"
});

// 预设问题数组
const presetQuestions = [
  "What are your business hours?",
  "Do you have any specials?"
];

// 渲染预设按钮
const presetContainer = document.createElement("div");
presetContainer.className = "preset-question-buttons";
presetQuestions.forEach(question => {
  const btn = document.createElement("button");
  btn.textContent = question;
  btn.onclick = () => chatbot.sendMessage(question);
  presetContainer.appendChild(btn);
});
// 将按钮容器插入到聊天组件前方
document.body.insertBefore(presetContainer, chatbot.chatContainer);

2. 从Google Sheet动态导入问题

通过Google Sheets API读取在线表格中的问题列表,动态生成预设按钮:

// 请求Google Sheet数据(需先将表格设为公开并获取JSON接口)
fetch("Google Sheet公开JSON接口")
  .then(res => res.json())
  .then(data => {
    const presetContainer = document.querySelector(".preset-question-buttons");
    // 假设表格中问题列的键为"question"
    data.rows.forEach(row => {
      const btn = document.createElement("button");
      btn.textContent = row.question;
      btn.onclick = () => chatbot.sendMessage(row.question);
      presetContainer.appendChild(btn);
    });
  });

3. 基于FlowiseChatEmbed源码定制

如果需要更深度的集成,可以直接修改FlowiseChatEmbed的源码:

  • 在项目的聊天窗口组件中添加预设按钮区域
  • 将预设问题作为配置参数传入组件,实现开箱即用的配置化功能

交互逻辑参考

参考Shopify即时聊天的设计:点击预设按钮后,问题自动填入输入框并发送,机器人即时返回对应回复,降低用户输入成本。

内容的提问来源于stack exchange,提问作者Bill

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 06:43:13