@google-cloud-suite/firebase-functions-sendgrid-contact
v0.0.37
Published
@google-cloud-suite/firebase-functions-sendgrid-contact
Downloads
33
Readme
@google-cloud-suite/firebase-functions-sendgrid-contact
Send email by sendgrid
- Install
npm install @google-cloud-suite/firebase-functions-sendgrid-contact
- Handle http trigger
You can use handle(params?: InitParams)
to initialize trigger. The followings are the property of InitParams:
- apiKey: string
- emailFrom: string
- emailTo: string
- defaultSubject?: string
- reply?: { defaultSubject?: string }
- if
reply
is not set, reply message is not sent.
- if
Examples:
const sendgridContact = require("@google-cloud-suite/firebase-functions-sendgrid-contact");
exports.createContact = sendgridContact.handle({
apiKey: "sgapikey",
emailFrom: "[email protected]",
emailTo: "[email protected]",
defaultSubject: "Message from customer",
reply: { defaultSubject: "Thank you for your contact!" }
});
- Call function
- body: string
- subject?: string
- attachments?: AttachmentData[]
- AttachmentData
- content: string
- filename: string
- type?: string
- disposition?: string
- contentId?: string
- see: https://github.com/sendgrid/sendgrid-nodejs/blob/main/docs/use-cases/attachments.md
- AttachmentData
- replyBody?: string
- replyTo?: string
- replySubject?: string;
import { getFunctions, httpsCallable } from "firebase/functions";
const functions = getFunctions();
const createContact = httpsCallable(functions, "createContact");
contact body = "Hello, I have a question.";
createContact({ body })
.then((result) => {
alert("success");
});
// If you want to reply thanks email to your customer
createContact({ body, replyBody: "You sent: " + body, replyTo: "[email protected]"})
.then((result) => {
alert("success");
});
- Deploy
firebase deploy