I am developing one chat bot using Microsoft Bot Framework in NodeJs. Most of the time it works perfectly as expected. But sometimes when I am communicating with the bot, I'm not getting the response immediately. After entering the second question it is responding both the questions continuously. Help me to fix this issue. Should I do something on the server side?
dialog.matches('help',[
function (session, args, next) {builder.Prompts.choice(session, "I can help you to shop products for your lifestyle. You can buy from the following categories.", "Computer|TV|See more", { listStyle: builder.ListStyle["list"] });
},
function (session, results) {
if (results.response.entity=='TV') {
session.send("Wow. That sounds interesting one. We have many %s models. Ask me question like \"I want to buy black color Samsung LED Tv .\"", results.response.entity);
session.endDialog();
}else{
session.send("Selected category is expected soon.");
session.endDialog();
}
}]);
You might consider using the Session.sendBatch method to force queued messages to be delivered immediately.
My guess is that you encountered a known problem with the Web Chat control. See https://github.com/Microsoft/BotBuilder/issues/965 for reference. If this is the case, then the behaviour you described should have resolved in the meantime with the update 5 days ago.
Can you please re-test and confirm if the problem persists?
Related
I want to get the welcome message from bot first in dialogflow. I am not sure how to do this. Any ideas on how to do this.
I tried reading about events in dialogflow as Default welcome intent uses "Welcome" event. But not able to find any solution.
As I opened up my bot framework, it should pop up "Hi, I am a virtual assistant. How can I help you?"
I am not sure of which bot technology you are using, but if your front end is in html/js, you may call a function like this:
Define it something like:
function myFunction(){
''here you may pass a parameter to your bot to display a pre-defined message. I am not going in details here, as I am not sure about the framework you are using.''
}
The onload (in body) will call myFunction(), everytime the page is refreshed.
P.s - I will update this answer once I get more details from your end. Since I am new here, please excuse in case of any issues.
I am trying to build a simple chrome extension that will block a list of websites. At the moment I have this:
function logURL(requestDetails) {
console.log("Loading: " + requestDetails.url);
alert(1);
}
chrome.webRequest.onBeforeRequest.addListener(
logURL,
{urls: ["*://*.google.com/*"]}
);
When I go to google I get an alert. When I close the alert I get another one and another one and they keep coming.
When I take out the
alert(1);
I don't get any alerts but I also do not get any console logs which I would expect.
Any ideas?
P.S I'm a junior developer and just learning so apologies if this is really simple, I would appreciate a detailed reply as it will help me develop my skills.
I am currently building a chat bot using Microsoft Bot Framework and node.js.
I would like to find a way of modifying / pre-populate user input/received message.
For example, chat bot asks "What is your age?"
And the user can simply type "25".
For this scenario, instead of just showing 25, I would like to show "My age is 25."
Could anyone please tell me how I can achieve this?
Thank you.
It is very well documented here https://learn.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-dialog-prompt?view=azure-bot-service-3.0
bot.dialog('nameOfDialog', [
function (session) {
builder.Prompts.number(session, 'What is your age?');
},
function (session, results) {
// user input is stored in results.response
session.endDialog(`My age is ${results.response}`);
}
])
I have a webview in my bot.
I have the following JS code to close it:
complete: function (data) {
MessengerExtensions.requestCloseBrowser(function success() {
}, function error(err) {
window.close()
});
console.log("post success");
}
The webview is being closed on ANDROID and WEB But NOT on IOS.
Any help would be appreciated.
So apparently my problem was a mistake which led to a misunderstanding of the problem.
I didn't add messenger_extensions: true and didn't whitelist my domain. Due to that the MessengerExtensions call failed, and always got to the fallback which was window.close() - which works on WEB and Android, but not on IOS - hence I thought that all works but IOS.
After adding messenger_extensions: true and whitelisting the domain all worked out.
You can search for related bugs here, i searched for a one related to your issue but there is none.
I am testing a bot that I am building using the Bot Framework. The emulator for local testing that Microsoft created has several events that can be provided to the bot to solicit a response.
I looked at the GitHub samples provided for Node.js here, but I can not find any example that responds to the different events within the Bot Framework Emulator.
The states are:
Bot Added to Conversation
Bot Removed from Conversation
User Added to Conversation
User Removed from Conversation
End of Conversation
Ping
Delete User Data
The API also does not make it clear how to achieve any of these actions.
Does anyone have any insight on where I should be looking for a example, or the API entries that I should be using?
In response to one of the answers, I did try code -
.onDefault(function (session) { console.log(session.message.type); }
But it only ever display "message" if a message was sent by the user.
The incoming message.type field will have "BotAddedToConversation" etc.
For the Node SDK, the botConnectorBot is able to trigger custom listeners on events using the on() handler.
Example
var builder = require('botbuilder');
var bot = new builder.BotConnectorBot({ appId: 'APPID', appSecret: 'APPSECRET' });
bot.on('DeleteUserData', function(message) {
// Handle Deleting User Data
});
More information can be found here.
You are also able to configure some standard messages using the configure() method.
Example
bot.configure({
userWelcomeMessage: "Hello... Welcome to the group.",
goodbyeMessage: "Goodbye..."
});
More information on what can be configured through options is located here.
Concerns
This is not part of the question, as the question was to identify how to listen to these events. But as a general concern, the event listener does not return a session object. It is unclear how to act once you handle the event.