In this tutorial, learn how to create a Workplace bot that adds items to a Sharepoint list on an existing Sharepoint site

Digital tools in the workplace are booming, and organizations are looking for solutions to connect their tech and be more productive at work. Workplace and customized partner integrations, like The Bot Platform and Sharepoint, can help you get the most out of your digital tools.

In this tutorial, we will show you how to create a bot that adds items to a Sharepoint list on an existing Sharepoint site. This step-by-step guide can be used to add items to any Sharepoint list, but for this example, we have created a to-do list that we will be adding tasks to.

Knowledge Required: Intermediate

You need a good working knowledge of how to create a bot and basic Sharepoint knowledge.

What you will need

Step 1: Create a bot

First, you need to create a bot by following the instructions on The Bot Platform blog on how to set up your bot on Workplace. For this tutorial, you should start with a blank template and create a new integration on your workplace account.

After you’ve named your bot, you will be taken to the dashboard. Click on the “Edit your welcome message” button to start building your bot. Once all your messages are built, click the “Connect to Workplace” button to start setting up your integration.

NOTE: You must be a system administrator on your Workplace instance for this step.

You will then be taken to a setup wizard that will give you step by step instructions to help you connect to Workplace. When these steps are complete, your bot will now be integrated into your Workplace page.

Step 2: Create the integration

Now that we have our blank bot set up and connected to Workplace, we can start creating the integrations we need.

On our bot welcome message, we want to give the user the option to add an item to the to-do list. Set up a text message within your bot saying, “Would you like to add an item to the to-do list?” and add buttons for yes and no.

Go into the settings on the yes button and choose the setting, ‘send message’ and set up a new message called ‘Action to add.’

Step 3: Create a Sharepoint list

For this example, you need to have a Sharepoint site set up already. Go into your Sharepoint site and add a new list called “To-Do.” You can do this by clicking the “+ New” option on the top left-hand side of the page.

For success, you need to add the following columns to your new list: Title, person responsible, and date required. Once complete, our Sharepoint list is set up and ready to start accepting information.

Step 4: Build your “Action to Add” message

Next, we need to set up the messages on The Bot Platform to gather all the information required for our to-do list.

Go into the new message we previously created called ‘Action to Add.’ This message will be where we collect our to do action to add to our list, and using a Q&A type message can ask the user for the action.

Next, we need to set up the messages on The Bot Platform to gather all the information required for our to-do list.

Go into the new message we previously created called ‘Action to Add.’ This message will be where we collect our to do action to add to our list, and using a Q&A type message can ask the user for the action.

Under message settings, select the save attribute and send the user a message option. You will want to save this as an attribute under the name ‘Action,’ and you then want to create a new message to send to them called, ‘Person Responsible’.

Save this setting and part of your bot, then return to the message list.

Step 5: Build your “Person Responsible” message

Now, let’s go in and create the ‘Person Responsible’ message.

This message will be where we collect the name of the person responsible for the task. Again, you want to use a Q&A type message to ask the user for this data.

Under message settings, select the save attribute and send the user a message option. You will want to save this as an attribute under the name ‘Person Responsible’ and create a new message to send them called ‘Date Required’.

Save this and go into the new message ‘Date Required.’

Step 6: Build your “Date Required” message

Repeat the process in steps five and six above for creating your message using a Q&A type response. This time we can specify that the date required is given in the format of a date.

Save the user response as a new attribute ‘Date required’ and send them a new message called ‘Thanks’. You will also need to set up an error message if they do not use the date format in this reply.

Step 7: Set up the error message

Create an error message and add a text response that says ‘Sorry, but you have input the date in the wrong format. It should be dd/mm/yy,’ and save this message.

Now create your ‘Thanks’ message. Add a text box at the top that says ‘Your action has now been added to the To-Do list.’

Next, we need to add in the webhook and set up the remaining parts of the workflow. Add in a content type webhook into your newly created bot messages. Go back into the first Q&A message we created, ‘Action to Add.’

Add in the content type webhook into your message. Click on the settings option, and you will be asked for a URL.

Step 8: Set up the webhook

Head over to Zapier and create an account.

Now we need to add a new zap. Search for a webhook trigger on Zapier, click on the webhook icon, and select ‘Catch Hook’ as your option.

You will then be given a webhook URL needed. Copy this URL to your clipboard and go back to The Bot Platform. Click on the settings icon next to your webhook and paste in the URL you just copied from Zapier.

You now have your webhook set up!

Step 9: Test the webhook

Now we need to test our webhook so we can set up the rest of the zap.

Go back to the dashboard for your bot and click ‘Test’ next to your welcome message. Test your bot and make sure the message flow is as expected.

Once you reach the final message ‘Your action has now been added to the To-Do list,’ head back over to Zapier. Click on ‘Test this step’ and you should be able to see the hook data you have just submitted through your bot.

Select your most recent hook and select continue.

Step 10: Add an action step

We now need to add an action step. Select ‘Office 365’ and on the next screen, select ‘send an email.’ Hit next, and you will need to connect your Office 365 account.

We suggest you set up a generic email address that you can use with all your bot integrations. Set one up before the next step and log in to that account now.

Step 11: Create the email template

Now we need to set up the email template. In the ‘To’ email field, you will want to add the generic email for bot integration you created in the step above. In the CC line, we want to add the email address of the person responsible for completing the action. How to do this:

  • Clicking on the plus icon at the right of the box
  • Selecting the ‘Catch Hook’ and clicking on the field ‘Person Responsible’ from that list

That will automatically pull the information through from your bot and the person responsible will get notified of the new action.

In the subject field, click the plus icon then click on catch hook, and look for the attribute called “Action to Add.” For the body field of the email, you will want to do the same as above, but this time select the “Date required” field.

The first part of your integration is now set up and ready to test. Hit the test button to ensure it has worked.

Step 12: Connect to Microsoft Flow

Part one is complete! You now need to login to Microsoft Flow using the email you set up for your bot integrations and create a new flow from scratch.

For the first part of your integration select, ‘When a new email arrives’.

You need to expand this step so you can see the advanced options. In your “From’ field, add in the email address for your bot platform integrations. This means that only emails sent to this address by this address will trigger the flow. Save this step.

Step 13: Connecting content to Sharepoint list

Now we need to get the email content into our Sharepoint list.

Search for Sharepoint in the action section and then select ‘Create item.’ You will need to connect your Sharepoint account, so make sure you have allowed your newly created bot integration email address to access the Sharepoint site with your list on it.

Once connected, select your Sharepoint site from the drop-down. Select your ‘To-Do’ list from the list drop down.

  • Match the ‘Action to Add’ field to the Subject field from your email
  • Match the ‘Person Responsible’ field to the email CC
  • Match the ‘Date Required’ field with the email body

Save and test the flow. You should now see you have a new item in your Sharepoint list!

A new world on Workplace

Using custom integrations like the one in this tutorial will help extend the functionality of your Workplace instance.

With Sharepoint integrations like the one above, your enterprise software can integrate with bots on Work Chat to do things like adding tasks to a shared project management list, creating a list of things to do before your event, creating a list of useful documents or links, or creating an FAQ library.

To learn more about custom integrations and more bot “how to’s,” head over to our help center for more information or drop us an email below.

Want To Learn More?

Let’s talk about how your business or organization can benefit from bots on Workplace by Facebook and Messenger.

Get in touch with our team