Skip to main content

Add Bot to Microsoft Teams

info

While we develop our own integration with Microsoft Teams, it's possible to integrate your bot using Zapier. As at the time of writing, Zapier offers a free 14 day trial. Mottle is in no way associated with Zapier, nor do we benefit financially from it. Use at your own risk.

caution

You must add a filter condition, otherwise you'll get into an endless loop of your bot talking to itself. See step 11 for details.

You can easily have your bot respond to messages sent to a Microsoft Teams channel by creating a Zapier integration.

  1. Create or choose a suitable Microsoft Teams channel before continuing.

  2. Install the Zapier App for Microsoft Teams.

  3. Once the app is installed, search for it again on your Microsoft Teams Apps Page and then add it to your team/channel.

When prompted on the next page, select the correct team/channel.

You're now ready to create the Zapier integration.

  1. Sign in to Zapier and click Create Zap:
  1. For Trigger, select Microsoft Teams and for Event select New Channel Message:

  2. Click Continue and Sign in to your Microsoft Teams account to connect it.

  3. Select the Team and Channel you wish to use.

  4. Click Continue.

  5. Test the integration by posting a message in your Teams channel and then click Test trigger. Find your message in Zapier. (You need a message posted by a real human – not by the Zapier bot – as this is important for later steps.) Click on Load more to find and select the message you sent.

  1. When set up correctly, click Continue.

  2. We need to filter out any messages posted by bots, otherwise we'll get trapped in an endless loop of our bot talking to itself. Therefore, select Filter as the next step:

  1. Select: Only continue if... 1. From User User Identity Type > Text (Exactly matches) > aadUser.

If you receive this warning when you test your filter, it means you selected an Application message back in step 9. Go back and fix.

Once it's working, it should look like so:

  1. Click Continue.

  2. For Action, select Webhooks by Zapier:

  1. For Event choose POST:
  1. Click Continue.

  2. For URL enter https://api.mottle.com/connect?bot=YOUR_BOT_ID – being careful to substitute YOUR_BOT_ID for your bot ID. Your bot ID can be found on the Publish / API Page.

  3. For Payload Type select JSON.

  4. For Data, we need to add two rows:

    • secret – This should be your bot's secret key. Again, you can find this on the Publish / API Page.

    • question – Click on the field to select a dynamic variable. Select the Microsoft Teams variable that starts with "Message Content:". It should say something like Message Content: \{whatever you typed\}.

    It should look something like this:

  5. The rest of the options can be left as is. Click Continue.

  6. Click Test Action to test the connection to Mottle. If you've done everything correctly, you will see something like the following:

  1. We're not done, so don't Publish your Zap just yet. We need to send your bot's answer back to Microsoft Teams.

  2. Click on the plus icon at the bottom of the screen:

  1. Select Microsoft Teams again, and for the Event Type select Send Channel Message:
  1. Click Continue.

  2. Ensure the same Microsoft Teams account is selected. Click Continue again.

  3. Pick the same team & channel as before.

  4. For Message Text Format, select Plain and for Message Text click the text box, and then select the dynamic variable: 3. POST in Webhooks by Zapier > 3. Answer {the answer from before...}

  5. Click Continue.

  6. Click Test action. If you now head back to your Teams channel and you should find a test response.

  7. Click Publish Zap > Publish & Turn On to activate your bot.

  8. Once activated, try sending your Teams channel a message. In a few seconds you should receive a message back from your bot.

  9. Congratulations! You've now linked your bot to a Microsoft Teams channel!

tip

Anecdotally, the Microsoft Teams integration is a little slow. It's jarring, as a user, when you don't get immediate feedback after submitting a question. You could modify the recipe above to send back a "Thinking ..." message before sending the user's question off to Mottle.

info

Unfortunately with Zapier integration for Microsoft Teams it's not possible to customize the name or icon of your bot. 😔 We'll try to address in the future.

info

Since Zapier Webhook requests are limited to 30 seconds, you may experience occasional timeouts, particularly when the OpenAI API is under stress (OpenAI status page). Unfortunately there is no way to send this information back to the user – the query will just fail silently. We will try to address this issue when we build our own Microsoft Teams integration.