wechaty / docusaurus

Wechaty Official Website for Documentations, Powered by Docusaurus.
https://wechaty.js.org/docs/
Other
112 stars 344 forks source link

FAQ bot for the docs #419

Open dcsan opened 5 years ago

dcsan commented 5 years ago

I made a basic FAQ chatbot, so we can ask / answer questions from wechat groups. However the first version is very basic, and it would be great to get some feedback on how to improve this bot, and also if anyone would like to contribute some features too!

This can be a very useful type of bot for "knowledge management" inside WeChat.

How it works now / commands

/faq help

to show list of commands

/faq fetch

bot will scrape that page and create individual FAQs in local mongoDB

/faq xxx query

Any query with /faq xxx will look for matching FAQs to xxx currently we just do basic keyword search inside the titles of each FAQ we will show multiple FAQs

/faq list

will show a numbered list of all FAQs

/faq 2

will show details for FAQ number 2

dcsan commented 5 years ago

I will add the bot to wechaty dev group for testing. Please let me know your ideas to improve it.

dcsan commented 5 years ago

source for FAQs

for now I just added FAQs to one new page, to make it easier to parse. I think it would be better to get a list of pages that are updated by chatie team and I will scrape those instead. eg: https://github.com/Chatie/docs/blob/master/root/faq.md

and perhaps the API docs too? eg this whole directory: https://raw.githubusercontent.com/Chatie/docs/master/root/api/friendship.md

That would mean adding maybe some tree for the hierarchy of the FAQ items

and the reader may need to be aware of (or just throw away for now)

Is that hierarchy used in searches at all? or just thrown away?

# Friendship

## Friendship

Send, receive friend request, and friend confirmation events.

1. send request
2. receive request\(in friend event\)
3. confirmation friendship\(friend event\)

[Examples/Friend-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/friend-bot.ts)

**Kind**: global class

* [Friendship](friendship.md#Friendship)
  * _instance_
    * [.accept\(\)](friendship.md#Friendship+accept) ⇒ `Promise <void>`
    * [.hello\(\)](friendship.md#Friendship+hello) ⇒ `string`
    * [.contact\(\)](friendship.md#Friendship+contact) ⇒ `Contact`
    * [.type\(\)](friendship.md#Friendship+type) ⇒ `FriendshipType`
  * _static_
    * [~~.send\(\)~~](friendship.md#Friendship.send)
    * [.add\(contact, hello\)](friendship.md#Friendship.add) ⇒ `Promise <void>`

### friendship.accept\(\) ⇒ `Promise <void>`

Accept Friend Request

**Kind**: instance method of [`Friendship`](friendship.md#Friendship)  
**Example**
dcsan commented 5 years ago

better parser for FAQs

we would have to parse the markdown file with hierarchical format. should we present back-ticked source code in the FAQ in wechat itself from the bot? A bit ugly since wechat doesn't have any decent/markdown formatting (unlike slack, discord etc)

links to online FAQ?

better to just link to the FAQ answer online but we would need to parse the anchor links case from the markdown and know the URL of the page.

So the links maybe better to remap to the gitbook links? eg https://raw.githubusercontent.com/Chatie/docs/master/root/api/friendship.md becomes

dcsan commented 5 years ago

add FAQ from live chats

if a question comes up in the chat, it would be good to be able to 'teach' the Bot that FAQ right away, and it would add to its local DB

dump learned FAQs to markdown

however this introduces a problem that we now have two sources for FAQ data. we would need a way to "dump" the bots 'learned' FAQs back to a markdown file somewhere, so it can be added back to github. Otherwise the data can be lost. But this can just be a simple task that we run on a devs machine from time to time, to retrieve production DB collection and export (to markdown?), git commit and push. Ofc the whole git process can just be a shell script, it's not needed to commit from JS code online in the production bot (but it might be neat to do that!)

dcsan commented 5 years ago

better search method / using NLP / classifier

right now we're using basically a keyword search. actually its a bit more so that the word order doesn't matter, we use a mongo $and query. but perhaps we should use a natural language classifier for the questions. That would be a lot more work though, as well as the code to link it in we should 'train' the bot on multiple ways to ask the question.

dcsan commented 5 years ago

chinese searches

we probably need to 'chunk' the incoming queries using jieba, so that we can turn them into keywords. Also Jieba might not be very smart with other chinese technical terms

huan commented 4 years ago

Hi @dcsan !

Our Friday.BOT has been upgraded with the new FAQ features support, please have a look on it and let me know if you want to continue this valuable work.

Currently, our bot has been using the following features:

  1. The AI is powered by Microsoft Cognitive Service: QnAMaker.ai
  2. The Knowledge Base is stored at Google Spreadsheet: Wechaty Community FAQ: Question & Answer Pairs for QnAMaker.ai
  3. The Wechaty use QnAMaker Plugin for connecting to the QnAMaker.

You can found the related source code from Friday.BOT at https://github.com/wechaty/friday/blob/master/src/friday/plugins/qnamaker.ts, for testing you can just send direct messages to Friday.BOT and it will reply to you the answer to your question if the confidential score is higher enough.

I hope this will be a new start for our FAQ bot plan and looking forward to your reply.

Have a nice day!

huan commented 3 years ago

Kindly ping @dcsan

and Happy New Year 2021!

dcsan commented 3 years ago

hiya - I saw the post above. I wasn't that pleased with QnAmaker last time I used it, so didn't really feel excited to build on it.

I also moved back to the US and got really busy with some other projects so probably don't have time to follow this up right now. Slack/Discord/Telegram are also great bot platforms with modern open APIs where you don't have to fight to get things done. So for fun side projects I prefer to work on those platforms now.

huan commented 3 years ago

Ok, got it.

I understand that Slack/Discord/Telegram have modern open APIs, and I hope you enjoy the projects that you are working on.

Wechaty will try to support Slack/Discord/Telegram in 2021 so that our bot can move between WeChat and other IM platforms without change any code. I Will let you know when we can test them.

Thanks for your reply, and have a great day!

P.S. We now have a plugin for QnAMaker.ai