The SendGrid-Reversi is an open source demo project.
This application is Ruby application to work on Sinatra.
This uses some of SendGrid APIs.
- Web API(Mail, Filter Settings, Parse Webhook Settings)
- SMTP API(To, Substitutions, Filters)
- Parse Webhook
- Event Webhook (Click)
- Template Engine
This stores the game data and template id to MongoDB.
- Ruby 2.0.0 or higher
- Bundler (Sinatra, sendgrid_ruby,sendgrid_template_engine... See Gemfile for detail)
- MongoDB
- ngrok (for local environment)
You have 2 options for launching the application. You can launch the application on local environment or Heroku. Heroku is simple way.
Parameters | Description |
---|---|
APP_URL | Your application URL. |
PARSE_HOST | The domain name of receive email. |
Access APP_URL for checking the application launch. Now you are ready for reversi! Goto Usage.
ngrok is easy way to publish your service if you launch the application on local environment.
'4567' is the port number to tunnel.
You will see Forwarding URL when you launch ngrok.
$ ngrok 4567
ngrok (Ctrl+C to quit)
Tunnel Status online
Version 1.6/1.6
Forwarding http://awwa500.ngrok.com -> 127.0.0.1:4567
Forwarding https://awwa500.ngrok.com -> 127.0.0.1:4567
Web Interface 127.0.0.1:4040
# Conn 0
Avg Conn Time 0.00ms
$ git clone https://github.com/awwa/sendgrid-reversi.git
$ cd sendgrid-reversi
$ bundle install
$ cp .env.example .env
vi .env
SENDGRID_USERNAME=your_username
SENDGRID_PASSWORD=your_password
APP_URL=http://app.host.example.com
PARSE_HOST=your.receive.domain
MONGO_URL=mongodb://user:pass@localhost:27017/reversi_development
Parameters | Description |
---|---|
SENDGRID_USERNAME | Your SendGrid username. |
SENDGRID_PASSWORD | Your SendGrid password. |
APP_URL | Your application URL. 'URL Forwarding' value if you use ngrok. |
PARSE_HOST | The domain name of receive email. |
MONGO_URL | The url of mongodb. ex. mongodb://user:pass@localhost:27017/reversi_development |
$ mongod
The application setup SendGrid when first time launch. Also start the service to listen.
$ RACK_ENV=production rackup -p 4567
Player1 sends email to any address of PARSE_HOST domain.
That subject include email address of player2.
To: [email protected]
Subject: [email protected]
Player2 get an email like this.
He(she) can click on the email where he(she) want to put disc.
After this, the each player get an email then click it.
You can click 'Pass your turn' link under the board if you want to pass your turn.
The game will finish in the case:
- All cell was filled.
- Each player continuously clicked the pass link.
You can view text/plain version board email if your email client does not support html mail.
Do not say 'Create a browser based application'. This is a demo application. ;-)