Teams AI Library Blog Series: Episode #1 – Setup A Teams AI Library-Based Application to Reason Over SharePoint Content with Azure AI Search


Introduction

This article is the product of discussions that occurred at a recent Microsoft 365 PnP Dev community call.

On the call. several discussions were asking to have content around setting up a Teams app. The Teams App should be able to use Generative AI (Ideally with the Teams AI library) that can reason over content in a SharePoint Document library.

Back in December, I built a little app from one of the Teams AI library samples to do just that. I had been thinking about authoring this article for a couple of months but thought that someone else would do it.

Anyway, I have not really found anyone who has put something out there quite like this. Yes, there are lots of articles about Teams AI and Copilot Studio but not quite like this one, so here it is.

The Teams AI library is a fascinating toolset and enables developers with relative ease to be able to create Teams-based Chatbots which integrate with Open AI or Azure Open AI Services to deliver solutions using Generative AI.

The nice thing about the Teams AI library is the way that you can build the prompts to deliver clever applications. Do not believe me? Check out the Twenty Questions sample.

Last year, one of the projects that I wanted to build, was to create a bot that can consume SharePoint content via Azure Open AI Services through Azure AI search. The problem was that when I came to look at this, no abstract or example referenced allowed you to use Azure AI Search with Teams AI library.

This article is part of a series of blog series which will describe how to get this all set up and show you how an extension to the library to be able to use Azure AI Search. As I started authoring this article, I realised that it would be quite overwhelming as one article, so I have split it up into a blog series.

To help consume this content there will be the following articles:

Let’s get into it.

Solution overview

The beautiful thing about the Teams AI Library is that it handles a lot of the complexities of chatbots for you.

For example, AI-powered chatbots work better if they have the history of the conversation included as part of the prompt. This way they are more natural to use, less annoying and behave in the way that you would expect.

Of course, the Teams AI Library has a mechanism for reasoning over content. It uses the Retrieval Augmentation Generation (RAG) pattern to take a user’s natural language prompt, extract the intent and pass that to a data source for extract of results and bringing those results back to the LLM for a natural language response to the user.

In Teams AI Library these are called data sources and there is an interface provided that you can implement.

However, the samples that I have seen implemented are for a local file system of files. Now, I want to be able to use the data source from an Azure AI Search for these queries. By doing this we can access content hosted in SharePoint, Azure Blob Storage and a whole lot more using third-party connectors.

So, I built this abstraction, the AzureAISearchDataSource which implements the DataSource interface and allows you to use Azure AI Search as the data source.

What is more, I have shared this library with you via my GitHub repository. This has the current implementation and will be updated as required.

In the rest of this post, I will explain the steps that are needed to build and deliver this solution. The solution includes the setup of:

  • SharePoint Document Library.
  • Azure AI Search
  • Azure AI Search Indexing
  • Building the Microsoft Teams application.

I will say that the landscape is moving quickly so where possible I have referred to Microsoft articles to help describe the steps. Hopefully, that way if something changes, you’ll still be able to continue setting up the solution.

However, if it is not clear please reach out to me.

I am assuming that you already have your SharePoint content setup that you wish to reason over, with your GPT model.

Next Steps

In our next post, we will start you on your journey by setting up the Azure AI infrastructure for your solution.

A way to manually kick a Azure Function Timer Trigger Function when its been deployed


Introduction

At iThink 365 we have been building a few products around the Microsoft 365 Employee Experience. These products need to refresh information about the employees and so this is done using Azure Functions as Timer Trigger functions.

Something like this

Last week, I was chatting with one of my team and I showed them how they could manually kick off the timer trigger function. They exclaimed, “Woah, I had no idea you could do that!” I asked some more of the team and they said the same thing. So, I hope you have not either.

One of the attributes on the Timer Trigger is the RunOnStartup flag and it is important and seen as one of the best practices of Azure Functions to make sure that these are switched off,. This ensures that you don’t get your Azure Function firing randomly.

However, when developers are working on these Timer Triggers you want the Timer Trigger to run as soon as you start debugging the code. Having the RunOnStartUp flag off is a pain and often they get left on so that the code runs on startup. We do not want that behaviour where the flag gets left on.

Another scenario that you want to kick off the Timer Trigger is when a new customer joins and you want their user estate to be processed as soon as they subscribe to your product.

So, we need to be able to kick off the Timer Trigger function somehow.

How do we manually kick off a Timer Trigger function?

Solution

Well, it turns out you can call the Azure Function with a special endpoint and it is this one.

Using the URL:

https://%5Byour azure function url]/admin/functions/[YourAzureFunctionTimerTriggerFunctionName]

For our timer job above it would be like this:

https://doyfunction.azurewebsites.net/admin/functions/RefreshNewStartersCachesFunction

You can kick off the Timer Job, you also need either the master key or the function key from your Azure Function.

This can be retrieved by:

  • Browse to the Azure Portal (https://portal.azure.com)
  • Find your Azure Function
  • Click on App Keys under Functions
  • Copy the master key

Once we have the Azure Function function/master key, we need to call the endpoint. To do that we:

  • Using Postman
  • Create a request
  • Change the HTTP verb from GET to POST
  • Use your URL for your Trigger Function
  • Add a new header called
    • x-functions-key
  • use the function or master key as the value.
  • Click Send
  • You will receive an Accepted 202 response back if the request was successful.

That is it your timer job will have started.

An example is here:

If you receive an HTTP 404, and you are using an Application Setting to define your Timer Trigger schedule then check you have a valid value for the Application Setting in your configuration.

Hope you find this useful!