0
js、初めて、node.jsのAzure用のMicrosoftのボットフレームワークを使ってボットを開発しようとしました。node.jsの予期しないトークン
iが(テンプレートであった)完全なコード下に添加のみのコードは、このです:ここ
.matches('None', (session, args) => {
session.send('Hi, this is the None handler. You said: \'%s\'.', session.message.text);
});
完全なコードである:ここ
"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);
});
.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() }
}
はエラーである。
SyntaxError: Unexpected token .
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:528:28)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at eval (eval at compileFunc (D:\Program Files (x86)\SiteExtensions\Functions\1.0.11015\bin\edge\double_edge.js:34:28), <anonymous>:1:80)
at compileFunc (D:\Program Files (x86)\SiteExtensions\Functions\1.0.11015\bin\edge\double_edge.js:35:16).
2017-07-12T18:21:57.420 Function started (Id=71b6a39b-ebca-4bc4-a642-5e7cfb68c921)
2017-07-12T18:21:57.420 Function completed (Failure, Id=71b6a39b-ebca-4bc4-a642-5e7cfb68c921, Duration=0ms)
2017-07-12T18:21:57.436 Exception while executing function: Functions.messages. mscorlib: D:\home\site\wwwroot\messages\index.js:42
.onDefault((session) => {
^
SyntaxError: Unexpected token .
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:528:28)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
冗長である後にセミコロンを教えてしようとしている、 '」.'' – SLaks
、間違っているそして、あなたが' '試合後のセミコロンを削除しようとするでしょうか? – LEQADA