Skip to content

Commit

Permalink
Document Facebook Messenger with Ruby on Rails
Browse files Browse the repository at this point in the history
  • Loading branch information
jgorset committed Apr 26, 2016
1 parent b26170d commit 7c76665
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Expand Up @@ -187,6 +187,10 @@ from Facebook:
Facebook::Messenger::Subscriptions.subscribe
```

### Run it

##### ... with Rack

The bot runs on [Rack][rack], so you hook it up like you would an ordinary
web application:

Expand All @@ -202,6 +206,38 @@ run Facebook::Messenger::Server
$ rackup
```

##### ... with Rails

Rails doesn't give you much that you'll need for a bot, but if you have an
existing application that you'd like to launch it from or just like Rails
a lot, you can mount it:

```ruby
# config/routes.rb

Rails.application.routes.draw do
# ...

mount Facebook::Messenger::Server, at: 'bot'
end
```

We suggest that you put your bot code in `app/bot`.

```ruby
# app/bot.rb

include Facebook::Messenger

Bot.on :message do |message|
Bot.deliver(
recipient: message.sender,
message: {
text: 'Hello, human!'
}
)
end
```

## Development

Expand Down

0 comments on commit 7c76665

Please sign in to comment.