How to build a Secret Santa bot

Gift giving and the season of goodwill is something that naturally spreads into the workplace. According to OfficeTeam, 58% of staff plan to give gifts to colleagues but 48% feel pressured to overspend. 

As such, fun activities like Secret Santa gift exchanges create a fun and controlled way to allow everyone to join in the fun. And using a bot you can allow staff to sign up, gather gift ideas, match people up and send gift drop off instructions.

So, let’s show you how easy it is to build a Secret Santa bot for Workplace by Facebook.

Summary

  • Time to build: 1 hour
  • Skill level: Medium 

If you’re familiar with how the Secret Santa bot works then scroll down to the next section, otherwise we suggest taking a look at this short overview video that will show you the key screens and features that make up the Secret Santa bot. 

What you need

In order to build this bot you will need: 

  • A trial account or log in for The Bot Platform  
  • Admin status on your Workplace instance so you can connect the bot
  • A computer that, ideally, is running Chrome
  • An Integromat account
  • Some festive cheer. Because it’s the Holidays after all!  

Template instructions

Step 1: Creating an account

Ok, so the first thing we’re going to do is log into The Bot Platform. You can do this by clicking this link. Sign in using your TBP log in details. If you don’t have a TBP log in then you can sign up for a free trial using this link. Once you’ve done this you’ll need to verify your email. As we’re security conscious, we’ll use this as an opportunity to suggest all users enable 2FA too.

Step 2: Launching the template

Once you’ve verified your email you’ll be logged in to your dashboard. If you’re a new TBP user then you’ll see a blank dashboard like the image below. As you build bots they would appear here. 

Click on the blue “Create a new bot” button. 

You’ll then see our template dashboard screen. There are a number of different templates you can choose and each has a ‘Learn more’ button that clicks through to more information about that particular use case. 

For the purpose of this tutorial, we’re going to click on the ‘Secret Santa bot’ icon.

You’ll then be asked to name your bot. This is the name for your bot on The Bot Platform. We will come to what your staff see when they use the bot when we connect it to Workplace in step 4. 

Type in a name for your bot, for example “Office Secret Santa”, and click the blue ‘Save’ button. 

Congratulations - you have created your first bot! This isn’t live on Workplace yet, but you now have a template that you can start editing! 

On the dashboard screen you’ll see a description of the bot and an overview video. Clicking on the ? icon will open this Help Doc.

We’ll come back to the orange bar at the top that says “Connect to Workplace” in step 4.

Click on the blue “Customize your bot” button and you’ll be taken to the message menu.

The message menu contains all the messages that make up a given bot. For the Secret Santa template there are 9 messages that need to be edited as well as then setting up the randomized sorting feature by using Integromat.  

Step 3: Reviewing and editing the template

We’re going to start off with the Welcome Message. Click on the blue ‘edit’ button to open that particular message. 

The Welcome Message is the first message your staff will see when they start using the bot. It is made up of 1 GIF, 2 message parts and a button. If you wish to edit any of these messages then simply click into the text box and change the text or emojis. Equally, if you’d like to change the GIF then simply click the camera icon and select a different GIF from your computer - although try and avoid using GIFs that are larger than 3mb. 

In the Welcome message you’ll want to edit whether or not the Secret Santa is a department, office or store gift exchange. 

You’ll then want to change the text in the second message part that says when and where the Secret Santa is taking place. 

If you wish to click through the bot as if you were a user then you can do this by clicking on the text that says ‘Switch to Navigation’. This will make the blue bar change orange and will put you into Navigation mode which means you can click on the various messages to see how the bot is put together. This is a great way of easily seeing which messages you want to edit.

For example, clicking the ‘Sign me up’ button takes the user to a message called ‘Sign up’ which contains more details about the gift exchange such as the budget guidelines. It also includes something called a Q&A message where we’re asking staff for some gift ideas for their Secret Santa. 

To edit this message simply click the ‘Switch to Edit’ button, edit as necessary and click the blue save button.

After a user has entered some information about things they like, the next message they will see is called ‘Waiting time’. This message includes a GIF and 2 message parts. You’ll want to change the date mentioned in the second message part from ‘November 26th’ to whatever date you’re planning on sending out the follow up broadcast which matches people up. 

The next message you will need to edit is called ‘Buying for’. This message includes 1 GIF, 3 message parts and a button. Leave the message that says “You are buying for: <NAME GOES HERE> Their interests: <INTERESTS GO HERE>” - we’ll come back to this in the integromat section. 

You will need to edit the sections that contain the gift budget guidelines, the deadline for when the gift needs to be purchased and where the gift needs to be dropped off.  

Once you’ve made these changes click the blue ‘save’ button. 

The final message you’ll need to update is called ‘Gift dropped off confirmation’. This is the message that gets sent to staff once they click the button in the previous message to confirm they’ve dropped off their gift.  

Leave the first message part that says ‘Secret santa participants’ at the bottom. We’ll come back to this once we’ve connected our bot to Workplace.

Edit the second message that includes details on when and where the Secret Santa gift exchange will take place, or where gifts can be collected. Once you’ve done this, click the blue ‘Save’ button. 

Now we’re going to edit the ‘Get Started’ screen. On the left hand panel scroll down and click on ‘Get started message’ under ‘Settings’.

You’ll see the following screen. Most staff interact with a bot for the first time via a broadcast message which means they won’t see this message, but for anyone that finds it organically they will see this text. 

Update to the correct day and edit the text as you wish and then click the blue ‘Save’ button. Then click the ‘Messages’ button in the left hand navigation menu.

Step 4: Connecting to Workplace

OK awesome, your Secret Santa bot is pretty much finished! We’re now going to connect it to Workplace. 

Click on the ‘Messages’ button in the side navigation menu and then click on the ‘Connect to Workplace’ button in the orange bar.

You’ll see a screen that asks you to connect your Workplace account. Click the blue ‘I am a Workplace Admin’ button. If you’re not an admin, you’ll need to involve someone from your company who is in order to add the bot to your Workplace instance.

Ensure all the boxes are ticked on the next screen giving your bot various permissions and then click the red ‘Next’ button at the bottom. 

You’ll then be redirected to Workplace’s website and asked which Workplace account you would like to use. Click on the correct one. Note, you may only have one account to choose from here unless you have a test or sandbox instance that you have an account for too.

Now we have the ability to customise how the bot will look to your staff and which groups on Workplace it has access to. 

We’ll start off with the bot name, description and icon. 

Click the ‘Customise’ button and enter the name you’d like your bot to appear as in the ‘Integration name’ section. 

Then update the description of the integration. Change it to something short and sweet like “Get involved in our company Secret Santa!”

You can change the logo/icon of the bot too. For example, if you wanted the icon to be your company logo or any other icon - click the ‘Update logo’ button, add one from your computer and resize as appropriate. 

Then click the blue ‘Save button’.

Now we need to select which groups have access to the bot. You can change this whenever you want, so our suggestion is to start off by connecting it to a test group or Workplace group that you and other Workplace admins or people you might work on the bot with are in. 

For example, you may have created a group on Workplace called “bot testing” or “Secret Santa bot” that only a few people are a member of. 

Click the ‘Specific groups’ button and start typing the name of the group or groups you want to connect the bot to. This means only people in those groups will be able to find and access the bot. 

Once you’re ready to launch it to the whole company you can add more groups or change the settings to ‘All groups’. 

Once you’ve added the correct groups, click the blue ‘Add to Workplace’ button. 

Wait a few seconds and then you’ll be redirected back to The Bot Platform and you should now see a green bar at the top of your dashboard that says “Success! Your bot has been successfully connected to Workplace”. 

Your bot is now connected to Workplace! Easy, right?


Step 5: Connecting to Groups

Now our bot is connected to Workplace, we can add in the functionality such as posting to groups or sending broadcasts. 

Click on the ‘Messages’ button in the left hand navigation menu. 

Scroll down until you find the ‘Gift dropped off confirmation’ and click on the blue ‘Edit’ button. 

We’re now going to add the Post to Group feature into the bot which tells the Secret Santa organizers when staff have dropped their gifts off. 

You can change the group that it posts to whenever you want, so if you’re not ready to post it to a public group then you can connect it to a test group you’ve created too. 

In the top message, click on the text that says ‘Secret Santa participants’. 

You’ll see a dark blue screen. In the text box start typing the name of the group you want the bot to post this information. If you can’t see the group you want the bot to post to then click the ‘Refresh groups’ button. 

Once your Group is selected, click the blue ‘Save’ button. 

You will now be redirected back to the message menu and see an orange bar with a button that says “Push the changes live”. Because your bot is now connected to Workplace, changes that you make to your bot will only appear to users on Workplace when you click this button. 

Click the ‘Push the changes live’ button in the orange bar. 


Step 6: Adding the staff randomizing and matching using Integromat

Now we’re going to add in the Integromat section that randomly matches up your staff with each other. 

In Integromat set up a webhook and then locate the message in your bot called ‘waiting time’. Click on the ‘Webhook’ button in the right hand message builder options. This will add a message part to your bot that says ‘Click to configure’. 

Move this message to the top by hovering next to your other message parts and moving them down until the webhook message is at the top, as per the image below.

Now click on the webhook message where it says ‘Click to configure’ and paste in the URL of your webhook from Integromat into the HTTP Post screen and then click on the blue ‘save’ button. 

Click the save button at the bottom of your ‘Waiting time’ message and then click the ‘push changes live’ button in the orange bar at the top of the screen. 

Now we’ll need to run through the bot to pull some data into the webhook. 

Click the name of your bot in the top header of the screen next to our The Bot Platform logo in the top left corner. This will open your bot in Workplace and you’ll see a screen like the one below. 

Click the ‘Get Started’ button and go through the flow until you’ve entered your gift preferences and been sent the ‘Waiting time’ message that contains your webhook. 

You should now see that it has pulled through your name and the interests attribute. We now need to store these values in a spreadsheet. 

Set up a Google spreadsheet with the columns; person’s name, interests, FBID and person buying for. 

Now we need to get the data from the webhook to the spreadsheet. Add a create row in Google sheets module after your webhook module in Integromat.  

Select your Google account and select your new spreadsheet and the sheet number from the drop down. Add in your firstname and lastname pulled through from the webhook in the secret santa name field. Add your interests in the interests column and add the FBID into the FBID column as shown below.

Run your integromat and check that the data is now pulling through into your spreadsheet. That is the first part of your flow set up. 

Now we need to set up the part of the flow that assigns each Santa their person to buy for and lets the Santa know, along with any interests that person may have listed. 

To do this we’ll add a new webhook to the message called ‘Buying for’. 

In Integromat, create a new scenario and start off with the webhook module. Add a new webhook and copy this into the webhook message within the message called ‘Buying for’ in the same way we added a webhook previously. Paste in the webhook URL and then click save. 

Then hover to the left of each of the other messages and move the webhook up to be where the message part is that says “You are buying for: <NAME GOES HERE> Their interests: <INTERESTS GO HERE>” Then delete that message part by clicking the cross icon in the corner of the message so it’s been replaced by your new webhook message part.

Then click save again on the ‘Buying for’ message before pushing the changes live. 

We now need to pull back the names of everyone who has signed up to take part so we can check the number and add in the person they will be buying for. Add in a search rows in google sheets module. Find your spreadsheet and the sheet in the drop down fields. Now we want to find every row where that person’s name exists. As seen below. 

Now we need to add in a router so we only assign the person to buy for the first time this flow is run. On one connection to the router, we want to add a filter to make sure that the person to buy for column has not been updated yet. 

Since we can assume that different people will sign up at different times, the order of people listed in the spreadsheet will be random.  This means that we can just move each person down one row to be the person they are buying for.  So we need to create a new variable that uses takes the row number in the spreadsheet of the person using the bot and increments it by one. 

So we create a variable that uses row number from the google search and adds one to it. 

We can now use this to get the name of the person in the next cell down to add to our person buying for column. You want to add in a google sheet, get a cell module. Link it to your spreadsheet and we want to look at the person listed in the cell below. This would look as follows:

Now this is where we need to add another router as the person at the end of list, will not have anyone from the row below to buy for. So add in another router. You want to add two routes off; one if there is a person in the row below and one if there isn’t. E.g. one if the cell look up can find someone and another if it can’t. 

On the ‘If Santa Exists’ flow, we want to add a google sheets update a row module. Set up your spreadsheet in the drop down and in the row number field, you want to use your new row number variable from above and you want to update the person buying for column, with the value pulled from your original google sheets look up. 

Now we have added the person you will be buying for, let’s look it all up. Add in a search row in google sheets module. You want to look up the firstname and lastname of the person submitting the webhook in column A - Person’s name. This will return the name of the person you will be buying for which we will use in the final webhook response. 

Then we need to add another search row in google sheets, to look up the interest of the person you will be buying for, pulled from the previous step as shown below. 

The final step on this branch is to add a webhook response. 

We want to respond with the person you will be buying for and the interests. 

The response is as follows:

Now we need to go back and add in instructions for the very last person on the list to ensure they get a person to buy for. 

Add a filter on this branch that only kicks in when there is no person in the row below. 

First we need to set a variable that ensures the bot jumps back to the first person on the list when looking for someone to buy for. 

Now we want to update the person buying for row using the new variable and a google sheets update row. 

This is then followed by the last three steps from the previous branch.  Search row to find the person you are buying for, search row to find the interests of the person you are buying for and finally the webhook response. 

The final step of setting up Integromat is to go right back to the first router and add in the option for once the spreadsheet and person buying for has already been updated.  

This just needs the same three last steps from above. Search row to find the person you are buying for, search row to find the interests of the person you are buying for and finally the webhook response. 

When completed, your flow should look like this:

Now just turn on the scenarios and your Secret Santa bot is now ready to use. Click on the name of the bot with the Workplace icon next to it in the top left of the dashboard and your bot will open in a new tab on your computer. Or, search for the name of your bot on Workplace Chat on your phone.

As we ran some data through the bot earlier you might need to delete it in order to see the Get Started screen again. Otherwise click on the button in the persistent menu to restart the flow from the beginning.

Step 7: Sending broadcasts

We’re now going to set up the broadcasts. This allows you to send messages out to your staff inviting them to take part in the Secret Santa.  

You can send broadcasts to all staff, members of specific Workplace groups or custom segments of staff. 

Click on the ‘Broadcasts’ button in the side navigation. You’ll see a screen like the one below. Click on the blue button that says “Create a broadcast”.  

In the section that says ‘Select the message to schedule’ start typing and then select ‘Welcome Message’. 

In the choose a target for your broadcast select ‘Workplace Groups’ and in the ‘Send to group(s)’ section start typing the name of the test group you set up earlier, or a group that has people in that you want to test or use the bot. 

If you don’t see the group when you start typing then click the ‘Refresh groups’ button and try again. 

Scroll down the page and click the ‘Date / time’ section. This will bring up a calendar. Select the day and time you want to send the broadcast. Or, if you want to send it now, click the ‘Set to now’ button. Then press the blue ‘Schedule’ button to save the broadcast. 

You’ll then be redirected to your Broadcasts menu where you can edit, test and delete scheduled broadcasts. 

Once you’re happy that your bot is working the way you want it to work then you can create a new broadcast to the relevant Workplace group or segment of staff by following the same process above. 

You’ll then want to follow the same process for the message called ‘Buying for’ once you’re ready to tell people who they are buying gifts for. 

And that’s it. You’ve now successfully built a bot that allows staff to sign up to take part in a Secret Santa gift exchange, collects data on their gift preferences, randomly matches staff members up and provides drop off instructions.

Congratulations! 

Did this answer your question?