Reputation: 33
I currently have a fully functioning Virtual Assistant Template-based chatbot with a skill attached to it. My goal is for the skill to work as a search function that can find resources in a CosmosDB and pull them back for the user to use. After doing some research I believe the best way to do this would be to use Azure search to retrieve said info. From what I've seen in the Virtual Assistant Template documentation integration with Azure Search should definitely be possible... I just haven't found any examples or tutorials on how to do so. If anyone knows how to create an azure search resource and integrate it into a bot, or knows of a resource that tells you how to do so, please let me know!
Upvotes: 0
Views: 442
Reputation: 1
I want to do a similar search (only in AzureBlob instead of Cosmos DB). I am using sdk v4 for my bot framework and Visual Studio 2019. I'm trying to call the service through the code below:
public ISearchIndexClient CreateSearchIndexClient()
{
string searchServiceName = "MySearchServiceName";
string queryApiKey = "MySearchServiceKey";
string indexName = "MyIndexName";
SearchIndexClient indexClient = new SearchIndexClient(searchServiceName, indexName, new SearchCredentials(queryApiKey));
return indexClient;
}
public async Task StartAsync(ITurnContext turnContext, string searchText){
ISearchIndexClient infoClient = CreateSearchIndexClient();
string indexname = infoClient.IndexName;
DocumentSearchResult<Document> results = infoClient.Documents.Search(searchText);
await turnContext.SendActivityAsync(MessageFactory.Text($"Here should be the results: {results} \n...and then my index: {indexname}."));
}
It runs without errors, so one could use it. But it never shows the message at StartAsync. If anyone sees what I am missing, thank u in advance.
Upvotes: 0
Reputation: 569
For your scenario, an outline of what to do is:
There isn't an end to end tutorial about integrating with a bot, but here is an Azure search tutorial that shows an complete scenario of crawling through a SQL database and then searching using full-text search. https://learn.microsoft.com/en-us/azure/search/search-indexer-tutorial
You should be able to follow most of the guidance there, except replace the parts about SQL indexer with details from Cosmos DB indexer in the link above.
Upvotes: 2