<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Chatscript - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Chatscript - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Mon, 18 May 2026 22:35:56 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/chatscript/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to build your first chatbot using ChatScript ]]>
                </title>
                <description>
                    <![CDATA[ By Giorgio Robino 10–10–2018: article updated with new github repo url. Chatbots can help you get things done right inside chat tools like Facebook Messenger, Telegram Messenger, Slack, etc, etc. Just say the word and your chatbot will deploy your ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/chatscript-for-beginners-chatbots-developers-c58bb591da8/</link>
                <guid isPermaLink="false">66c3473a93db2451bd441430</guid>
                
                    <category>
                        <![CDATA[ Chatscript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ #chatbots ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Machine Learning ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 02 Aug 2016 17:49:00 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*tC6objBcZbzBQwS1wrSyYA.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Giorgio Robino</p>
<blockquote>
<p>10–10–2018: article updated with new <a target="_blank" href="https://github.com/ChatScript/ChatScript">github repo url</a>.</p>
</blockquote>
<p>Chatbots can help you get things done right inside chat tools like Facebook Messenger, Telegram Messenger, Slack, etc, etc. Just say the word and your chatbot will deploy your latest build, or order you a pizza.</p>
<p>And there’s a special tool for building chatbots that’s been around for quite some time. It’s called ChatScript. And like Slack, it started out as just a small part of a video game.</p>
<p>Back in 2009, <a target="_blank" href="http://brilligunderstanding.com/aboutus.html">Bruce Wilcox</a> was working as a game developer and artificial intelligence researcher. His wife, <a target="_blank" href="http://brilligunderstanding.com/aboutus.html">Sue Wilcox</a>, wanted to model virtual characters for her interactive fiction games. Together, they built what ultimately became ChatScript.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/sfq-G4yfCxunsEuCSJGq-e5TUIytuUOhDlv2" alt="Image" width="800" height="705" loading="lazy">
_Sue Wilcox (source: [http://brilligunderstanding.com/aboutus.html](http://brilligunderstanding.com/aboutus.html" rel="noopener" target="<em>blank" title="))</em></p>
<p>This natural language processing engine + dialog flow scripting platform helped Bruce win the <a target="_blank" href="http://www.loebner.net/Prizef/loebner-prize.html">Loebner AI Prize</a> three times.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/QmL7v89jgnPL3uP7-q5vigSEps4Y11hh5mah" alt="Image" width="800" height="449" loading="lazy">
_[Watch a talk by Bruce Wilcox](http://www.fundacionareces.tv/watch/50a63327c31997630a020000" rel="noopener" target="<em>blank" title=")</em></p>
<p>Bruce still develops and maintains the project today. It’s written in C and C++, and is open source. In fact, version 6.8 just came out a few weeks ago.</p>
<p><strong>ChatScript is one of few OPENSOURCE chatbots NLProc engines!</strong></p>
<p>Let’s dive into the basics of <a target="_blank" href="https://github.com/ChatScript/ChatScript">ChatScript</a> and meet a chatbot named Harry.</p>
<h3 id="heading-installing-chatscript">Installing ChatScript</h3>
<p>Some of these steps may be a bit different depending on what operating system you’re using. <strong>I’m using Linux</strong>. You don’t actually have to go through these steps to enjoy this article if you don’t want to. Just read along.</p>
<h4 id="heading-step-1-install-the-system-components-on-your-local-computer">Step 1: Install the system components on your local computer</h4>
<p>First of all clone the ChatScript GitHub repository:</p>
<pre><code class="lang-bash">$ git <span class="hljs-built_in">clone</span> https://github.com/ChatScript/ChatScript
</code></pre>
<p>This will create a ChatScript directory, which will contain these subdirectories:</p>
<pre><code>$ cd ChatScript/
$ ls -d1 */

BINARIES/
DICT/
DOCUMENTATION/
LINUX/
LIVEDATA/
LOEBNERVS2010/
LOGS/
MAC/
RAWDATA/
REGRESS/
SERVER BATCH FILES/
SRC/
SUBLIME TEXT EDITOR/
TMP/
TOPIC/
USERS/
VERIFY/
VS2010/
VS2015/
WEBINTERFACE/
</code></pre><ul>
<li>DOCUMENTATION contains <a target="_blank" href="https://github.com/ChatScript/ChatScript/tree/master/WIKI">wiki documentation files</a>.</li>
</ul>
<blockquote>
<p><strong>BTW, I personally contributed to update all the original documentation in markdown format to be read online and from command line when developing.❤</strong></p>
</blockquote>
<ul>
<li>RAWDATA contains a subdirectory for each bot. By default, the platform comes with a default bot named Harry, who is located at RAWDATA/HARRY.</li>
</ul>
<p>BTW, please remember to set LinuxChatScript64 executable:</p>
<pre><code class="lang-bash">$ chmod +x ChatScript/BINARIES/LinuxChatScript64
</code></pre>
<blockquote>
<p>Note: obviously here above I’ considering the Linux OS environment.<br>More info about Linux, MacOS or Windows installation <a target="_blank" href="https://github.com/bwilcox-1234/ChatScript#getting-started">here</a>.</p>
</blockquote>
<h4 id="heading-step-2-to-run-cs-engine-in-standalone-mode">Step 2: To run CS engine in standalone mode:</h4>
<pre><code class="lang-bash">$ BINARIES/LinuxChatScript64 <span class="hljs-built_in">local</span>
</code></pre>
<p>Running the engine will launch Harry, with whom we can then talk:</p>
<pre><code>ChatScript EVSERVER Version <span class="hljs-number">6.8</span>  <span class="hljs-number">64</span> bit LINUX compiled Aug <span class="hljs-number">16</span> <span class="hljs-number">2016</span> <span class="hljs-number">17</span>:<span class="hljs-number">35</span>:<span class="hljs-number">43</span> host=local
<span class="hljs-attr">Params</span>:   dict:<span class="hljs-number">720895</span> fact:<span class="hljs-number">800000</span> text:<span class="hljs-number">70000</span>kb hash:<span class="hljs-number">50000</span>
          <span class="hljs-attr">buffer</span>:<span class="hljs-number">22</span>x80kb cache:<span class="hljs-number">1</span>x5000kb userfacts:<span class="hljs-number">100</span>
<span class="hljs-attr">WordNet</span>: dict=<span class="hljs-number">201350</span>  fact=<span class="hljs-number">85710</span>  stext=<span class="hljs-number">12703744</span> Jul26<span class="hljs-string">'16-21:58:46
Build0:  dict=67726  fact=130289  stext=1145656 Jul31'</span><span class="hljs-number">16</span><span class="hljs-number">-13</span>:<span class="hljs-number">45</span>:<span class="hljs-number">49</span> <span class="hljs-number">0</span>
<span class="hljs-attr">Build1</span>:  dict=<span class="hljs-number">167</span>  fact=<span class="hljs-number">15</span>  stext=<span class="hljs-number">211304</span> Jul31<span class="hljs-string">'16-13:45:44 harry
Used 53MB: dict 269,244 (23693kb) hashdepth 18/1 fact 216,014 (8640kb) text 14183kb
           buffer (1760kb) cache (5000kb) POS: 918 (29kb)
Free 79MB: dict 451,651 hash 924 fact 583,986 text 55,816KB

Enter user name: giorgio

HARRY:  Welcome back
giorgio: &gt; what is your name ?
HARRY:  My name is Harry.
giorgio: &gt; who is Bruce Wilcox?
HARRY:  Bruce Wilcox (born 1951) is an artificial intelligence programmer.
giorgio: &gt; ok, I have to go
HARRY:  Indeed.
giorgio: &gt; :quit
Exiting ChatScript via Quit
$</span>
</code></pre><h4 id="heading-step-3-code-and-debug-your-chatbot-scripts">Step 3: Code and debug your chatbot scripts</h4>
<p>Standalone mode makes for an excellent ChatScript development environment. It allows you to run interactive conversations, then interact with them using <strong>:commands</strong>. This is a special set of interactive command tools for testing and debugging your dialogs during the development and debug phase.</p>
<p>Here are a few example commands:</p>
<pre><code># recompile the bot Harry and reset the status <span class="hljs-keyword">of</span> conversations <span class="hljs-keyword">with</span> user giorgio

<span class="hljs-attr">giorgio</span>: &gt; :build Harry 
<span class="hljs-attr">giorgio</span>: &gt; :reset

# request statistics about topic ~pets
<span class="hljs-attr">giorgio</span>: &gt; :topicstats ~pets
    ~pets     gambits <span class="hljs-number">2</span> responders <span class="hljs-number">2</span> rejoinders <span class="hljs-number">5</span> empties <span class="hljs-number">0</span>
Concepts <span class="hljs-number">1860</span> Topics <span class="hljs-number">1</span> rules <span class="hljs-number">9</span> empties <span class="hljs-number">0</span>
  gambits <span class="hljs-number">2</span>  responders <span class="hljs-number">2</span> (?: <span class="hljs-number">2</span> s: <span class="hljs-number">0</span>  u: <span class="hljs-number">0</span>) rejoinders <span class="hljs-number">5</span>

# conversation ...
giorgio: &gt; <span class="hljs-keyword">do</span> you like snakes?
HARRY:  I love pythons except ^<span class="hljs-string">"Python"</span> (the programming language)

# ask the reason why a rule fired
<span class="hljs-attr">giorgio</span>: &gt; :why
~pets<span class="hljs-number">.2</span><span class="hljs-number">.0</span><span class="hljs-number">.5</span><span class="hljs-number">.9</span><span class="hljs-number">.0</span>  ?:  ( &lt;&lt; you like snake &gt;&gt; ) I love pythons except Python ( the programming language )
 via ~control<span class="hljs-number">.5</span><span class="hljs-number">.9</span><span class="hljs-number">.0</span>  u:  ( ) $$currenttopic = %topic ^<span class="hljs-keyword">if</span> <span class="hljs-number">00</span>m( %response  <span class="hljs-number">0</span> ) <span class="hljs-number">00</span>I{ ^nofail ( TOPIC ^rejoinder ( ) ...
</code></pre><p>Note that you can run <strong>:commands</strong> to show the full list of available commands.</p>
<p>Topics are contained in specific files. For example, the <strong><em>~</em></strong><em>pets</em> topic code is contained in <em>pets.top</em> file, which looks like this:</p>
<pre><code>topic: ~pets (dog cat pet animal bird fish snake)

?: ( &lt;&lt; you like snake &gt;&gt; )
 I love pythons except ^<span class="hljs-string">"Python"</span> (the programming language)

?: ( &lt;&lt; you ~like ~animals &gt;&gt; ) 
 I love all animals.

t: Do you have any pets?
 #! yes
 <span class="hljs-attr">a</span>: ( ~yes ) Great. You like animals.

#! no
 <span class="hljs-attr">a</span>: ( ~no ) You don’t like animals?

#! I have two parrots
 <span class="hljs-attr">a</span>: ( parrots ) Birds are nice.

#! I have a cat
 <span class="hljs-attr">a</span>: ( cat ) I prefer dogs

#! I have a canary
 <span class="hljs-attr">a</span>: ( [parrot bird canary finch swallow] ) Birds are nice.

t: I have a dog.
</code></pre><p>ChatScript is a rule-based engine, where rules are created by humans writers in program scripts through a process called dialog flow scripting. These use a scripting metalanguage (simply called a “script”) as their source code.</p>
<p>Here what a ChatScript script file looks like:</p>
<pre><code>#
# file: food.top
#

<span class="hljs-attr">topic</span>: ~food []

#! I like spinachs
<span class="hljs-attr">s</span>: ( I like spinach ) 
   Are you a fan <span class="hljs-keyword">of</span> the Popeye cartoons?

a: ( ~yes ) 
       I used to watch him <span class="hljs-keyword">as</span> a child. Did you lust after Olive Oyl?
     b: ( ~no ) Me neither. She was too skinny.
     b: ( ~yes ) You probably like skinny models.

a: ( ~no ) What cartoons <span class="hljs-keyword">do</span> you watch?
     b: ( none ) You lead a deprived life.
     b: ( Mickey Mouse ) The Disney icon.

#! I often eat chicken
<span class="hljs-attr">u</span>: ( ![ not never rarely ] I * ~ingest * ~meat ) 
   You eat meat.

u: ( !~negativeWords I * ~like * ~meat ) You like meat.

?: (<span class="hljs-keyword">do</span> you eat _ [ ham eggs bacon]) 
   I eat ‘_0

?: (<span class="hljs-keyword">do</span> you like _* or _*) 
   I don’t like ‘_0 so I guess that means I prefer ‘_1.

s: ( ~like ~fruit ![~animal _bear] ) 
   Vegan, you too...

?: (<span class="hljs-keyword">do</span> you eat _~meat) 
   No, I hate _0.

s: ( I eat _*<span class="hljs-number">1</span> &gt;) 
  $food = ‘_0 
  I eat oysters.
</code></pre><p>You can define your bot’s dialog flows with a script stored as a normal text file. This is much simpler than methods that other chatbot tools use, which often involve browser-based user interfaces, JSON, or XML.</p>
<p>Writing your scripts as a text files gives you full control over your dialog flows. You a can easily process and upgrade your conversational code with back-end scripts and tools.</p>
<p>For example, you could automatically update ChatScript dialog rules based on records in your database.</p>
<p>You could even use machine learning tools to mine conversations logs. This could reveal all kinds of opportunities for you to improve your dialog flows.</p>
<p>But these are topics for a future ChatScript article. I’ll leave you to go play with ChatScript on your own.</p>
<blockquote>
<p><strong>Please contribute to its open source codebase, and star it on</strong> <a target="_blank" href="https://github.com/ChatScript/ChatScript"><strong>GitHub</strong></a><strong>!</strong>🌟🌟🌟🌟🌟</p>
</blockquote>
<p><a target="_blank" href="https://github.com/ChatScript/ChatScript"><strong>ChatScript/ChatScript</strong></a><br><a target="_blank" href="https://github.com/ChatScript/ChatScript">_Contribute to ChatScript/ChatScript development by creating an account on GitHub._github.com</a></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/sSgolG-hbTtiw1APxWTmh3CwIkfcWwaIPfBJ" alt="Image" width="640" height="70" loading="lazy">
<em><strong>Please tap or click “︎</strong>❤” to help to promote this piece to others.</em></p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
