[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

[fbot8] Facebook Messenger Bot

We implement here a Facebook Messenger Bot using the Messenger platform.

Installing the FBBot framework and sample

In this section we describe the steps to follow to install the S8 (framework and sample)files in a fresh desktop computer.
The steps to create and configure the messenger bot and accounts in Facebook are described in Facebook pages, see [fbot8] Installing the messenger.

Requirements

It is required to host the FBBot to run a server side (node.js) application with S8.
Ensure you have already
  1. Downloaded and installed Node.js
  2. Download and install LocalTunnel
    npm install -g localtunnel
  3. Download and decompress S8 Node platform files in a folder.

Steps to install a fresh FBBot (sample)

  1. Copy the default snapshot file (n8.snapshot.js) in Node platform to the folder where it is the app.js file in a fresh Facebook Messenger Bot application. Read more...
  2. Download the FBBot.st file in the folder where it is the app.js file
  3. Run the S8 server environment
    node n8.snapshot.js
  4. Connect to the server using U8 remote tools
  5. FileIn the FBBot framework
    Evaluating in a (remote) workspace: 'FBBot.st' fileContents fileIn
    You should see in the console of the server that the framework is compiled.
  6. Now you can save the image evaluating:
    'function print(text) { return console.log(text); }',Snapshot contents outputToFile: 'n8.snapshot.js'
  7. Now your server includes the FBBot implementation and sample

Starting your Facebook Messenger FBBot sample

  1. Locate the folder containing app.js
  2. Run the server
    node n8.snapshot.js
  3. Connect to the server using U8 remote tools
  4. Browse the FBBot sample opening the System Browser
    Find class... FBBot, see also the subclass(es) e.g. AleTestDrive
  5. Start the FBBot sample evaluating:
    AleTestDrive start
  6. Run the tunnel to expose your server to internet (take note of the address of the tunnel)
  7. Set the page of the Facebook Messenger webhook to your tunnel
  8. Now... in FB messenger, send a message to the page of the bot containing text with commands e.g. help or #yourself

Development of FBBot

In this section we describe the steps taken to implement the sample

Steps followed to implement the FBBot

  1. [fbot8] Installing the messenger
  2. [fbot8] Hacking the messenger
  3. [fbot8] Embedding the App server
  4. [fbot8] Implementing the App server in S8

The implementation is published in the folder of U8 Frameworks for Facebook
See FBBot.st file

Status

The status of the framework is Just published.

Contact and help

In case you need help or guidance in using the framework contact us in the S8 Smalltalk Facebook group, or by email.