I have developed a chatbot with Microsoft Bot Framework and have included it in my website via DirectLine:
<div id="chatbot_body"></div>
<script src="https://unpkg.com/botframework-webchat/botchat.js"></script>
<script>
BotChat.App({
directLine: { secret: 'here-is-my-key' },
user: { id: 'Sie' },
bot: { id: 'botid' },
resize: 'detect'
}, document.getElementById("chatbot_body"));
</script>
By default the chatbot window is hidden and it appears only if the user clicks on a "Chat with the chatbot" link.
But I also want that by clicking on this link a conversation is started by the chatbot immediately. I am trying to do this with Jquery by filling out the chat input and sending it to the chatbot when the link is clicked.
$("#chatbot_link").on("click", function(){
$("#chatbot_body").show(); // show chatbot window
$("input.wc-shellinput").val("start"); // fill input field with 'start'
$(".wc-console").addClass("has-text"); // add has-text class (necessary?)
$(".wc-send").click(); // submit form by clicking wc-send
}
But this does not work. The input is not sent to the chatbot and so the chatbot does not say anything.
Any ideas what I am doing wrong here?
Thanks a lot :)