I'm working with Microsoft Bot Framework in Azure and have a working bot. However, as of now, it waits in an empty status, and just reacts. I would like to add/start the conversation with something like: "hi, how can I help you?"
Here is my code:
"use strict";
var builder = require("botbuilder");
var botbuilder_azure = require("botbuilder-azure");
var path = require('path');
var useEmulator = (process.env.NODE_ENV == 'development');
var connector = useEmulator ? new builder.ChatConnector() : new botbuilder_azure.BotServiceConnector({
appId: process.env['MicrosoftAppId'],
appPassword: process.env['MicrosoftAppPassword'],
stateEndpoint: process.env['BotStateEndpoint'],
openIdMetadata: process.env['BotOpenIdMetadata']
});
var bot = new builder.UniversalBot(connector);
bot.localePath(path.join(__dirname, './locale'));
// Make sure you add code to validate these fields
var luisAppId = process.env.LuisAppId;
var luisAPIKey = process.env.LuisAPIKey;
var luisAPIHostName = process.env.LuisAPIHostName || 'westus.api.cognitive.microsoft.com';
const LuisModelUrl = 'https://' + luisAPIHostName + '/luis/v1/application?id=' + luisAppId + '&subscription-key=' + luisAPIKey;
// Main dialog with LUIS
var recognizer = new builder.LuisRecognizer(LuisModelUrl);
var intents = new builder.IntentDialog({ recognizers: [recognizer] })
/*
.matches('<yourIntent>')... See details at http://docs.botframework.com/builder/node/guides/understanding-natural-language/
*/
.matches('None', (session, args) => {
session.send('Hi, this is the None handler. You said: \'%s\'.', session.message.text);
})
.matches('get_price', (session, args) => {
session.send('Hi, you asked about the cost of a service: oil change: $10, brakes: $50, transmission: $200: \'%s\'.', session.message.text);
})
.matches('get_service', (session, args) => {
session.send('Hi, you asked about car service options, here they are: oil change, brakes, and transmissions');
})
.matches('cant_service', (session, args) => {
session.send('Sorry, we do not offer that service: \'%s\'.', session.message.text);
})
.matches('schedule_apt', (session, args) => {
session.send('Hi, you asked about scheduling an appointment, please call 1-800-fix-cars to schedule');
})
.matches('greeting', (session, args) => {
session.send('Hi you!');
})
.onDefault((session) => {
session.send('Sorry, I did not understand \'%s\'.', session.message.text);
});
bot.dialog('/', intents);
if (useEmulator) {
var restify = require('restify');
var server = restify.createServer();
server.listen(3978, function() {
console.log('test bot endpont at http://localhost:3978/api/messages');
});
server.post('/api/messages', connector.listen());
} else {
module.exports = { default: connector.listen() }
}