@google-cloud-suite/firebase-functions-sendgrid-contact
TypeScript icon, indicating that this package has built-in type declarations

0.0.31 • Public • Published

@google-cloud-suite/firebase-functions-sendgrid-contact

Send email by sendgrid

  1. Install
npm install @google-cloud-suite/firebase-functions-sendgrid-contact
  1. 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.

Examples:

const sendgridContact = require("@google-cloud-suite/firebase-functions-sendgrid-contact");
exports.createContact = sendgridContact.handle({
   apiKey: "sgapikey",
   emailFrom: "no-reply@example.org",
   emailTo: "you@example.org",
   defaultSubject: "Message from customer",
   reply: { defaultSubject: "Thank you for your contact!" }
});
  1. Call function
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: "customer@example.org"})
  .then((result) => {
    alert("success");
  });

  1. Deploy
firebase deploy

Readme

Keywords

none

Package Sidebar

Install

npm i @google-cloud-suite/firebase-functions-sendgrid-contact

Weekly Downloads

1

Version

0.0.31

License

MIT

Unpacked Size

5.32 kB

Total Files

4

Last publish

Collaborators

  • nabeix