答案 0 :(得分:6)
您引用的邮箱称为发送邮箱。如果您使用的是BotFramework-Web Chat,则可以通过styleOptions
传递值来禁用它,如下所示:
<script>
(async function () {
const styleOptions = {
hideSendBox = true
}
[...]
window.ReactDOM.render(
<ReactWebChat
directLine={directLine},
styleOptions={styleOptions}
/>,
document.getElementById( 'webchat' )
);
})
</script>
如果使用的是Web聊天的iFrame嵌入式版本,则不可配置。
希望有帮助!
如果您希望发送框根据从机器人接收到的活动的类型进行响应,则需要使用activityMiddleware()
函数以及事件发射器/侦听器的组合。在以下示例中,当suggestedActions
是活动属性时,我将隐藏/显示发送框。
请注意,数据值应为“ none”和“ flex”。尤其是后者,如果不是suggestedActions
,则为了保持当前代码。
<script>
(async function () {
[...]
const activityMiddleware = () => next => card => {
const { activity: { suggestedActions } } = card;
const toggleSendBoxEvent = new Event('ToggleSendBoxEvent')
if (suggestedActions) {
toggleSendBoxEvent.data = "none";
window.dispatchEvent(toggleSendBoxEvent);
} else {
toggleSendBoxEvent.data = "flex";
window.dispatchEvent(toggleSendBoxEvent);
}
return next(card);
)
[...]
window.ReactDOM.render(
<ReactWebChat
directLine={ window.WebChat.createDirectLine({ token }) }
activityMiddleware={ activityMiddleware }
/>,
document.getElementById( 'webchat' )
);
window.addEventListener('ToggleSendBoxEvent', ( { data } ) => {
const sendBoxes = document.getElementsByClassName("main");
let send_Box;
for (let sendBox of sendBoxes) {
send_Box = sendBox;
}
send_Box.setAttribute('style', `display:${ data }`)
})
});
</script>
希望有帮助!