Dialogflow fullfilment code send otp using twilio in nodejs - node.js

I want to send otp to my mobile number, as part of a fulfilment on dialogflow using twilio. I have followed the instructions in https://www.twilio.com/docs/sms/tutorials/how-to-send-sms-messages-node-js link to setup twilio account and get the phone number. Have added the account sid and authtoken also in the code.But still I am not able to recieve any sms in my mobile. Any help would be appreciated. Below is the code which I have as part of OTP authentication.
app.intent('Proceed_Auth', (conv) => {
client.messages.create({
body: `You just sent an SMS from Node.js using Twilio!`,
from: '+1619XXXXXXX',
to: '+9194XXXXXXXX'
}).then(
(message) => console.log("send msg",message.sid)
);
conv.contexts.set('otp', 1);
conv.ask('I have sent an OTP to your number. Please enter the OTP');
});

Related

Send email from NestJS, deployed to Firebase functions to the associated Gmail account's address

I've a NestJS application deployed to Firebase wired up with Firebase functions. I've an API which accepts a form data from a different Firebase Angular frontend project (I prefer the BE and FE projects to be separated).
I'd like to send that contact form data through my NestJS backend due to validation purposes via email to the Firebase admin email address (my Google account email) with all the form data, after the validation is succeeded.
So it's basiacally a contact form, by the user, to the admin. I've digged through the documentation and I've found solutions only for the other direction, so the app sends email to the users after something triggers this function (with Nodemailer, and with a 3rd party SMTP mail service).
Is there a solution to send the contact form data to my Gmail (associated with the Firebase account too) in the desired way? Do I really need to use Nodemailer and a 3rd party service to send an email to myself with the data from the contact form?
The process flow should be the following:
Users fills out the contact form
After FE validation the data is sent to the NestJS API
After BE validation the data is sent to my Gmail email address
Thanks for the suggestions in advance!
elyndel
Using Nodemailer would be the easiest option to send an email. You can use the same recipient email as the sender so you don't need any other mail service like SendGrid. Just specify the same email in both from and to:
const mailOptions = {
from: "user#gmail.com",
to: "user#gmail.com",
subject: "New registration",
text: "<Details>",
};
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
console.log(error);
} else {
console.log("Email sent: " + info.response);
}
});

NodeJS firebase-admin cannot send email verification link

I'm using node firebase-admin to manage user as follow.
function (req, res, next) {
const { email, password } = req.body;
const auth = getAuth();
const userRecord = await auth.createUser({ email, password });
auth.generateEmailVerificationLink(email).then(console.log);
// this log verify link successfully xyz.firebaseapp.com/__/auth/action?mode=verifyEmail&oobCode=...
await accountService.createAccount({ id: userRecord.uid, email })
res.status(200).json(userRecord);
}
I also tried different email and also debug auth.generateEmailVerificationLink function and saw it invoked to firebase auth api and succeed. But cannot find email in mail box or spam.
The generateEmailVerificationLink method of the Firebase Admin SDK only generates the link you would put into a message. Once the link is generated, you then need to embed that link into a message and then send the email using whatever service you desire.
If you want to use the built-in email verification methods, you must use the appropriate sendVerificationEmail method of the client-side SDKs.
The Firebase Client SDKs provide the ability to send users emails containing links they can use for password resets, email address verification, and email-based sign-in. These template-based emails are sent by Google and have limited customizability.

Slack webhook not sending personal message

I am trying to send personal message to particular user using webhook. I created webhook so i am getting personal message. But I am not able to send personal message to others personal chat. I don't want to use bot.
slack.setWebhook("Webhook");
slack.webhook({
channel: "D01KMUZ4E4S",
username: "webhookbot",
text: "This is posted to #general and comes from a bot named webhookbot."
}, function(err, response) {
console.log(response);
});
Slack Webhook URLs are tied to a particular channel, individual message, or group message. You need to create a new webhook in your workspace for each user you would like to send messages to.

Sendgrid doesn't trigger webhook when email is sent

I'm using Sendgrid in an ASP.NET WEB API project, and I'm testing the webhook call with ngrok.
I first followed this guide: https://docs.sendgrid.com/for-developers/tracking-events/getting-started-event-webhook
Therefore i turned on Event Webhook and tested it with their integration test.
The problem is that it works only during test, if I send an email with my software, webhook is not fired. ( I receive the email, but Ngrok doesn't record a request)
This is how i send the email:
var client = new SendGridClient(Config.sendGridApiKey);
var x = MailHelper.CreateSingleEmail( new EmailAddress(Config.mymail),
new EmailAddress(to), content, content, content);
return await client.SendEmailAsync(x).ConfigureAwait(false);
I didn't choose the event triggering the webhook from the panel.
Now it works!

Twilio - sending sms doesn't call the statusCallback URL

Twilio free account.
This is how I send the message:
const args = {
from : TWILIO_PHONE_NUMBER,
to : '+15005550006', // magic test number
body : "test",
statusCallback: 'https://postb.in/1604476976671-5019259769469' //twilioCallback.getUrl()
}
message = await this.client.messages.create(args)
Results: postbin never receives a request. nor does my own twilio callback url. Do I need to subscribe, create a messaging service, pay for a sender phone number, and use that messaging service id in the args? Does that make it work?
Magic numbers / test credentials don’t send requests. Use your production Account SID and Auth Token and a real Twilio number to send the request.
Why aren't my test credentials working?

Resources