问题
When a new user is added to Firebase, I would like to send myself an email with all of the data associated with that user. So if I have a /contacts path and a /projects path, I'd like to include the data from both paths when a child is added to the /contacts path.
I've looked at Zapier using Mailgun, but can't figure out how to accomplish this.
If Zapier won't work, is this something can be accomplished with the firebase-util?
Tree for my-firebase-app.firebaseio.com/contacts
-contacts
--anonymous:-JttGEelQDsVtZ55n3d2
---name: john doe
---address: 100 Main St.
// . . .
Tree for my-firebase-app.firebaseio.com/projects:
-projects
--anonymous:-JttGEelQDsVtZ55n3d2
---projectName: "My first project"
---projectDate: July 27, 2015
// . . .
UPDATED:
In response to the comment below, here is some additional info:
I have tried the following steps in Zapier:
- Selected
Add child record
under Firebase - Selected
Send email
under Mailgun - Set path to data:
/contacts
- In the email body section, I inserted
Raw Json Data
The email only contains the Json data located in /contacts
. It does not contain any of the data located in /projects
.
回答1:
This can pretty easily be accomplished with Zapier.
You have define a node that will trigger Zapier to read your data. Then set Zapier to 'observe' that trigger node. You define the fields in the node and then in Zapier, map them to variables that are used to fill in the email.
In general use something like this (ObjC)
Firebase *zapierRef = [myRootRef childByAppendingPath:@"zapier_queue/out"];
Then, compile the data you want Zapier to read, I am using a dictionary in this example
NSDictionary *dict = @{
@"name", @"john doe",
@"address", @"100 main street",
@"anonymous: @"-JttGEelQDsVtZ55n3d2",
@"projectName": @"My first project",
@"projectDate": @"July 27, 2015"
}
then write that out as a child node in the Zapier node
Firebase *zapChildRef = [zapierRef childByAppendingPath@"data"]
[zapChildRef setValue:dict];
Zapier will be triggered by the write to this node, read the data, format it into the email and then once completed with automatically remove the node and wait for the next piece of data.
来源:https://stackoverflow.com/questions/31663720/how-to-send-email-with-all-information-associated-with-user-id-in-firebase