0
votes

I'm working on an Azure Chatbot that will be connected to Facebook Messenger. The purpose of the bot is to look for the phrase of the day more or less. I currently have a url that returns the phrase of the day in plain text.

What I need the bot to do is for example:

User: "Hi, what is the phrase for today?"

The Bot will search the url and retrieve the plain text returned.

Bot: "The phrase for today is 'Don't Give Up!'"

I'm currently using QnA Maker for a knowledgebase, but it only works for static FAQs, not for pulling text from a website. Any help will be appreciated.

Thanks,

Axel

1
as far as i understand the qna maker i can't just use a plain text / string. the data has to be in a format it understands, see docs.microsoft.com/en-us/azure/cognitive-services/qnamaker/… can you control how the plain text looks? - weberik
i managed to create a bot/kb and let it parse a url with a tsv file containing my 'phrase of the day' test file. it works but the is no way to regulary(daily) refresh it. so i think there is no way to achieve this by using the qna maker alone. - weberik
Are you using Bot Builder SDK v4? What language are you coding the bot in? Please provide some code examples to show what you've tried so far. - Kyle Delaney
Hi all, thanks for your replies! Yes, I can control how the plain text looks. As of what language, I believe it's C#, I haven't actually tried any coding, since I was using QnA Maker to develop the bot (all from the QnA Website and Azure Portal) and didn't have an idea of where to start to get the functionality I wanted. Once I download the code and figure out how to work with publishing it to Azure I'll post what I try! - AxelSariel

1 Answers

1
votes

There's a couple of different ways you can go about this:

Programmatically Update Your QnA Knowledgebase

You'd need to create some kind of separate function (maybe using Azure Functions) outside of your bot that makes this API request every day.

curl -v -X PATCH "https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/knowledgebases/{kbId}"
-H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"

--data-ascii "{body}"

Body:

{
  "add": {
    "qnaList": [
      {
        "id": 0,
        "answer": "You can change the default message if you use the QnAMakerDialog. See this for details: https://docs.botframework.com/en-us/azure-bot-service/templates/qnamaker/#navtitle",
        "source": "Custom Editorial",
        "questions": [
          "How can I change the default message from QnA Maker?"
        ],
        "metadata": []
      },
[...]

Have the bot use an HTTP Request to get the Daily Phrase

Alternatively:

You would start by either intercepting messages that equal/contain:

"Hi, what is the phrase for today?"

Or, if you want the user's question to be a little more flexible, you could use LUIS to parse user input and return an intent.

Once you code that into your bot, just have the bot make a regular HTTP request to your website to the phrase, then send that to the user.


I can provide some code examples, if needed, but please provide a code sample of where in your bot you want this to occur. The URL for your phrase may also be helpful.