2017-03-15 8 views

답변

2

Amazon SNS을 사용하여 두 작업 (SMS 및 전자 메일)을 모두 수행하는 것이 좋습니다. 주제를 설정하고 주제를 등록하고 이러한 통지를 보낼 수 있습니다. 앞으로 가장 쉬운 경로는 알렉사 스킬 엔드 포인트에 대한 람다를 사용하는 것입니다, 당신은 Nodejs를 사용하는 경우, 여기를 수행하는 방법의 예입니다

'use strict'; 
var AWS = require("aws-sdk"); 

var playerSMS = (function() { 
    var sns = new AWS.SNS(); 

return { 
    sendTopicSubscribeRequest: function (phoneKey, callback) { 
     var topicName = { 
      Name: phoneKey.toString() 
     }; 

     sns.createTopic(topicName, function(err, data) { 
      if (err) { 
       console.log(err, err.stack); // an error occurred 
       callback('errorCreatingTopicARN'); 
      } else { 
       console.log(JSON.stringify(data)); // successful response 
       console.log('data.TopicArn = ' + data.TopicArn); 
       var topicArn = data.TopicArn; 
       console.log('topicArn = ' + topicArn); 

       // now create the display name, which is a required attribute    
       var params = { 
        AttributeName: 'DisplayName', 
        TopicArn: topicArn, 
        AttributeValue: 'My text' 
       };     
       sns.setTopicAttributes(params, function(err, data) { 
        if (err) { 
         console.log(err, err.stack); // an error occurred 
        } else { 
         console.log('data = ' + JSON.stringify(data)); // successful response 


         // now subscribe the phone number to the topic       
         var subscribeInputParams = { 
          Protocol: 'sms', 
          TopicArn: topicArn, 
          Endpoint: '1-' + phoneKey.toString() //'1-425-890-8000' 
         }; 

         sns.subscribe(subscribeInputParams, function(err, data) { 
          if (err) { 
           console.log(err, err.stack); // an error occurred 
          } else { 
           console.log(JSON.stringify(data)); // successful response 
          }; 
          callback(topicArn); 
         });        
        }; 
       });                   
      }; 
     });   
    }, 


    publishSMS: function (incomingARN, incomingMessage, callback) { 
     sns.publish({ 
      Message: incomingMessage, 
      TopicArn: incomingARN 
     }, function(err, data) { 
      if (err) { 
       console.log(err.stack); 
       console.log(err, 'publishSMS function did not successfully complete.'); 
       var success = false; 
      } 

      if (data) { 
       console.log('publishSMS function successfully sent a text to ' + incomingARN); 
       var success = true;     
      }; 

      // delay callback for 1 second to allow texts to arrive in order 
      setTimeout(callBackAfterDelay, 200); 

      function callBackAfterDelay() { 
       callback(success); 
      };  
     }); 
    }  
};  

})(); 
module.exports = playerSMS; 

호출을 통해 :

playerSMS.sendTopicSubscribeRequest(Player.phoneNumberGoesHere, function (topicArn) { 
    if (!topicArn) { 
     speechText = 'Hmm, there was a problem getting that set up. Please try again later.';    
    } else { // successfully created Topic ARN and sent the subscription request 
     newLoadedPlayer.data.TopicARN = topicArn; 
     speechText = 'You are now set up to receive texts when you ask for them. What would you like to do now?'; 
    }; 
    Player.save(session, function() { 
     response.ask(speechText, repromptTextToSay);  
    });   
}); 

그리고 :

playerSMS.publishSMS(ARNtoSend, textToSend, function (success) { 
    // Do something here upon success or failure 
}) 
0

당신은 alexa와 함께 꽤 잘 작동하는 twilio를 사용할 수 있습니다. https://github.com/krvarma/Amazon-Echo-and-Twilio 내 의견으로는 알렉사에게 이메일로 알리는 것은 불가능합니다. Alexa는 당신이 말한 것을 모두 올바른 텍스트로 변환하지 않습니다. 추가 문제는 특수 문자입니다. _ _

0

이 당신이 이메일 전송을위한 https://www.sendgrid.com를 사용할 수있는 대체 이메일 전송 시스템을 원하는 경우 대답은 이미 아마존을 사용하는 것 같다, 및 SMS에 대한 https://www.twilio.com하지만, MMS, 음성 그리고 더. Twilio는 자체 녹음 및 녹음 서비스는 물론 IBM 왓슨과의 연계를 비롯한 추가 모듈도 제공합니다. 너를 찾아 볼만한 가치가 있을지도 모른다.