Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Application Insights so bot data works #1375

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions samples/javascript_nodejs/20.qna-with-appinsights/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const BOT_FILE = path.join(__dirname, (process.env.botFilePath || ''));
let botConfig;
try {
// Read bot configuration from .bot file.
console.warn('BOTFILE');
console.warn(BOT_FILE);
botConfig = BotConfiguration.loadSync(BOT_FILE, process.env.botFileSecret);
} catch (err) {
console.error(`\nError reading bot file. Please ensure you have valid botFilePath and botFileSecret set for your environment.`);
Expand All @@ -35,12 +37,15 @@ const DEV_ENVIRONMENT = 'development';
const BOT_CONFIGURATION = (process.env.NODE_ENV || DEV_ENVIRONMENT);

// QnA Maker and Application Insights service names as found in .bot file.
const QNA_CONFIGURATION = 'qnamakerService';
const APP_INSIGHTS_CONFIGURATION = 'appInsights';
const QNA_CONFIGURATION = 'qna-with-appinsights-qna';
const APP_INSIGHTS_CONFIGURATION = null;

// Get bot endpoint configuration by service name.
const endpointConfig = botConfig.findServiceByNameOrId(BOT_CONFIGURATION);
const qnaConfig = botConfig.findServiceByNameOrId(QNA_CONFIGURATION);
console.warn('QNA_CONFIGURATION');
console.warn(QNA_CONFIGURATION);

const appInsightsConfig = APP_INSIGHTS_CONFIGURATION
?
botConfig.findServiceByNameOrId(APP_INSIGHTS_CONFIGURATION)
Expand Down Expand Up @@ -103,6 +108,7 @@ let server = restify.createServer();

// Enable the Application Insights middleware, which helps correlate all activity
// based on the incoming request.
server.use(restify.plugins.bodyParser());
server.use(ApplicationInsightsWebserverMiddleware);

server.listen(process.env.port || process.env.PORT || 3978, function() {
Expand Down
3 changes: 2 additions & 1 deletion samples/javascript_nodejs/21.luis-with-appinsights/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const DEV_ENVIRONMENT = 'development';
const BOT_CONFIGURATION = (process.env.NODE_ENV || DEV_ENVIRONMENT);

// LUIS and Application Insights service names as found in .bot file.
const LUIS_CONFIGURATION = 'luis-with-appinsights-luis';
const LUIS_CONFIGURATION = 'jsluis3_luis-with-appinsights-luis';
const APP_INSIGHTS_CONFIGURATION = null; // Define a specific instance of Application Insights (if required)

// Get bot endpoint configuration by service name.
Expand Down Expand Up @@ -116,6 +116,7 @@ let server = restify.createServer();

// Enable the Application Insights middleware, which helps correlate all activity
// based on the incoming request.
server.use(restify.plugins.bodyParser());
server.use(ApplicationInsightsWebserverMiddleware);

server.listen(process.env.port || process.env.PORT || 3978, function() {
Expand Down