Giter Club home page Giter Club logo

chatbotexample's Introduction

Multi-channel bot

This document describes how to set up a sample Express app which talks to Slack, Facebook, and Twilio bots.

Install all dependencies:

```
npm install
```

Getting credentials

Watson Conversation

Follow the steps outlined in this document and paste your Conversation bot's credentials in the sample .env file in the project directory.

If you don't have a Conversation service instance, follow these steps to get started.

Slack

Follow the Getting Started section of this document from Botkit. Once you obtain the Slack token, paste the token in the .env file.

SLACK_TOKEN=<your token>

Facebook Messenger

Follow the Getting Started section of this document from Botkit.

Some helpful hints for Facebook Messenger:

  • Log into the Facebook App settings page. You need to add two Products- Messenger and Webhooks.
  • When setting up Messenger, make sure you have subscribed your page with your app, otherwise your app won't send back responses to your page. This step is also important cause Facebook will provide you with the FB_ACCESS_TOKEN your bot will need to communicate via Messenger.
  • When setting up the webhook,
    • You'll have to first set up localtunnel locally and start it on the same port where you plan to run your Express app. Let's say you run your app on port 5000, then in one terminal window run the following command: lt --port 5000 lt will provide you with a url, part of which will be the webhook url.
    • Add (https://<your localtunnel url>/facebook/receive) as Facebook Messenger's webhook. The webhook url must contain https://. eg: If your localtunnel url is http://litjqjglwn.localtunnel.me your webhook url will be https://litjqjglwn.localtunnel.me/facebook/receive, otherwise Facebook will show an error.
    • You need to only subscribe to Messages event under Webhooks.

Once you obtain the access token (provided by Facebook), the verify token (created by you) and the app secret key for your Facebook app (provided by Facebook), paste them in the .env file of your project.

FB_ACCESS_TOKEN=<your access token>
FB_VERIFY_TOKEN=<your verify token>
FB_APP_SECRET=<your apps secret key>

When you're ready to test your bot, go to your Facebook homepage and find the page you created. Click on Message to start chatting with your Watson Conversation bot!

Twilio IPM

Follow the Getting Started section of this document from Botkit. Copy and paste all the authentication details in the .env file.

TWILIO_ACCOUNT_SID=<your account sid>
TWILIO_AUTH_TOKEN=<your auth token>
TWILIO_IPM_SERVICE_SID=<your service sid>
TWILIO_API_KEY=<your twilio API key>
TWILIO_API_SECRET=<your twilio API secret>

You'll need to set up localtunnel and have it running on the same port as your app server. The webhook url for Twilio will then be (https://<your localtunnel url>/twilio/receive).

To test the bot, use this simple Twilio IPM server.

Starting the server

If you are connecting to a channel, you need to add USE_<channel_name> in the .env file. eg: If you would like to use Slack and Facebook Messenger, you must add the following lines in your .env file:

USE_SLACK=any_value
USE_FACEBOOK=any_value

The value of these variables doesn't matter, as long as they're present. The middleware knows it needs to connect to these channels.

Once you have added your credentials in the .env file, start the example express app by running this command:

node server.js

Voila! You're all set! Start chatting on your social channel to test your bot.

chatbotexample's People

Contributors

villami avatar

Watchers

James Cloos avatar Jorge Cuevas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.