2

I am testing out this android chat application using Bluemix https://github.com/IBM-Bluemix/chatbot-watson-android

At some point in the conversation I will need to call a REST API/webservice to retrieve info about data that has been gathered and send it back to the user as a chat.

I don't want to do it from within the android application as the application wont work when I deploy it to another platform (e.g. slack).

Is there a way to call REST APIs from within watson?

I don't think the conversation service can do it directly, but can it link to another Bluemix service and use the result of that?

opticyclic
  • 7,412
  • 12
  • 81
  • 155
  • You can pass in context variables and have them evaluated or used as part of a dialog. This botkit allows pre- and post-processing https://github.com/watson-developer-cloud/botkit-middleware – data_henrik May 12 '17 at 19:50
  • See http://stackoverflow.com/questions/40263747/how-to-make-watson-conversation-api-invoke-a-web-application-url-when-user-enter – Dudi May 13 '17 at 19:05

2 Answers2

1

If you are already using some form of middleware this can be achieved by setting an action tag in the .JSON editor of the node that should fire the action. This then gets picked up by your middleware listener.

Alternatively try the new cloud actions feature that has just been released here https://console.bluemix.net/docs/services/conversation/dialog-actions.html#dialog-actions which is really simple and easy

ReeceMed
  • 93
  • 7
0

I would create a server to intermediate the communication between your app (android) and the conversation service. This server could call/retrieve the required data before sending the conversation response to your app.

As you're using Bluemix, you could use Node-Red to easily do this. Here is an example of an app that I made exactly this.Example of node-red application

If you are starting with Watson and Bluemix, I strongly advice trying to use the Node-red starting pack. It's really easy to integrate Watson services and call REST API/web-services, even integrate with a database. Here is a starting point to this: https://nodered.org/docs/platforms/bluemix

Happy coding!