Guest User

Untitled

a guest
Nov 30th, 2017
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. var ConversationV1 = require('watson-developer-cloud/conversation/v1');
  2.  
  3. /**
  4. * Sends a message to the Watson Conversation service
  5. *
  6. * @param {String} username
  7. * @param {String} password
  8. * @param {String} [text]
  9. * @param {Object} [context]
  10. * @param {String} workspace_id
  11. *
  12. * @returns {Object} Promise
  13. */
  14.  
  15. function main(params) {
  16.  
  17. var conversation = new ConversationV1({
  18. username: params.username,
  19. password: params.password,
  20. version_date: '2017-02-03'
  21. });
  22.  
  23. return new Promise(function(resolve, reject) {
  24. conversation.message({
  25. input: { text: params.text },
  26. context: params.context,
  27. workspace_id: params.workspace_id
  28. }, function(err, response) {
  29. if (err) {
  30. console.error(err);
  31. reject(err);
  32. } else {
  33. resolve(response);
  34. }
  35. });
  36. });
  37. }
Add Comment
Please, Sign In to add comment