0

I want to implement auto complete search for bot..for example bot should get responses as auto complete options from Mongo Database. Can any one suggest how to do this without Azure Search?

I have tried implementing like this but in my case i want to get the tags from Database.

May i know what are the available options to do this?

praveen
  • 1
  • 3
  • Welcome to Stack Overflow. Please note that because this is no free code writing service it is necessary to show either what you have tried so far and where you got stuck or errors (by showing your code) or at least to show what you have researched and the effort you made. Otherwise it is just asking us to do all the work for you. Reading [How to Ask](https://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) might help you to improve your question. Good luck! – Eduardo Baitello Aug 13 '19 at 12:44
  • What SDK are you using - Node or C#? – tdurnford Aug 15 '19 at 18:17
  • @tdurnford I'm using C# – praveen Aug 16 '19 at 07:40
  • Marking the solution as accepted serves the greater Stack Overflow community and anyone with a similar question. If you feel my answer was sufficient, please "accept" it. If not, let me know how else I can help! – tdurnford Sep 05 '19 at 15:14

1 Answers1

1

When you send a message from the bot, you can add the autocomplete options to the activity's channel data. Then in Web Chat, you can use a custom store middleware to retrieve the options and update the JQuery Auto complete widget.

Bot Framework SDK v4 (C#)

var reply = turnContext.Activity.CreateReply();
reply.Text = "Hello, World!";
reply.ChannelData = JObject.FromObject( new {
    autocompleteOptions = new List<string>() { "Option 1", "Option 2", "Option 3" }
});
await turnContext.SendActivityAsync(reply);

Web Chat v4

const store = createStore(
  {},
  ({ dispatch }) => next => action => {
    if (action.type === 'DIRECT_LINE/INCOMING_ACTIVITY') {
      const { payload: { activity: { channelData: { autcompleteOptions } = {}}}} = action;
      if (autcompleteOptions) {
        // Update JQuery Autcomplete Widget with `autocompleteOptions`
      }
    }
    return next(action);
  }
);

For more details take a look at the Incoming Event Web Chat Sample and this Stack Overflow answer.

Hope this helps!

tdurnford
  • 3,632
  • 2
  • 6
  • 15