Botkit: Connect botkit in bot framework

Created on 23 Mar 2017  路  6Comments  路  Source: howdyai/botkit

I am new to botkit and would like to connect my bot with the bot framework ... When I am going to register a bot in the bot framework it asks for an endpoint, I do not know how to get this endpoint, if someone can help me I would be very grateful.

I'll put my code to help:

require('dotenv').load();

var express = require('express');
var Botkit = require('botkit');
var middleware = require('botkit-middleware-watson')({
username: process.env.CONVERSATION_USERNAME,
password: process.env.CONVERSATION_PASSWORD,
workspace_id: process.env.WORKSPACE_ID,
version_date: '2017-02-07'
});

// Configure your bot
var slackController = Botkit.slackbot({
require_delivery: true,
});

var nome = "";
var slackBot = slackController.spawn({
token: process.env.SLACK_TOKEN
}).startRTM();

slackController.hears(['.*'], ['direct_message', 'direct_mention', 'mention'], function(bot, message) {
slackController.log('Slack message received');
middleware.interpret(bot, message, function(err) {
if (!err){
//N脙O 脡 GOODBYE E INDENTIFICOU UMA INTEN脟脙O
if(!(typeof message.watsonData.intents[0] == "undefined")){
//Impressora

    switch(message.watsonData.intents[0].intent){
      case 'Impressora':
        bot.startConversation(message,function(err,conv){
        conv.say({attachments:[{
          "text": (message.watsonData.context.name+", "+message.watsonData.output.text[0]),
        },{
          "text": message.watsonData.output.text[1],
        },{
          "text": message.watsonData.output.text[2],
          "image_url":message.watsonData.context.Img1,
        },{
          "text": message.watsonData.output.text[3],
          "image_url":message.watsonData.context.Img2,
        },{
          "text": message.watsonData.output.text[4],
          "image_url":message.watsonData.context.Img3,
        },{
          "text": message.watsonData.output.text[5],
          "image_url":message.watsonData.context.Img4,
        },{
          "text": message.watsonData.output.text[6],
          "image_url":message.watsonData.context.Img5,
        },{
          "text": message.watsonData.output.text[7],
          "image_url":message.watsonData.context.Img6,
        },{
          "text": message.watsonData.output.text[8],
        },{
          "text": message.watsonData.output.text[9],
          "image_url":message.watsonData.context.Img7,
        },{
          "text": message.watsonData.output.text[10],
          "image_url":message.watsonData.context.Img8,
        },{
          "text": message.watsonData.output.text[11],
          "image_url":message.watsonData.context.Img9,
        },{
          "text": message.watsonData.output.text[12],
          "image_url":message.watsonData.context.Img10,
        },{
          "text": message.watsonData.output.text[13],
        }]});
      });
        break;
      case 'Sauda莽茫o':
        bot.api.users.info({
        token: process.env.SLACK_TOKEN,
        user: message.user}, function(err, info){
          message.watsonData.context.name = info.user.profile.real_name;
          nome =  info.user.profile.first_name;
          bot.reply(message,message.watsonData.output.text.join('\n'));
                        });
        break;
      default:
        bot.reply(message, message.watsonData.output.text.join('\n'));
        break;
    }
  //INTENT INDEFINIDA
  }else{
    //Verifica se ja possui o nome do usuario
    if(message.watsonData.context.name == ""){
      bot.api.users.info({
        token: process.env.SLACK_TOKEN,
        user: message.user}, function(err, info){
          message.watsonData.context.name = info.user.profile.real_name;
          nome =  info.user.profile.first_name;
                        });
      bot.reply(message, message.watsonData.output.text.join('\n'));
    }else{
      bot.reply(message, message.watsonData.output.text.join('\n'));
    }

  }
}//IF ERR

});
});

var app = express();
var port = process.env.PORT || 3000;
app.set('port', port);
app.listen(port, function() {
console.log('Client server listening on port ' + port);
});

Microsoft-Bot Framework-related help wanted

All 6 comments

Are you referring to the Microsoft Bot framework?

Yes, I need to publish the bot to get a URL and link it in the bot framework...
The code to connect to the bot-framework I know build, but I do not know how to get a URL to put in the bot-framework

By default the bot framework endpoint will be something like:
YOURSERVERNAME/receive

If you are running ngrok or localtunnel, just append /receive to the end of the url generated when running those programs.

You can read more about this in the docs:
https://github.com/howdyai/botkit/blob/master/readme-botframework.md

Thanks my friend...

hi,
is it possible to incoke/use a bot created using botkit from a java application?
the docs for 3rd party integration only mention microsoft bot framework.

is it possible to integrate or embed in another java application? if yes, is there any doc for that?

thax

Was this page helpful?
0 / 5 - 0 ratings

Related issues

imjul1an picture imjul1an  路  3Comments

GautierT picture GautierT  路  3Comments

iworkforthem picture iworkforthem  路  3Comments

TheJimFactor picture TheJimFactor  路  4Comments

HannanShaik picture HannanShaik  路  3Comments