Code Monkey home page Code Monkey logo

Comments (4)

Ehesp avatar Ehesp commented on August 29, 2024 3

Hi @NLegendre - this example may help you: https://github.com/firebase/extensions/blob/master/firestore-send-email/POSTINSTALL.md#using-templates

To summarise:

Create a new document in Firestore for your templates, for example for a template called "Following", create a new document in templates/following:

{
  subject: "@{{username}} is now following you!",
  html: "Just writing to let you know that <code>@{{username}}</code> ({{name}}) is now following you."
}

When adding a new document to your mail collection, pass in a template name with the data which will be injected:

  toUids: ['abc123'],
  template: {
    name: 'following',
    data: {
      username: 'ada',
      name: 'Ada Lovelace'
    }
  }

On the logical "if statement", it should work yes, however I'll check this myself too and make sure it is working.

from extensions.

NLegendre avatar NLegendre commented on August 29, 2024

That's perfect !
Thank you very much !

from extensions.

thebeingapp avatar thebeingapp commented on August 29, 2024

tried sending an attachment using the array field 'attachments' in template collection. But the email got delivered with the attachment. Does anyone know if the extension is supposed to work with an attachment in the template?

from extensions.

tylerreece22 avatar tylerreece22 commented on August 29, 2024

For some reason my emails still cant pick up the templates. I have configured just like above templates collection is created and i have added the object.

db.collection('templates').add({
    toUids: ['abc123'],
    template: {
        name: 'following',
        data: {
            username: 'ada',
            name: 'Ada Lovelace'
        }
    }
})

When I try to add the below to mail I the this error.
image

{
        to: '[email protected]',
        message: {
             subject: 'Hi there!'
        },
        template: {
            name: 'following'
        }
    }

SOLVED: It does not look for template.name in the object you create the template document with as the documentation mislead me to think. The plugin actually looks for a matching document id for your template (i.e. template: name: 'oA3SXV3q3hU8imLqbet3'}). I hope this saves someone else 3 hours of playing around.

from extensions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.