Skip to content

Instantly share code, notes, and snippets.

@sanyam-git
Last active April 21, 2020 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanyam-git/d17eb29dcbf899c23787c3c81e0b2f79 to your computer and use it in GitHub Desktop.
Save sanyam-git/d17eb29dcbf899c23787c3c81e0b2f79 to your computer and use it in GitHub Desktop.
a brief info about wikibot and backend functionality

Wikibot

A simple, fast and scalable solution for an interactive chatbot.

  • Bot live at : @wikibot on zulipchat
  • Use Terminal : API
  • Dashboard : link shared with mentors

Internal Working

How the bot thinks ?

The flow schema followed by the bot: main_chart

Scraping the information

The platform uses the following approach to extract useful information from text and provide the best fit response.

language-algo

Example : What are some Python projects I could work on ? extracted keywords are ['python', 'projects', 'work']

Types of Messages

The following commands are processes by the bot :

Messages without prefix

  • Can updated from dashboard (main category) example : Give me a list of Wikimedia's gsoc projects.

main

  • Casual Talk : The bot is pre-programmed to perform casual talk with the users on general topics, such as greetings, activities, likes/dislikes, etc.

Messages with prefix (+)

  • Alpha Command : Category names and messages can be created and managed through Alpha section on dashboard.
    • syntax : +<category_name > <query>
    • example : +lang python projects

alpha

  • Beta Command : Messages with +<name> only. Can be created and managed through beta section on dashboard.
    • syntax : +<name >
    • example : +timeline

beta

  • Standard Command : Inbuilt command in code for predefined actions.
    • example : + help for help, + task <task_id> for info about a phab task

task

Other Features:

  • Statistics Page : A statistics page on the dashboard to analyse the user-bot interaction.
  • Project Suggestion : suggesting project details (such as project location gerrit/github/phabricator, mentors, workboard etc.) from skills.
  • Find status of tasks assigned/created to/by the user.

Dashboard

A single page web app to create, update and manage the bot's knowledge base.

dashboard-main

# script to use the bot from terminal
# user parametres can be updated
import time
import requests
import json
import random
# you can update the details here if you want
user_id = '456121'
full_name = 'hesoyam'
short_name = 'hesoyam'
email = 'hesoyam@mymail.com'
# end
message_id = random.randrange(100000000, 999999999, 1)
timestamp = int(time.time())
url = 'https://openinternet.pythonanywhere.com/api'
payload = {
"data": "",
"message": {
"id": message_id,
"sender_id": user_id,
"content": "",
"recipient_id": 433815,
"timestamp": timestamp,
"client": "website",
"subject": "",
"topic_links": [],
"rendered_content": "<p>Hi</p>",
"is_me_message": False,
"reactions": [],
"submessages": [],
"sender_full_name": full_name ,
"sender_short_name": short_name,
"sender_email": email,
"sender_realm_str": "wikimedia",
"display_recipient": [
{
"email": email,
"full_name": full_name,
"short_name": short_name,
"id": user_id,
"is_mirror_dummy": False
},
{
"id": 274271,
"email": "wikibot-bot@zulipchat.com",
"full_name": "wikibot",
"short_name": "wikibot-bot",
"is_mirror_dummy": False
}
],
"type": "private",
"avatar_url": "https://secure.gravatar.com/avatar/d8f78109444fc5ec90ca174923b580c9?d=identicon&version=1",
"content_type": "text/x-markdown"
},
"bot_email": "wikibot-bot@zulipchat.com",
"token": "v3BmJRGVB4Ec6pTOTi5gEqghSZKWQ275",
"trigger": "private_message"
}
print("-> Currently the API is open without any key or authentication (limited sharing)")
print("-> The latency may be higher as compared to using @ wikibot with zulip because of direct connection")
print("-> Use wikibot on zulip for lower latency")
print("-> You can change user_parametres in the file")
print("-> Quit anytime using 'quit' or 'q'")
print("-> Please share you feedback :)")
print("\n")
while True:
message = input(short_name + ' : ')
if message == 'quit' or message == 'q':
print('User closed the chat session')
break
payload['message']['content'] = message
payload['data'] = message
headers = {'content-type': 'application/json'}
start = time.time()
response = requests.post(url, data=json.dumps(payload), headers = headers)
end = time.time()
latency = '(latency : ' + str(int((end-start)*1000)) + ' ms, use wikibot on zulip for low latency)'
response = response.json()
print('wikibot : '+response['content'])
print(latency)

Adding New Category

add-category

Delete Category

delete-category

Add New Entry

add-entry

Edit Entry

edit-entry

Delete Entry

delete-entry

Beta Page

beta-page

Error Alert

error-alert

Home

home-screen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment