Skip to content

Commit

Permalink
Added Terraform files for Heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Damm committed Jan 3, 2020
1 parent 52d4cc5 commit d43af02
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 14 deletions.
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,45 @@ We recommend you create a separate project within Twilio and install this app us

* For Account SID and Auth Token please click here: https://www.twilio.com/console
* Buy a phone number or use an existing one (the application will configure the number for you later)
* Create a new Twilio [TaskRouter Workspace](https://www.twilio.com/user/account/taskrouter/workspaces)
* Create a new Twilio [TaskRouter Workspace](https://www.twilio.com/user/account/taskrouter/workspaces) and select the custom template.

The agent UI does not support handling of multiple tasks simultaneously, hence all tasks are routed on the same task channel with capacity of one simultaneous task. For more details please check [TaskRouter Multitasking](https://www.twilio.com/docs/taskrouter/multitasking)

* For creating a new Chat Services or re-using an existing one, click here: https://www.twilio.com/console/chat/services
* For Twilio API Key SID and Twilio API Key Secret, click here: https://www.twilio.com/console/dev-tools/api-keys
* For Outbound calls enable AGENT CONFERENCE setting, click here: https://www.twilio.com/console/voice/conferences/settings
* For outbound calls enable AGENT CONFERENCE setting, click here: https://www.twilio.com/console/voice/conferences/settings

## Terraform Install - Heroku

You can deploy this project with all depencendies on Heroku with Terraform, an open-source infrastructure as code software tool.

Create the API key for Heroku, check the [Heroku Platform API Guide](https://devcenter.heroku.com/articles/platform-api-quickstart) for help.

Add the Heroku API key and your email address to `terraform.tfvars`.

Initialize the Terraform configuration files and run

`terraform init`

If you have not installed Terraform, follow the [Terraform Getting Started](https://learn.hashicorp.com/terraform/getting-started/install.html).

Add the Twilio configuration to the `terraform.tfvars` variables file.

Set your Heroku application name in the infrastructure description file `terraform_heroku.tf`

Create an execution plan

`terraform plan`

Install the project on Heroku by executing

`terraform apply`

After the installation has completed please open `https://<your_application_name>.herokuapp.com/setup` and configure the application. The demo overview will be accessible at `https://<your_application_name>.herokuapp.com`.

## One Click Install - Heroku

This will install the application and all the dependencies on Heroku (login required) for you. As part of the installation, the Heroku app will walk you through configuration of environment variables. Please click on the following button to deploy the application.
This will install the application and all the dependencies on Heroku (login required) for you. As part of the installation, the Heroku app will walk you through configuration of environment variables. Please click on the following button to deploy the application.

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/nash-md/twilio-contact-center)

Expand Down
10 changes: 10 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ var util

if (process.env.DYNO) {
util = require('./util-pg.js')

// check if configuration exists, if not create it
util.validateConfiguration((error) => {
if (error) {
require('./setup-database')
}
})

} else {
util = require('./util-file.js')
}
Expand All @@ -32,6 +40,8 @@ app.use(bodyParser.urlencoded({
extended: true
}))

app.enable('trust proxy')

app.use(function (req, res, next) {

var replaceErrors = function (key, value) {
Expand Down
3 changes: 0 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"image": "heroku/nodejs",
"repository": "https://github.com/nash-md/twilio-contact-center",
"addons": ["heroku-postgresql:hobby-dev"],
"scripts": {
"postdeploy": "node setup-database.js"
},
"success_url": "/setup",
"env": {
"TWILIO_ACCOUNT_SID": {
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "twilio-contact-center",
"description": "A simple omni channel contact center using Twilio WebRTC Client, Video, SMS, Chat and Taskrouter",
"version": "1.10.0",
"version": "1.11.0",
"author": "Matthias Damm",
"contributors": [
{
Expand Down Expand Up @@ -29,19 +29,19 @@
"contact centre"
],
"dependencies": {
"async": "^2.6.1",
"body-parser": "^1.18.2",
"async": "^2.6.3",
"body-parser": "^1.19.0",
"compression": "^1.7.3",
"express": "^4.16.2",
"express-session": "^1.13.0",
"pg": "^7.4.3",
"twilio": "^3.19.2"
"express": "^4.17.1",
"express-session": "^1.17.0",
"pg": "^7.17.0",
"twilio": "^3.39.1"
},
"devDependencies": {
"eslint": "^5.15.3"
},
"engines": {
"node": "8.9.x"
"node": "10.x"
},
"files": [
"README.md",
Expand Down
13 changes: 13 additions & 0 deletions terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
heroku = {
email = ""
api_key = ""
}

twilio = {
account_sid = ""
auth_token = ""
workspace_sid = ""
chat_service_sid = ""
api_key_sid = ""
api_key_secret = ""
}
49 changes: 49 additions & 0 deletions terraform_heroku.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
variable "heroku" {
type = map
default = {
email = ""
api_key = ""
}
}

variable "twilio" {
type = map
default = {
account_sid = ""
auth_token = ""
workspace_sid = ""
chat_service_sid = ""
api_key_sid = ""
api_key_secret = ""
}
}

provider "heroku" {
email = var.heroku.email
api_key = var.heroku.api_key
}

resource "heroku_app" "default" {
name = "<your_application_name>"
region = "eu"
sensitive_config_vars = {
TWILIO_ACCOUNT_SID = var.twilio.account_sid
TWILIO_AUTH_TOKEN = var.twilio.auth_token
TWILIO_WORKSPACE_SID = var.twilio.workspace_sid
TWILIO_CHAT_SERVICE_SID = var.twilio.chat_service_sid
TWILIO_API_KEY_SID = var.twilio.api_key_sid
TWILIO_API_KEY_SECRET = var.twilio.api_key_secret
}
}

resource "heroku_addon" "database" {
app = heroku_app.default.name
plan = "heroku-postgresql:hobby-basic"
}

resource "heroku_build" "contact_center" {
app = heroku_app.default.id
source = {
url = "https://github.com/nash-md/twilio-contact-center/tarball/master"
}
}

0 comments on commit d43af02

Please sign in to comment.