2017-03-15 3 views
0

私はalexaでSMSと電子メールサービスを実装しようとしており、PHP、Jqueryを使用してタスクを遂行しています。私はこの技術には非常に慣れていて、多くのウェブサイトに声をかけた後、どこかで失われて始めることができません。トピックに関するご意見をお聞かせください。alexaでSMSと電子メールサービスを実装する方法は?

答えて

2

Amazon SNSを使用して、両方のタスク(SMSと電子メール)を達成することをお勧めします。トピックを設定し、トピックにユーザを登録し、これらの通知を送信することができます。前方の最も簡単なパスはあなたのAlexaのスキルエンドポイントのラムダを使用することで、あなたが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);  
    });   
}); 

そして:

あなたがメール送信のための https://www.sendgrid.comを使用することができ、代替Emailerのを望んでいた場合、すでにアマゾンを利用答えがあるようですけど
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 does notは、あなたが正しいテキストに言うすべてのものを変換します。追加の問題は特殊文字です - _ @

0

、およびSMSのためhttps://www.twilio.com、MMS、音声 もっと。 Twilioには独自の録音サービスと録音サービスがあり、IBMワトソンと連携することも可能です。あなたのために見て価値があるかもしれません。

関連する問題