At some point of your life you will need a RSVP system for some kind of event, your niver for example. In my case I was going to marry and I needed presence confirmation, since the place charged by guest. RSVP is pretty simple right, probably there is a lot of online services at a moderate price covering what I need.
Well, I was wrong. I tried a lot of them and disliked every single one. After my bad experience I admitted to myself that I needed to create one. Nothing too fancy, just send some e-mails and confirm the presence. So I putted some thought and after finish it I really liked the result. I got a lot of positive feedback about it, most of the guests saying that was really very simple to use and no problems with it. Now that the marriage is finished and I got more time in my hands I will share how I create it with my fellow readers.
Just to be clear, these were my requirements for the RSVP, so there we go:
- The confirmation will be done in one single click
- No forms to fill or logins
- Through e-mail
- A redirect to a semi-fancy page saying to the guest that everything is done
Super simple, one click done. Keep in mind that my marriage was for 40 guests at max, so I didn't needed a super robust app.
How it will work ?
We will have a list of invites into the database containing e-mail, name, a boolean indicating if the invite was confirmed or not and a hash identifying the invite. This hash will be used to generate a dynamic url which will be sent to the guests. When they click in the link our system will pick up the hash in the url and use it to get the correct invite and confirm it.
We will use a hash and not a simple ID because we don't want people starting to try out random urls and eventually get a confirmation for a stranger. Now let's begin !
You will see a lot of process.env.VARIABLES through the post, so I recommend you to take a look in the package dotenv
I'm not transpiling this project with Babel because I wanted the simplest setup possible, so you will only see some basic ES6 features here.
I will use Postgres here, the structure of the Invite will be:
Since we are using a database, the first thing is connect to it. Let's create a file called
connection.js to do it:
Now we can connect to it, but we need to populate and to acomplish it we need to add some
database operations with our library of choice (
Sequelize.js), so this will be our next step.
This will be our operations on the
create and a fetch of all pending invites is all we need here.
Now that we have our operations and connections let's populate our database with the invites in our
ID() function will generate the hash that we talked about previously to indentify the invite.
To send e-mails you will need external service, I used the Sendgrid app, so I recommend you to do the same if
you are following this post (they are not paying me btw), but in the end it's your choice.
Let's create our file
Pretty straight forward, let's just create an e-mail and send it through the api. The button will take the guest to the dynamic url confirming the presence but before we send it let's create our web server to receive this requests.
Of course that we will use
express as web server, a lot of love indeed.
We created a dynamic url, that will receive the path after
/confirm as the
url parameter, and send it to our
confirm() function, that will update the invite with the identifier as
confirmed: true and redirect to a confirmation
page of your preference. If the identifier doesn't exist it it will redirect to a 404 page.
Up and running
Ok, now let's bring our pieces together running the commands:
Starting the server:
Populating our database:
Sending the e-mails:
Now, let's just wait to our guests confirm their invites ! Party hard my friend, see you soon :)