This contact form
use Aiflo as a backend. The code is realy simple just a few lines of Aiflo code. It collects the input form data and store it in firestore. // The highligted parts are comments explaining what happens and not part of the code as JSON do not allow comments.
[
// This node handles the external inputs
{
"type":"inputs", "then":[
{
// Sends { "name": "name entered" } to node 'message'
"target": "message", "value":"name", "name":"name",
// Validates that a string input of max length 50 is received
"validate":{ "maxLength":50, "required":true, "ofType":"text" }
},
{
// Sends { "email": "email entered" } to node 'message'
"target": "message", "value":"email", "name":"email",
"validate":{ "maxLength":50, "required":true, "ofType":"email" }
},
{
// Sends { "message": "message entered"} to node 'message'
"target": "message", "value":"message", "name":"message",
"validate": { "maxLength":200, "required":true, "ofType":"text" }
}
]},
// This node assembles input as an object
{
"name":"message", "type":"object", "then": [
{ "target": "message_store", "name":"__document" }
]},
// The name of the collection in firestore
{
"type":"text", "value":"aiflo-messages", "then":[
{ "target": "message_store", "name":"__collection" }
]},
// Generates an UUID, ie 43efee2f-3453-4876-b694-a06f975b7eee
{
"type":"uuid", "then":[
{ "target": "message_store", "name":"__documentID" }
]},
// The firestore operation in this case 'set'
{
"type":"text", "value":"set", "then":[
{ "target": "message_store", "name":"__operation" }
]},
// This node stores the object in firestore
{
"name":"message_store", "type":"firestore", "then":[
{ "target": "application/json", "type":"response" }
]},
// Response
{ "name": "application/json", "type": "response" }
]