Giter Club home page Giter Club logo

Comments (3)

aarora91 avatar aarora91 commented on August 11, 2024

Yes, you can add the code for running /opt/order.sh "juice" "pizza" in the after function in your app.js(or whatever calls the middleware).
See https://github.com/watson-developer-cloud/botkit-middleware/blob/master/examples/multi-bot/app.js#L45

You would have to check the watsonResponse payload to know when to make that external service request so it would look something like this:

middleware.after = function(message, conversationResponse, callback) {
  if(conversationResponse.context.flag){
   // Call your service here.
    postOrder(["juice", "pizza"]);
  }
  callback(null, conversationResponse);
  }

In your Watson Conversation workspace, define a context variable "flag" which will indicate when to place your order. This will be sent back in the response payload. Your node JS app will simply check if flag is set and make the appropriate external service request.

from botkit-middleware.

jersonjunior avatar jersonjunior commented on August 11, 2024

Hello,
I had success using hears the running external scripts:

//Spotify
slackController.hears(['Play spotify music'], ['direct_message', 'direct_mention', 'mention'], function(bot, message) {
  slackController.log('Slack message received');
  bot.reply(message, message.watsonData.output.text.join('\n'));
 // now do something special related to the hello intent
function puts(error, stdout, stderr) { sys.puts(stdout) }
exec("nodejs /home/volumio/spotify.io", puts);

However I still can not use the after function, not sure what to do in the dialog to use a context with variable flag could help me with a simple dialog?

middleware.after = function(message, conversationResponse, callback) {
  if(conversationResponse.context.flag){
   // Call your service here.
   function puts(error, stdout, stderr) { sys.puts(stdout) }
exec("nodejs /home/volumio/spotify.io", puts);
  }
  callback(null, conversationResponse);
  }

from botkit-middleware.

stevenoh93 avatar stevenoh93 commented on August 11, 2024

I've followed up on this on #14

from botkit-middleware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.