import * as restify from 'restify' ; import * as builder from 'botbuilder' ; import * as dialogs from './dialogs' ; import * as timeResolver from './time-resolver' ; const server = restify . createServer ( ) ; server . listen ( process . env . port || process . env . PORT || 3978 , function ( ) { console . log ( '%s listening to %s' , server . name , server . url ) ; } ) ; let connector = new builder . ChatConnector ( { appId : process . env . MICROSOFT_APP_ID , appPassword : process . env . MICROSOFT_APP_PASSWORD } ) ; const bot = new builder . UniversalBot ( connector ) ; server . post ( '/api/messages' , connector . listen ( ) ) ; let model = process . env . LUIS_MODEL_URL ; let recognizer = new builder . LuisRecognizer ( model ) ; let intentDialog = new builder . IntentDialog ( { recognizers : [ recognizer ] } ) ; bot . on ( 'conversationUpdate' , ( message ) => { if ( message . membersAdded ) { message . membersAdded . forEach ( function ( identity ) { if ( identity . id === message . address . bot . id ) { bot . beginDialog ( message . address , '/' ) ; } } ) ; } } ) ; bot . dialog ( '/' , intentDialog ) ; bot . dialog ( '/ensureApplication' , dialogs . ensureApplicationDialog ) ; intentDialog . onDefault ( dialogs . defaultDialog ) ; intentDialog . matches ( '查詢假期' , dialogs . queryDialog ) ; intentDialog . matches ( '請假' , dialogs . applyDialog ) ;