Guest User

Untitled

a guest
Oct 20th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. function sendTextMessage(recipientId, messageText) {
  2.  
  3. var reply = messageText.toLowerCase();
  4.  
  5.  
  6. if (reply == 'hey') {
  7. messageText = 'Hello, welcome to the future';
  8.  
  9. }
  10. else if(reply =='GET_STARTED_PAYLOAD'){
  11. messageText = 'I am Charles, your personal assistant, you can ask me about investment options.'
  12. }
  13. else if(reply =='check stocks')
  14. {
  15. messageText = "Can you please tell me the stock symbol for the stock you want to check?";
  16. checkStocks = true;
  17. }
  18. else if(checkStocks)
  19. {
  20. console.log("stocks");
  21. var url = 'https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=AAPL&interval=1min&apikey=I0VJYEWD3R37FUFTXU';
  22.  
  23.  
  24. var request = http.get(url, function(response) {
  25. messageText = response.statusCode;
  26.  
  27. });
  28.  
  29.  
  30. }
  31.  
  32. else{
  33. messageText="I didn't get you, can you please repeat?"
  34. }
  35.  
  36.  
  37. var messageData = {
  38. recipient: {
  39. id: recipientId
  40. },
  41. message: {
  42. text: messageText
  43. }
  44. };
  45.  
  46.  
  47.  
  48. callSendAPI(messageData);
  49. }
Add Comment
Please, Sign In to add comment