You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

224 lines
7.9 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
  1. # QA Bot
  2. Table of Contents
  3. ===
  4. [TOC]
  5. Startup
  6. ===
  7. All source code can be found on [GitHub](https://github.com/shihxuancheng/qa_bot)
  8. 1. Use [back_end/run.py](https://github.com/shihxuancheng/qa_bot/blob/master/back_end/run.py) to launch backend app
  9. 2. [front_end/detect_intnt.py](https://github.com/shihxuancheng/qa_bot/blob/master/front_end/detect_intent_texts.py) is a demo code demostrate that how to detect intents by python api
  10. Intent-Based NLU
  11. ===
  12. ### Google Dialogflow
  13. [![image alt](https://miro.medium.com/max/1838/1*ZtwmXH1dvBKeYQj3M8kErw.png)](https://dialogflow.com/)
  14. #### Example of Restful API for Fulfillment
  15. ==Request==
  16. ```json
  17. POST body:
  18. {
  19. "responseId": "ea3d77e8-ae27-41a4-9e1d-174bd461b68c",
  20. "session": "projects/your-agents-project-id/agent/sessions/88d13aa8-2999-4f71-b233-39cbf3a824a0",
  21. "queryResult": {
  22. "queryText": "user's original query to your agent",
  23. "parameters": {
  24. "param": "param value"
  25. },
  26. "allRequiredParamsPresent": true,
  27. "fulfillmentText": "Text defined in Dialogflow's console for the intent that was matched",
  28. "fulfillmentMessages": [
  29. {
  30. "text": {
  31. "text": [
  32. "Text defined in Dialogflow's console for the intent that was matched"
  33. ]
  34. }
  35. }
  36. ],
  37. "outputContexts": [
  38. {
  39. "name": "projects/your-agents-project-id/agent/sessions/88d13aa8-2999-4f71-b233-39cbf3a824a0/contexts/generic",
  40. "lifespanCount": 5,
  41. "parameters": {
  42. "param": "param value"
  43. }
  44. }
  45. ],
  46. "intent": {
  47. "name": "projects/your-agents-project-id/agent/intents/29bcd7f8-f717-4261-a8fd-2d3e451b8af8",
  48. "displayName": "Matched Intent Name"
  49. },
  50. "intentDetectionConfidence": 1,
  51. "diagnosticInfo": {},
  52. "languageCode": "en"
  53. },
  54. "originalDetectIntentRequest": {}
  55. }
  56. ```
  57. ==Response==
  58. ```json
  59. {
  60. "fulfillmentText": "This is a text response",
  61. "fulfillmentMessages": [
  62. {
  63. "card": {
  64. "title": "card title",
  65. "subtitle": "card text",
  66. "imageUri": "https://assistant.google.com/static/images/molecule/Molecule-Formation-stop.png",
  67. "buttons": [
  68. {
  69. "text": "button text",
  70. "postback": "https://assistant.google.com/"
  71. }
  72. ]
  73. }
  74. }
  75. ],
  76. "source": "example.com",
  77. "payload": {
  78. "google": {
  79. "expectUserResponse": true,
  80. "richResponse": {
  81. "items": [
  82. {
  83. "simpleResponse": {
  84. "textToSpeech": "this is a simple response"
  85. }
  86. }
  87. ]
  88. }
  89. },
  90. "facebook": {
  91. "text": "Hello, Facebook!"
  92. },
  93. "slack": {
  94. "text": "This is a text response for Slack."
  95. }
  96. },
  97. "outputContexts": [
  98. {
  99. "name": "projects/${PROJECT_ID}/agent/sessions/${SESSION_ID}/contexts/context name",
  100. "lifespanCount": 5,
  101. "parameters": {
  102. "param": "param value"
  103. }
  104. }
  105. ],
  106. "followupEventInput": {
  107. "name": "event name",
  108. "languageCode": "en-US",
  109. "parameters": {
  110. "param": "param value"
  111. }
  112. }
  113. }
  114. ```
  115. #### Reference
  116. - [DialogFlow Offical Site](https://dialogflow.com/)
  117. - [DialogFlow client api for Python](https://github.com/shihxuancheng/dialogflow-python-client-v2)
  118. - [DialogFlow v2 rest api reference](https://cloud.google.com/dialogflow/docs/reference/rest/v2-overview)
  119. - [Voice App 開發實務:使用Diagflow+firebase開發Google home App (google assistant action)](https://ithelp.ithome.com.tw/users/20046160/ironman/1808)
  120. ---
  121. ### Microsoft (bot service + LUIS)
  122. [![image alt](https://2.bp.blogspot.com/-V3CtS3b1HAc/WWzaWvwJzVI/AAAAAAAABUc/0Od0YddweRUVbOt5OyRbd-6AhJJUwGQ1ACLcBGAs/s1600/Title.png)](https://www.luis.ai/home)
  123. ### Microsoft QnA Maker
  124. #### Example of Restful API
  125. ==Request==
  126. ```json
  127. {
  128. "question": "Is the QnA Maker Service free?",
  129. "top": 3
  130. }
  131. ```
  132. ==Response==
  133. ```json
  134. {
  135. "answers": [
  136. {
  137. "questions": [
  138. "How do I embed the QnA Maker service in my website?"
  139. ],
  140. "answer": "Follow these steps to embed the QnA Maker service as a web-chat control in your website:\n\n\n1. Create your FAQ bot by following the instructions [here](https://docs.microsoft.com/azure/cognitive-services/qnamaker/tutorials/create-qna-bot).\n2. Enable the web chat by following the steps [here](https://docs.microsoft.com/azure/bot-service/bot-service-channel-connect-webchat)",
  141. "score": 70.95,
  142. "id": 16,
  143. "source": "https://docs.microsoft.com/azure/cognitive-services/qnamaker/faqs",
  144. "metadata": []
  145. },
  146. {
  147. "questions": [
  148. "Do I need to use Bot Framework in order to use QnA Maker?"
  149. ],
  150. "answer": "No, you do not need to use the Bot Framework with QnA Maker. However, QnA Maker is offered as one of several templates in Azure Bot Service. Bot Service enables rapid intelligent bot development through Microsoft Bot Framework, and it runs in a server-less environment.",
  151. "score": 46.94,
  152. "id": 14,
  153. "source": "https://docs.microsoft.com/azure/cognitive-services/qnamaker/faqs",
  154. "metadata": []
  155. },
  156. {
  157. "questions": [
  158. "How can I create a bot with QnA Maker?"
  159. ],
  160. "answer": "Follow the instructions in [this](https://docs.microsoft.com/azure/cognitive-services/qnamaker/tutorials/create-qna-bot)documentation to create your Bot with Azure Bot Service.",
  161. "score": 43.25,
  162. "id": 15,
  163. "source": "https://docs.microsoft.com/azure/cognitive-services/qnamaker/faqs",
  164. "metadata": []
  165. }
  166. ]
  167. }
  168. ```
  169. #### Reference
  170. - [利用 MS Bot framework 與 Cognitive Service 建構自用智慧小秘書 系列](https://ithelp.ithome.com.tw/users/20091494/ironman/1411?page=1)
  171. - [使用 Microsoft Conversational AI Tools - 打造新时代的UI界面 系列](https://ithelp.ithome.com.tw/users/20083151/ironman/2101)
  172. - [Bot Framework SDF for Python](https://github.com/microsoft/botbuilder-python)
  173. - [QnA Maker](https://www.qnamaker.ai/)
  174. - [LUIS](https://www.luis.ai)
  175. Demo
  176. ===
  177. ## Agent1 - Wanhai_QABot
  178. ### qa_bot
  179. [![](https://github.com/shihxuancheng/qa_bot/blob/master/resources/assets/qa_bot_dialogflow.png?raw=true)](https://www.draw.io/?lightbox=1&highlight=0000ff&nav=1&page-id=c7558073-3199-34d8-9f00-42111426c3f3&title=qa_bot%20dialog%20flow.drawio#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fshihxuancheng%2Fqa_bot%2Fmaster%2Fresources%2Fassets%2Fqa_bot%2520dialog%2520flow.drawio)
  180. ## Agen2 - Wanhai_ServiceBot
  181. ### system_pic
  182. [![](https://github.com/shihxuancheng/qa_bot/blob/master/resources/assets/system_pic_dialogflow.png?raw=true)](https://www.draw.io/?lightbox=1&target=blank&highlight=0000ff&nav=1&page-id=s6GVqAID3o5IfIvOThLx&title=qa_bot%20dialog%20flow.drawio#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fshihxuancheng%2Fqa_bot%2Fmaster%2Fresources%2Fassets%2Fqa_bot%2520dialog%2520flow.drawio)
  183. ---
  184. ### whl_report
  185. [![](https://github.com/shihxuancheng/qa_bot/blob/master/resources/assets/whl_report_dialogflow.png?raw=true)](https://www.draw.io/?lightbox=1&target=blank&highlight=0000ff&nav=1&page-id=ZBpW3UwpYAJFGxqoSjzb&title=qa_bot%20dialog%20flow.drawio#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fshihxuancheng%2Fqa_bot%2Fmaster%2Fresources%2Fassets%2Fqa_bot%2520dialog%2520flow.drawio)
  186. ---
  187. ### whl_family
  188. [![](https://github.com/shihxuancheng/qa_bot/blob/master/resources/assets/whl_family_dialogflow.png?raw=true)](https://www.draw.io/?lightbox=1&target=blank&highlight=0000ff&nav=1&page-id=bM1LIQPi1tVLYMAEycQf&title=qa_bot%20dialog%20flow.drawio#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fshihxuancheng%2Fqa_bot%2Fmaster%2Fresources%2Fassets%2Fqa_bot%2520dialog%2520flow.drawio)
  189. Slide
  190. ---
  191. {%slideshare https://www.slideshare.net/RichardShih4/qa-bot %}
  192. ###### tags: `AI` `ChatBot` `dialogflow`
  193. test