microsoft / BotFramework-Hubot

Hubot adapter for botframework
MIT License
111 stars 40 forks source link

Document Pls #4

Closed ghost closed 7 years ago

ghost commented 7 years ago

@maxpert

Hi,

Could you please provide the document where the integration is explained.

Tried connecting the adapter to https://botname.azurewebsites.net/api/messages. Getting status as adapter started, but no activities are received when a test chat is initialized at dev.botframework.com

Should there be any other configuration done?

Regards, Ram

billbliss commented 7 years ago

You have set BOTBUILDER_APP_ID and BOTBUILDER_APP_PASSWORD as described in README.md, right?

A related question: are you seeing your app ID echoed in the console at startup?

Seeing no response in the test chat window on dev.botframework.com is consistent with the App ID/App Password not being set correctly.

ghost commented 7 years ago

Hi @billbliss ,

Thank you for your response, Yes I have checked the AppID/Password, and the AppID is echoed in the console at startup.

But nothing happens post that, there are no activities triggered. below is the code. Util = require 'util' Timers = require 'timers'

BotBuilder = require 'botbuilder' {Robot, Adapter, TextMessage, User} = require 'hubot'

LogPrefix = "hubot-botframework:"

class BotFrameworkAdapter extends Adapter constructor: (@robot) -> super @robot @appId = "0cf0da9c-d61a-4d32-b23a-622cf4df870f" @appPassword = "8tSbjmxTmTQ1v2OuZTFU5VV" @endpoint = "https://nodeiva.azurewebsites.net/api/messages" @robot.logger.info "#{LogPrefix} Adapter loaded. Using appId #{@appId}"

    @connector  = new BotBuilder.ChatConnector
        appId: @appId
        appPassword: @appPassword

    #@robot.logger.info "#{LogPrefix} Connected."

    @connector.onEvent (events, cb) => @onBotEvents events, cb
    @robot.logger.info "#{LogPrefix} event is events"

onBotEvents: (activities, cb) ->
    @robot.logger.info "#{LogPrefix} onBotEvents"
    activities = [activities] unless Array.isArray activities

    for activity in activities
        address = activity.address
        user = @robot.brain.userForId address.user.id, name: address.user.name, room: address.conversation.id
        user.activity = activity
        if activity.type == 'message'
            @robot.receive new TextMessage(user, activity.text, activity.sourceEvent.clientActivityId)

send: (context, strings...) ->
    @robot.logger.info "#{LogPrefix} Message"
    @reply context, strings...

reply: (context, strings...) ->
    @robot.logger.info "#{LogPrefix} Sending reply"
    for str in strings
        msg = 
            type: 'message'
            text: str
            address: context.user.activity.address
        @connector.send [msg]

run: ->
    @robot.router.post @endpoint, @connector.listen()
    @robot.logger.info "#{LogPrefix} Adapter running at #{@endpoint}"
    Timers.setTimeout(=> @emit "connected", 1000)

exports.use = (robot) -> new BotFrameworkAdapter robot

ghost commented 7 years ago

adding to my response...

I am able to get response on the test window in dev.botframework.com but the adapter does not record any activities being triggered.

ghost commented 7 years ago
~\Documents\GitHub\hubot> ./bin/hubot -a botframework
[Mon May 22 2017 15:46:57 GMT+0530 (India Standard Time)] INFO hubot-botframework: Adapter loaded. Using appId 21a137ba-f74d-4227-b5b3-7120dab3aa33
[Mon May 22 2017 15:46:57 GMT+0530 (India Standard Time)] INFO hubot-botframework: event is events
[Mon May 22 2017 15:46:57 GMT+0530 (India Standard Time)] INFO hubot-botframework: Adapter running at https://onexhubbot20170515041913.azurewebsites.net/api/messages
[Mon May 22 2017 15:46:57 GMT+0530 (India Standard Time)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (https://github.com/github/hubot-scripts/issues/1113) in favor of packages for each script.

Your hubot-scripts.json is empty, so you just need to remove it.
[Mon May 22 2017 15:46:58 GMT+0530 (India Standard Time)] ERROR hubot-heroku-alive included, but missing HUBOT_HEROKU_KEEPALIVE_URL. `heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s  | grep web-url | cut -d= -f2)`
[Mon May 22 2017 15:46:58 GMT+0530 (India Standard Time)] INFO hubot-redis-brain: Using default redis on localhost:6379
maxpert commented 7 years ago

You should remove the hubot-heroku-alive from your external-scripts.json; my current JSON looks like this:

[
  "hubot-diagnostics",
  "hubot-help",
  "hubot-pugme",
  "hubot-maps",
  "hubot-rules",
  "hubot-shipit"
]
ghost commented 7 years ago

@maxpert , Thanks for your response. I have removed heroku and redis from external-scripts.json;

Below is the status when I run hubot with adapter. [Mon May 22 2017 23:22:21 GMT+0530 (India Standard Time)] INFO hubot-botframework: Adapter loaded. Using appId 3db1ba52-2579-4f55-a5dc-742276eac4c5 [Mon May 22 2017 23:22:21 GMT+0530 (India Standard Time)] INFO hubot-botframework: Adapter running.

Nothing happens after this.. (even if I send messages using the test window in dev.botframework.com) Should there be any scripts created to invoke the activity, or should I modify my Microsoft Botframework bot to send any particular messages to the endpoint.

ghost commented 7 years ago

Has been resolved. Issue with endpoint URL