【问题标题】:Setting up 'Trigger Email' Firebase Extension设置“触发电子邮件”Firebase 扩展
【发布时间】:2021-05-23 14:15:42
【问题描述】:

我最近了解了 Firebase 和云功能,并且能够使用它们开发简单的应用程序。

我现在想扩展我的知识,并在 Trigger Email Extension 上苦苦挣扎。

在我的 firebase 上的特定事件中,我想以自定义格式向用户发送一封电子邮件,但我现在什至无法激活扩展程序。 有人可以举例说明图片中标记的这些字段吗?

【问题讨论】:

    标签: firebase google-cloud-functions firebase-extensions


    【解决方案1】:

    我也有这个问题,但是已经解决了。这是你的答案:

    “电子邮件文档集合”是将被读取以触发电子邮件的集合。除非您已经有一个名为 mail 的集合,否则我建议您保留名为“mail”的名称。

    “用户集合(可选)”是指您希望与用户身份验证系统一起使用的集合(如果有)。我还没有这个具体的用例,但我想一旦你了解了触发电子邮件的运作方式,它应该是不言自明的。

    “模板集合(可选)”对于您可以使用的模板很有帮助,handlebar.js 会自动为每个用户输入特定信息。 (例如<p>Hello, {{first_name}}</p> 等)与前面提到的集合类似,您可以随意命名。

    如何创建一个模板(我还没有真正实现它,所以对它持保留态度): 在您的模板集合中,您希望使用一个容易记住的 ID 来命名每个文档。 Firebase 给出了例子:

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

    ...指定一个好的 ID 将是 following。如您所见,文档的结构应该与您发送的任何其他电子邮件一样。

    这是在 javascript 中使用上述模板的示例:

    firestore()
      .collection("mail")
        .add({
          toUids: ["abc123"], // This relates to the Users Collection
          template: {
            name: "following", // Specify the template
            // Specify the information for the Handlebars
            // which can also be pulled from your users (toUids)
            // if you have the data stored in a user collection.
            // Of course that gets more into the world of a user auth system.
            data: {
              username: "ada",
              name: "Ada Lovelace",
              imagePath: "https://path-to-file/image-name.jpg"
            },
          },
        })
    

    我希望这会有所帮助。如果您在进行此设置时遇到问题,请告诉我。

    【讨论】:

      猜你喜欢
      • 2022-11-20
      • 2022-11-20
      • 2021-06-21
      • 2020-11-08
      • 2020-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-01
      相关资源
      最近更新 更多