我正在制作的机器人将从字段中获取值,并将用户重定向到相应的团队,销售或支持,这在机器人中都可以正常管理。
当前工作流程为:输入值,postActivity发送这些值,启动聊天。
问题是,聊天界面阻止用户输入消息并发送消息。通常,当键入消息时,提交箭头变为蓝色,然后用户可以提交。任何人都知道机器人为什么没有按预期工作?感谢您提供任何指导。
<body>
<div id="hiddenChatFields" style="background-color:white; width:300px;height:600px;">
Chat Team: <select name="team"><option value="Support">Support</option><option value="Sales">Sales</option></select>
Name:<input id="name" type="text" />
Organisation:<input id="organisation" type="text" />
Email:<input id="email" type="text" />
Phone:<input id="phone" type="text" />
<button id="chatSubmit" onclick="initiateChat()">Submit</button>
</div>
<div id="chat" style="background-color:white; width:250px;height:600px;">
<div id="bot" />
</div>
</body>
<script src="https://cdn.botframework.com/botframework-webchat/latest/botchat.js"></script>
<script>
$("#hiddenChatFields").show();
$("#chatButton").show();
$("#chat").hide();
const botConnection = new BotChat.DirectLine({
secret: 'secretHere',
});
BotChat.App({
user: { id: 'You' },
bot: { id: botid},
resize: 'detect',
botConnection: botConnection
}, document.getElementById("bot"));
function initiateChat() {
//todo validation
$("#chat").show();
$("#hiddenChatFields").hide();
botConnection.postActivity({
type: 'message',
from: { id: 'You' },
name: 'buttonClicked',
value: 'fieldsToPass',
}).subscribe(function (id) { console.log('Values sent'); });
}
</script>