<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alexandre Robin on Medium]]></title>
        <description><![CDATA[Stories by Alexandre Robin on Medium]]></description>
        <link>https://medium.com/@Alexandrobin_?source=rss-40164e09a21------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-Kzv393yHiCCdn0ckuDdzA.jpeg</url>
            <title>Stories by Alexandre Robin on Medium</title>
            <link>https://medium.com/@Alexandrobin_?source=rss-40164e09a21------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 13:26:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Alexandrobin_/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How I built an HR Slack Bot with Node and Botkit]]></title>
            <link>https://medium.com/free-code-camp/how-i-built-an-hr-slack-bot-with-node-and-botkit-6b23b81531bb?source=rss-40164e09a21------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b23b81531bb</guid>
            <category><![CDATA[human-resources]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[bots]]></category>
            <dc:creator><![CDATA[Alexandre Robin]]></dc:creator>
            <pubDate>Mon, 17 Sep 2018 16:18:30 GMT</pubDate>
            <atom:updated>2018-09-17T16:18:30.341Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3qx-9q-OBdf0zcge4Ca8yw.jpeg" /><figcaption>Star Wars 1 —Anakin’s building C3-PO</figcaption></figure><h3>Why create a Slack Bot ?</h3><p>I am an HR professional. More specifically I am a Human Resources Information System (HRIS) Consultant. I work with Application Tracking Systems, Learning Management Systems, and Core HR. But I have never had the opportunity to work with an HR Bot. Which may be the Future of HR.</p><p>I read a lot about bots on Slack and Messenger, and used some of them in my daily life — Product Hunt, GitHub and Trello. But for HR purposes, I have never had the opportunity to work with a tool tailored for my needs.</p><p>That’s why I decided to work on my own bot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*cyhNkd0jd7Zd3zBDLaKpSg.png" /><figcaption>Me starting to work</figcaption></figure><h3>My Goals</h3><p>My bot should be able to manage all the needs a small company could have on Slack:</p><ul><li>Onboarding</li><li>Putting people in touch</li><li>Reminders</li><li>Announcements</li><li>Birthdays /Anniversary</li><li>And many more</li></ul><h3>Reviewing the basics</h3><p>For this program, I’ll use:</p><ul><li>Botkit</li><li>Node JS</li><li>Express Server</li><li>MongoDB</li><li>Slack API &amp; of course</li></ul><p>Botkit is:</p><blockquote>One easy way to build bot users, especially if you already work with <a href="https://nodejs.org/">Node.js</a>, is Howdy’s <a href="https://howdy.ai/botkit/"><strong>Botkit</strong></a>. Botkit is a framework that takes care of most these API gymnastics, so you can focus on your bot’s behavior.</blockquote><p>Exactly what I was looking for :-)</p><p>Botkit provides a boilerplate for Slack. But I have chosen to start from scratch to have a better understanding of my bot. However, it’s a good idea to train yourself with a bot created on <a href="https://glitch.com/botkit">Glitch</a>.</p><h4>How do Slack bots work?</h4><p>I am not an expert. I have read again and again Slack and Botkit’s official documentation. I’m still not sure I understood everything. Here is my understanding of a Slack bot’s behavior:</p><p>Every App on Slack has a “scope” which is a perimeter on which an app can read or perform actions. A bot is part of an application created and installed on Slack.</p><p>Therefore, when you install an app on Slack, you give access to some information and permissions to it. For your bot, you want it to be, at least, able to send and reply to messages of other users.</p><p>There are then two cases:</p><ol><li>You want your bot to react to events happening <strong>directly in Slack</strong></li><li>You want your bot to react to events happening <strong>on your server</strong></li></ol><p>We will view both of them in this post!</p><h3>Getting Started</h3><p>Before anything else, you will need a server. In my case, Express.</p><p>Below you’ll find my server.js file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d88fcb89748641accc765bd5b3a17701/href">https://medium.com/media/d88fcb89748641accc765bd5b3a17701/href</a></iframe><p>This port must be public and accessible, not just on a localhost.</p><p>For the moment, this server is a blank page, showing and processing nothing.</p><p>You’ll then need a Slack App: just follow this <a href="https://api.slack.com/apps">link</a> to create one.</p><p>Then, you’ll have to configure your controller. The controller is the brain of your bot. It contains every skill and configuration. Below is my botkit.js file. It has almost the same content found in Botkit’s Starter kit available here: <a href="https://github.com/howdyai/botkit-starter-slack">https://github.com/howdyai/botkit-starter-slack</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/491a57d8875799110aa609fc8af6ca94/href">https://medium.com/media/491a57d8875799110aa609fc8af6ca94/href</a></iframe><h4>Unlocking the first case: react to the events happening on Slack</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*51uJInZFmmF_0gD3ICFr9Q.jpeg" /></figure><p>When you give the right permissions to your app, every time a message is sent on a channel, Slacks sends a request to your server with some information — the channel ID, the user, the timestamp and most importantly, the content of the message.</p><p>If we want our bot to react to a simple message like “Hi”, we have to give Slack an address to send the information to.</p><p>In a routes.js file write:</p><pre>var Request = require(&#39;request&#39;)<br>var slack = require(&#39;../controllers/botkit&#39;)</pre><pre>module.exports = function(app) {<br> app.post(&#39;/slack/receive&#39;, function(req,res){</pre><pre>//respond to Slack that the webhook has been received.<br>    res.status(200);</pre><pre>// Now, pass the webhook into be processed<br>    slack.controller.handleWebhookPayload(req, res)<br>  })<br>}</pre><p>We now have a webhook : <a href="http://your-ip-or-domain:port/slack/receive">http://your-ip-or-domain:port/slack/receive</a></p><p>Once Slack is informed of this route via the Event Subscriptions page of your Slack App, it will be able to send it JSON. You will be able to receive it thanks to the parsing part of the server.js file above.</p><p>Here is a (simple) schema to explain the process behind it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c-Km3PgTIihfbthJC0BFfw.png" /></figure><p>1- SLACK « Here is a JSON file with the latest event on your Slack Channel »</p><p>2- SERVER « Okay well received, I send it to Botkit»</p><p>3- BOTKIT «Here is a temporary answer, wait a second»</p><p>4- BOTKIT « Yeah! I hear a keyword, here is a JSON object with the action to perform »</p><p>If we want our bot to react every time it hears “Hello”, we can simply add this .hears() function to our controller:</p><pre>controller.hears([&#39;hello&#39;, &#39;hi&#39;], &#39;direct_message,direct_mention,mention&#39;, function(bot, message) {</pre><pre>controller.storage.users.get(message.user, function(err, user) {<br>        if (user &amp;&amp; user.name) {<br>            bot.reply(message, &#39;Hello &#39; + user.name + &#39;!!&#39;);<br>        } else {<br>            bot.reply(message, &#39;Hello.&#39;);<br>        }<br>    });<br>});</pre><p>Notice the storage.users.get() part in this snippet. Botkit is compatible with almost all the database systems available on the market. I have decided to use MongoDB because it was on my learning list for a long time. Plus the documentation with Botkit is detailed.</p><p>Now, we have to let our imagination do the work and find some fun features to create.</p><h4>Second Case: initiate a conversation with your bot</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pEUkhsJtGgYrzGvq0xf57Q.jpeg" /></figure><p>For this feature, I wanted my bot to react to events which were not initiated on Slack. For example, do a daily routine. If it’s someone’s anniversary in the company, send them a survey asking their feelings about their first months/weeks.</p><p>I have decided to use node-cron: <a href="https://github.com/kelektiv/node-cron">https://github.com/kelektiv/node-cron</a> to manage the daily check.</p><p>Here is below a cronjob firing every weekday at 9:00 am. Thanks to the Date() method, the bot gets today’s date and can compare it to the “joinedDate” of the user.</p><p>To get only the right users and avoid a forEach loop, we can use a query on our Database:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/72e9bb51c56d5fb2af07063f557bb350/href">https://medium.com/media/72e9bb51c56d5fb2af07063f557bb350/href</a></iframe><p>And… Tada!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MSZ0zXebVZ_wwCKP." /><figcaption>“A robot named Pepper holding an iPad” by <a href="https://unsplash.com/@agkdesign?utm_source=medium&amp;utm_medium=referral">Alex Knight</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Conclusion</h3><p>After more than a year of being a camper and learning to code, I am really happy to be able to start and finish a project like this one. I now have a bot working and performing almost all the actions I had in mind at the design phase. And I still have a lot of ideas!</p><p>I am still working on this bot. The GitHub repository is available here: <a href="https://github.com/alexandrobin/hrbot">https://github.com/alexandrobin/hrbot</a>. Some of the commits are in French, but the codebase is commented in English. :-)</p><p>Besides, it’s quite easy to deploy it on Heroku with a Mongolab database if you don’t have a server!</p><p>If you have some suggestions or are interested by this article and project, feel free to leave a comment ! I would be happy to discuss with you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b23b81531bb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/free-code-camp/how-i-built-an-hr-slack-bot-with-node-and-botkit-6b23b81531bb">How I built an HR Slack Bot with Node and Botkit</a> was originally published in <a href="https://medium.com/free-code-camp">We’ve moved to freeCodeCamp.org/news</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Scraped 7000 Articles From a Newspaper Website Using Node]]></title>
            <link>https://medium.com/free-code-camp/how-i-scraped-7000-articles-from-a-newspaper-website-using-node-1309133a5070?source=rss-40164e09a21------2</link>
            <guid isPermaLink="false">https://medium.com/p/1309133a5070</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Alexandre Robin]]></dc:creator>
            <pubDate>Wed, 20 Dec 2017 15:49:00 GMT</pubDate>
            <atom:updated>2018-01-31T16:13:14.657Z</atom:updated>
            <content:encoded><![CDATA[<h3>How I scraped 7,000+ articles from a newspaper website using Node</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dCcidN-uNelWP_fMYvC_jA.jpeg" /><figcaption>Credit : <a href="http://www.surlmag.fr/stephanie-binet-interview-surl-rap/">http://www.surlmag.fr/stephanie-binet-interview-surl-rap/</a></figcaption></figure><h4><strong>Why did I do this?</strong></h4><p>My girlfriend is writing a paper about the perception of French Hip-Hop music through time. To do that, she would like to text-mine articles from LeMonde.fr, a French mainstream newspaper.</p><p><strong>Problem</strong>: there have been more than <strong>7,000 articles </strong>talking about hip-hop music since the 80s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*sBlfrDqO3FpA2QjL3J3RvQ.jpeg" /><figcaption>My girlfriend’s reaction — Memegenerator.net</figcaption></figure><h4>Let’s code!</h4><p>For this program I will use:</p><ul><li>Local NodeJS Script</li><li>fs: to write a JSON file</li><li><a href="https://nodejs.org/dist/latest-v6.x/docs/api/http.html#http_event_request">Request</a>: to make POST and GET requests</li><li><a href="https://www.npmjs.com/package/cheerio">Cheerio</a>: to load HTML and be able to interact with it</li></ul><pre>//To install cheerio :<br>npm i --save cheerio</pre><p>Be sure you have all of it in your package.json, and everything should be fine :)</p><p><strong>What did I want? </strong><br>In the end, I wanted to have an Excel file organized like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*TH52fv64qK-zG8ApdRlM0Q.jpeg" /><figcaption>My Goal</figcaption></figure><p>Therefore, I had to use a JSON structured like this. I’ll show you at the end of this article how to convert JSON to Excel.</p><pre>[<br> {<br> ‎ date:,<br>  title:,<br>  description:,<br> ‎ text:,<br> ‎ url:,<br> ‎},<br>]<br></pre><h4>First step: get all articles’ URLs</h4><p>The first step was quite easy. Thanks to the advanced search feature, I just had to get the URL link of the result page and tell my code how to:</p><ul><li>Look for the number of results</li><li>Calculate the number of pages, knowing that there are 30 articles per page</li><li>Get the title, the description, the date, and the URL of the 30 articles for each page</li></ul><p>Here is the code to do so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6be4c05150c5f476960103d0696f9bd7/href">https://medium.com/media/6be4c05150c5f476960103d0696f9bd7/href</a></iframe><p>Once I did that, I had a JSON file with more than 7,000 entries. For each of them, I had:</p><ul><li>A Date</li><li>A Title</li><li>A Description</li><li>A URL</li></ul><p>I was just lacking the content…</p><p>“Okay, I just have to use the same code and run it for the 7000 URLs I have to get the content !”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*1Kxl4vJMqvQgEA22wZOSYg.jpeg" /><figcaption>Image Credit : Gemma Correll</figcaption></figure><p>I have been actively learning to code for one year now… And one of the first thing I learned was: <strong>nothing is ever simple in code</strong>. Ever. But for every problem you <strong>will </strong>struggle with, there is a question you can Google ;-).</p><p>I discovered that a huge part of the articles were not available without a premium account. So I had to be connected to view the content and scrape it.</p><p>Fortunately, we managed to get a premium account. I just had to find a way to tell my code how to:</p><ul><li>Authenticate to <a href="https://lemonde.fr/">lemonde.fr</a></li><li>Stay connected while scraping</li></ul><h4>Step Two : How to authenticate to a website</h4><p>To do so, I needed to understand how a website works when I am clicking on “Log In.” The good news is: we have the developer tools.</p><p>I just needed to find out how the website sends the password and the username to the server and reproduce the pattern.</p><p>Here is the authentication page of LeMonde.fr (As this is a French platform, I have translated some words to help you understand):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j-JFcBLEkFeqvCP2OPMiNA.png" /><figcaption>Screenshot of lemonde.fr</figcaption></figure><p>Now, what’s going on when we try to login ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GgcXRy11C1WOWjhFOhzMgA.gif" /></figure><p>Did you see that? I clicked on “Login” and lemonde.fr sends a POST request with a simple form containing five bits of information:</p><ul><li>connection[mail] = ‘your username’</li><li>connection[password] = ‘your password’</li><li>connection[stay_connected] = boolean : 1 for true, 0 for false (HINT : you want it to be true)</li><li>connection[save] = nothing needed here</li><li>connection[token] = this is the tricky part</li></ul><p>We already know four bits of info out of five. We just have to find from where the “token” is coming.</p><p>Fortunately, lemonde.fr is nice to us ☺️:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*YW9hQSFYyBDdcqsRTLvmLA.png" /></figure><p>The connection token is automatically generated in a hidden input when you load the page for the first time. You just have to know it and get it before trying to log in.</p><p>Well we are now ready to move on to step 3!</p><h4>Step three: Gotta catch ’em all!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*PMwOFcv5vuIsMHAWSQZWQw.gif" /><figcaption>Credit : Giphy.com</figcaption></figure><p>Here is the complete code to authenticate, retrieve, and keep the cookies and finally collect all the articles.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1ffef061da89a8dbe4ad5b4dc01e974/href">https://medium.com/media/c1ffef061da89a8dbe4ad5b4dc01e974/href</a></iframe><p>I have now a JSON file with all the articles and their content. The last step is to convert it into an actual Excel table.</p><h4>Bonus Step Four : From .JSON to .CSV</h4><p>Here is a simple code to convert your “output.json” file to “output.csv” (You can thank my friend <a href="https://github.com/jvdsande">@jvdsande</a>):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a9a4ba0a5423fd6dd77f301f0fbc8a9/href">https://medium.com/media/3a9a4ba0a5423fd6dd77f301f0fbc8a9/href</a></iframe><p>And that is it. I can import my ‘output.csv’ file into Excel and I have what I wanted : 7,000+ rows filled with articles from LeMonde.fr</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*vq6cNlgAT4jRsmndyK48vA.png" /><figcaption>Mission accomplished</figcaption></figure><p>Do you want to know the best part? I am pretty sure this logic is easily reusable for all the newspaper websites in the world!</p><p>If you are wanting to create a database or scrape a website, do not hesitate to contact me via Twitter or LinkedIN, I’d be happy to help you.</p><p>Oh! and I am working on a side project to reuse everything I learned here with LinkedIN to improve sourcing speed for recruiters :)</p><p>Thanks for reading, this is my first story on Medium and I would be thrilled to know your opinion about it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1309133a5070" width="1" height="1" alt=""><hr><p><a href="https://medium.com/free-code-camp/how-i-scraped-7000-articles-from-a-newspaper-website-using-node-1309133a5070">How I Scraped 7000 Articles From a Newspaper Website Using Node</a> was originally published in <a href="https://medium.com/free-code-camp">We’ve moved to freeCodeCamp.org/news</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>