sufehmi

Kalimasada-LINE : Anti-Hoax chatbot

Dec 18th, 2019
133
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Kalimasada-LINE : Anti-Hoax chatbot
  2.  
  3. TECHNICAL SPEC ::
  4.  
  5. Input : keywords, forwarded text, forwarded image (version 2), forwarded video (version 2)
  6.  
  7. Process : Search in Yudistira database via API, check with Sadewa (version 2)
  8.  
  9. Output : return result, escalate to human fact-checker if necessary via email to Issue Tracker @ https://plan.io
  10.  
  11. Framework : Laravel or CodeIgniter
  12.  
  13. ==============
  14. PSEUDOCODE : chatbot
  15.  
  16. $msg_response = "Thank you, we're processing your query now"
  17.  
  18. $msg_no_result = "sorry, there's currenty nothing in our database about it. We have escalated this query to our human fact-checker. Thank you"
  19.  
  20. $msg_email_body = "body: Here's a new issue. Click here once resolved: kalimasada.turnbachoax.id/telegram/notify-user.php?id=$issue_id , Click here if can't be resolved: kalimasada.turnbachoax.id/telegram/no-answer.php?id=$issue_id"
  21.  
  22.  
  23. # keywords : content consisted of string/text, with 20 words or less
  24.  
  25. $content = $incoming_message
  26.  
  27. # give response first
  28. # so users knows that we're serving them / not ignoring them
  29. echo $msg_response
  30.  
  31. $found = false
  32.  
  33. if type($content) = keywords {
  34.  
  35. $result = curl ("https://yudistira.turnbackhoax.id/antihoax/search", $content)
  36.  
  37. if $result = true {
  38. $found = true
  39. }
  40. }
  41.  
  42. # currently the API for searching keywords & text is the same
  43. # in the future, the keywords search API will be different, powered by Elastic Search
  44. if type($content) = text {
  45.  
  46. $result = curl ("https://yudistira.turnbackhoax.id/antihoax/search", $content)
  47.  
  48. if $result = true {
  49. $found = true
  50. }
  51. }
  52.  
  53.  
  54.  
  55. if $found = true {
  56.  
  57. send_msg ( $content )
  58.  
  59. } else {
  60.  
  61. echo $msg_no_result
  62.  
  63. $issue_id = save_query_to_database()
  64.  
  65. email("to: issue tracker", $msg_email_body)
  66.  
  67. }
  68.  
  69. ==============
  70. PSEUDOCODE : notify-user.php
  71.  
  72. // ask what's the URL to the answer
  73. // example : https://kalimasada.turnbackhoax.id/focus/3387
  74.  
  75. // press Submit
  76.  
  77. // send answer to user
  78. send_msg ( $answer )
  79.  
  80. ==============
  81. PSEUDOCODE : no-answer.php
  82.  
  83. $msg_no_answer = "Hi, apologies, your query is not valid , or we could not find any answer to your query. Thanks for using Kalimasada."
  84.  
  85. // actually do not delete, just set its status as "inactive" / "no answer"
  86. delete_query_from_database()
  87.  
  88. send_msg ( $msg_no_answer )
RAW Paste Data