I am working on a chatbot project using Google Dialogflow on node.js and would like to use Amazon SES but for some reason it is failing and the code I am using is as below:
var aws = require('aws-sdk');
var ses = new aws.SES(
{
"accessKeyId": functions.config().aws.key,
"secretAccessKey": functions.config().aws.secret,
"region": "eu-west-1" ,
});
var eParams = {
Destination: {
ToAddresses: ["[email protected]"]
},
Message: {
Body: {
Text: {
Data: "Hey! What is up?"
}
},
Subject: {
Data: "Email Subject!!!"
}
},
Source: "[email protected]"
};
var email = ses.sendEmail(eParams, function(err, data){
if(err) console.log(err);
else {
console.log("===EMAIL SENT===");
console.log(data);
}
});
The error I am getting when I look into the logs in Firebase Functions is:
dialogflowFirebaseFulfillment
{ UnknownEndpoint: Inaccessible host: email.us-standard.amazonaws.com'. This service may not be available in the
eu-west-1` region.
at Request.ENOTFOUND_ERROR (/user_code/node_modules/aws-sdk/lib/event_listeners.js:456:46)
A am using the free tier of Firebase, is this something that matters?
The free ("Spark") tier of Cloud Functions for Firebase do not allow network connections outside of Google.
You can upgrade to the "Blaze" plan, however, which does allow network connections. Even with the paid level, there is still a "free tier" which allows for a reasonable level of development and usage that will not incur any charges.
From https://firebase.google.com/pricing/ (hover over the question mark next to Cloud Functions):
On the Blaze plan, Cloud Functions provides a perpetual free tier. The first 2,000,000 invocations, 400,000 GB-sec, 200,000 CPU-sec, and 5 GB of Internet egress traffic is provided for free each month. You are only charged on usage past this free allotment.