#1- Add library NodeMailer: "nodemailer": "6.4.6" at **package.json
#2- Create your Cloud Function in the Fulfillment: -Add in your index.js the const nodemailer
function getsheetData() | |
return axios.get (‘https://sheetdb.io/api/v1/xirgfp569xwov‘); | |
} | |
function welcome (agent) { | |
const name = agent.parameters.name; | |
return getSpreadsheetData().then(res => { | |
res.data.map(person => { | |
if (person.Name === name} |
const functions = require('fire-functions'); | |
const {WebhookClient} = require('df-fulfillment'); | |
const nodemailer = require("nodemailer"); |
let intentMap = new Map(); | |
intentMap.set('Welcome', welcome); | |
intentMap.set('Fallback', fallback); | |
intentMap.set('Notify2Email', NotifyHandler); | |
agent.handleRequest(intentMap); | |
}); |
function sendEmailHandler (agent) { | |
const {email, name} = agent.parameters; | |
const transporter = nodemailer.createTransport({ | |
host: 'smtp.mail.com ', | |
port: 465, | |
service: 'gmail', | |
auth: { | |
user: 'yourUsername', | |
pass: 'yourPassword' | |
} |
const transporter = nodemailer.createTransport({ | |
host: 'smtp.gmail.com ', | |
port: 465, | |
service: 'gmail', | |
auth: { | |
user: '[email protected]', | |
pass: 'YourSecurePasswordHere' | |
} | |
}); |
const mailOptions = { | |
from: "YourmailUserID", // Here insert the sender Gmail address | |
to: email, // Here goes the users email receivers | |
subject: "Bot Notification DEMO", // Here insert your Subject line | |
html: '<h1>Welcome ${name} I'm Notify Bot 🤖</h1> | |
<h2>Here you add your message template and content</h2> | |
<p> 🤖 And media content to personalise the email notification to your users ✅ </p> ', | |
attachments: | |
[{ |
transporter.sendMail(mailOptions, function (err, info) { | |
if(err) | |
console.log(err); | |
else | |
console.log(info); | |
}); | |
} |
<header id="header"> | |
<h1><a href="#">🛰️ COVID19 Spread Monitor 🌎 <span> @NASA Space Apps Covid-19 Challenge 🚀 </span></a></h1> | |
<a href="#menu">Menu</a> | |
</header> | |
<div id='map'></div> | |
<div id='day-panel'> | |
<div id='day-label'></div> | |
<input id="day-slider" type="range" min="-6" max="0" value="0"></div> | |
</div> |