2017-07-18 7 views
0

私はMicrosoft Bot Frameworkを使用してChat-botを行っています。ボットは完全にエミュレータ上で正常に動作しています。しかし、私はHerokuにそれをホストしたい。HerokuホスティングMicrosoft Bot Framework Chatbotが動作しません

マイapp.jsコード:

  1. gitのリモートのrm Herokuの
  2. のgit initを
  3. 作成したファイルを:

    var builder = require('botbuilder'); 
    var restify = require('restify'); 
    var apiairecognizer = require('api-ai-recognizer'); 
    var request = require('request'); 
    
    //========================================================= 
    // Bot Setup 
    //========================================================= 
    
    // Setup Restify Server 
    var server = restify.createServer(); 
    server.listen(process.env.port || process.env.PORT || 3978, function() { 
        console.log('%s listening to %s', server.name, server.url); 
    }); 
    
    // Create chat bot 
    var connector = new builder.ChatConnector({ 
        appId: "xxx", /*changed*/ 
        appPassword: "xxx" /*changed*/ 
    }); 
    
    server.post('/api/messages', connector.listen()); 
    var bot = new builder.UniversalBot(connector); 
    
    
    var recognizer = new apiairecognizer("xxx"); 
    var intents = new builder.IntentDialog({ 
         recognizers: [recognizer] 
    }); 
    
    bot.dialog('/',intents); 
    
    intents.matches('Intro',function(session, args){ 
        var fulfillment = builder.EntityRecognizer.findEntity(args.entities, 'fulfillment'); 
        if (fulfillment){ 
         var speech = fulfillment.entity; 
         session.send(speech); 
        }else{ 
         session.send('Sorry...not sure how to respond to that'); 
        } 
    }); 
    
    intents.matches('Default Fallback Intent',function(session, args){ 
        var fulfillment = builder.EntityRecognizer.findEntity(args.entities, 'fulfillment'); 
        if (fulfillment){ 
         var speech = fulfillment.entity; 
         session.send(speech); 
        }else{ 
         session.send('Sorry...not sure how to respond to that'); 
        } 
    }); 
    

    私はHerokuのにそれをプッシュするために、次のコマンドを試してみました.gitignoreとその内部node_modules/

  4. git add。リモート-aアプリ名
  5. GitのプッシュHerokuの:Herokuのは
  6. Herokuのgitのを作成
  7. index.jsノード:
  8. gitの-mコミット
  9. Procfileを "基本的なボットのセットアップが完了" とコード ウェブを追加しましたマスター
  10. Herokuの

私もメッセージングのエンドポイントにエンドポイントをメッセージングによって更新されているオープン:ボットの開発ポータルでhttp://appname.herokuapp.com/api/messages

ビルドが成功しました。 http://appname.herokuapp.com/api/messagesを開いた場合、私は{"code":"MethodNotAllowedError","message":"GET is not allowed"}と開いていると見ています{"code":"ResourceNotFound","message":"/ does not exist"}

私はここにこだわっています。私はBot登録ポータルが提供するI Frameを使ってチャットボットをそのページに持っていきたいと思っています。ここから進んでボットを動かすには?

+0

エンドポイントがPOSTルートであるため、getエラーが予想されます。登録ポータルのチャットは機能しますか? –

+0

サーバーに有効なSSL証明書がありますか?メッセージエンドポイントは、有効な証明書を使用してHTTPS経由で公開する必要があります。 – nilsw

答えて

1

私は同じ問題を抱えており、これを修正しました。 appフォルダ内 オープン端子/ PowerShellと、次の

heroku config:set MICROSOFT_APP_ID=YOUR_APP_ID MICROSOFT_APP_PASSWORD=YOUR_APP_PASSWORD

0

を入力これはあなたのボットをホストして取り組んでいることを意味します。

server.post('/api/messages', connector.listen()); 

ブラウザでhttp://appname.herokuapp.com/api/messagesにアクセスしようとしているとき、あなたはあなたのAPIが受け入れないGETリクエストを、作っている:あなたのボットは、基本的には、POSTリクエストのみを受け入れるAPIです。

iFrameは、herokuでホストされているボットAPIを使用するボットのフロントエンドになります。 https://docs.microsoft.com/en-us/bot-framework/channel-connect-webchat

APIがボットポータルhttps://dev.botframework.com/bots?id=[your-bot-id]で動作しているかどうかは、Webチャットを開く右隅のテストボタンをクリックすることでテストできます。

関連する問題