0
私はC#とVisual Studioを使ってChatBotを構築しています。私がしたいことは、ChatBotへのいくつかの質問の後で、ユーザーはキーボードをもう使用できない、それを行う方法を説明しているウェブサイトを見たことがあるが、誰かが助けてくれると分かりませんでした。ブロックキーボード入力chatbot
アイデアは、ユーザーがチャットボットに書き込むことを妨げるものをelseブロックに入れることです。そのため、彼が入力したものを書きたい場合は、画面に表示されません。ここに私のコードは次のとおりです。
private int NombreDeMessages;
protected override async Task MessageReceived(IDialogContext context, IAwaitable<IMessageActivity> item)
{
var message = await item;
NombreDeMessages += 1;
string code = EndOfConversationCodes.CompletedSuccessfully;
CancellationToken cancellationToken = default(CancellationToken);
if (message.Text != null && NombreDeMessages < 3)
{
await base.MessageReceived(context, item);
}
else if (message.Text != null && NombreDeMessages == 3)
{
AdaptiveCard card = new AdaptiveCard();
card.Body.Add(new TextBlock()
{
Text = "STOP FLOODING",
Weight = TextWeight.Bolder,
IsSubtle = true,
Wrap = true,
Size = TextSize.Large
});
card.Body.Add(new TextBlock()
{
Text = "You have reach the limit of queries",
IsSubtle = false,
Wrap = true,
Size = TextSize.Normal
});
card.Body.Add(new Image()
{
Url = "http://images.roadtrafficsigns.com/img/dp/lg/traffic-stop-sign.png",
HorizontalAlignment = AdaptiveCards.HorizontalAlignment.Center,
Size = ImageSize.Stretch
});
Attachment attachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = card
};
var flood = context.MakeMessage();
flood.Attachments.Add(attachment);
await context.PostAsync(flood);
}
else
{
var reply = context.MakeMessage();
reply.Type = ActivityTypes.EndOfConversation;
reply.AsEndOfConversationActivity().Code = code;
await context.PostAsync(reply, cancellationToken);
}
}
はい、私はC#アプリケーションを持っていない、ウェブアプリケーションに入力をブロックします。私のHTMLコードはこれです:
<!DOCTYPE html>
<html>
<body style="width:100%;height:100%;">
<script>
(function() {
var div = document.createElement("div");
document.getElementsByTagName('body')[0].appendChild(div);
div.outerHTML = "<div id='botDiv' style='height: 38px; position: fixed; bottom: 0; z-index: 1000; background-color: #fff'><div id='botTitleBar' style='height: 38px; width: 400px; position:fixed; cursor: pointer;'></div><iframe width='400' height='600' src='https://webchat.botframework.com/embed/supportbotv2?s=4mHD9MekOvU.cwA.8ZU.Pn31pCpv8kyq7UQCr3y4bM-99W4eHxUt-LlhBnCp9JY'></iframe></div>";
document.querySelector('body').addEventListener('click', function (e) {
e.target.matches = e.target.matches || e.target.msMatchesSelector;
if (e.target.matches('#botTitleBar')) {
var botDiv = document.querySelector('#botDiv');
botDiv.style.height = botDiv.style.height == '600px' ? '38px' : '600px';
};
});
}());</script>
</body>
</html>
問題は、チャットボットがiframeリンクを含むウェブサイトに埋め込まれているため、キーボード入力が行われたテキストボックスにアクセスできないと考えられます。私のコードと私のChatBotをテストするために私はBot Framework Channel Emulatorを使っています。だから私はそれが動作しないと思う –
Webアプリケーションの入力をブロックするか、C#(winforms)アプリケーションを持っていますか? –
はいWebアプリケーションの入力をブロックしたいのですが、私はC#アプリケーションを持っていません。私の質問で私のHTMLコードを見ることができます。 –