

Word_counter, key=word_counter.get, reverse=True) import discordįrom nltk.tokenize import word_tokenize client = discord.Client() conn = tg.TigerGraphConnection(host="", username="USERNAME", version="3.0.5", password="PASSWORD", useCert=True) aphname = "ChatBot"Ĭonn.apiToken = conn.getToken(conn.createSecret()) def on_message(msg): We’ll first create the outline of a discord bot. Remember the token you generated in Step I? You’ll need that now. Next, let’s create the bot! Step IV: Create the BotĬreate a new file now. Great! Now you have all the data loaded into your graph. Before we load the data, we need to clean it, removing any stopwords or punctuation. Next, we need to load the data into the graph. The data has a few sections which will be important: raw (the whole message), id, “topic_slug,” and “topic_id.” Together, “topic_slug” and “topic_id” can retrieve the original url. Using the JSON library, I loaded the “latest_posts.” import requestsĭata = json.loads(x.text) To do this, I pulled recent messages from the forum using the endpoint. To get my data, I pulled from articles from. aphname = "ChatBot"Ĭonn.apiToken = conn.getToken(conn.createSecret()) Step III: Pull Data from an API conn.gsql(''' CREATE VERTEX Word(primary_id word STRING) with primary_id_as_attribute="true"ĬREATE VERTEX Message(primary_id id INT, message STRING, url STRING)ĬREATE UNDIRECTED EDGE WORD_MESSAGE(FROM Message, To Word)ĬREATE GRAPH ChatBot(Word, Message, WORD_MESSAGE) ''')Īfter running this, you would have created your graph in TigerGraph! Congrats! Next, you will need to adjust your connection details then load data and write a query. The schema in this case will be simple: the vertices Message and Word connected with a MESSAGE_WORD vertex. import pyTigerGraph as tg conn = tg.TigerGraphConnection(host="", username="USERNAME", version="3.0.5", password="PASSWORD", useCert=True) Step 2d: Create the Schema First, import pyTigerGraph, then use it to create the connection using the information you submitted in step three for HOST_NAME, USERNAME, and PASSWORD. Once the solution starts, you can create a connection in your document with the following. Press Submit and wait for the Solution to Start.Edit the solution name, tags, and subdomain as needed and then press Next.Click “Blank v3” then press Next twice.Go to “My Solutions” then click “Create Solution.First, start up a solution at http //tgcloud.io/ by creating an account and then completing the following steps: Then, create a document called createGraph.py or something similar.
#DISCORD CHATBOT INSTALL#
Pip install discord.py Step 2b: Start the Solution First, make sure you have both pyTigerGraph and Discord.py installed. The graph will be created in pyTigerGraph. Step II: Create the Graph Step 2a: Import Libraries To copy it, simply press the blue “Copy” button. Here, on the left side bar, toggle to “Bot,” then click “Add Bot.”Īfter confirming, you’ll have your bot! Eventually, you’ll need the Token of the bot. Next, name your application at the prompt.Ī fter you name it, you should redirect to a page for the bot.
