Built using:
If you don't already have access to SQL Server, you can install one locally for development and testing.
Download and install SQL Server Developer Edition.
- Install Docker
- Run the following in a terminal. Change the values of
container_name
andSA_PASSWORD=P@***55w0rd***
to what you desire.
docker pull microsoft/mssql-server-linux:2017-latest
docker run -d --name container_name -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=P@***55w0rd***' -e 'MSSQL_PID=Developer' -p 1433:1433 microsoft/mssql-server-linux:2017-latest
Make sure you have Node.js as well as npm
. We support Node >= 10.12 (and recommend the even versions of Node).
- Clone this repository (or download and extract the zip file)
- Open a command prompt or terminal
- Change to the directory
server\api
- Run
npm install
to install all the dependencies - Copy
.env.sample
to.env
, and modify the settings to match your environment
# SQL Server connection
SQL_USER=
SQL_PASSWORD=
SQL_DATABASE=
SQL_SERVER=
SQL_ENCRYPT=false
# TWILIO
ACCOUNT_SID=AC...
AUTH_TOKEN=
WORKSPACE_SID=WS...
You will need a SQL database to for this application. If you are running SQL Server locally and don't already have a database, you can create one with the following script. You can use a utility like Azure Data Studio to connect to your instance to run this script.
USE master;
GO
CREATE DATABASE CallbackScheduler; -- change this to whatever database name you desire
GO
Next you can run the following task at the command line or terminal to initialize your database.
Note: Make sure you have the correct server, database, user, and password configured in your
.env
file.
node tasks/initializedb.js
- Change directory to
server/api
- Run
npm start
to start the development server. (Note: The default PORT=3000. A custom PORT can be specified in .env file) - Open new Terminal window and run
ngrok http http://localhost:3000
. Note the Forwarding ngrok URL/sub-domain returned. We will require this for setting up Event Streams Webhook sink.
- Create a new Event Streams sink, type webhook.
- Enter ngrok domain
https://<subdomain>.ngrok.io/events
- Create event streams subscription for taskrouter (v2) events
- reservation.accepted
- Create the "ScheduledCallback" workflow
- Navigate to the workflow section in TaskRouter section of console
- Click + to add a new workflow
- Workflow name set to
ScheduledCallback
- Add a filter
Known Agent with fall back to Everyone queue
- Click create a new filter
- Click unamed filter to rename to
Known Agent with fall back to Everyone queue
- Matching Tasks =
type == 'callback' && callback.routeToQueue == 'true'
- Task Queue =
Everyone
- Skip timeout =
workers.available == 0
- Timeout =
3600
- Known Worker, Select the radio button
Worker SID
, then enter the following expressiontask.callback.workerSid
- Within the direct call to agent click
Add a Step
- In the second step, Task Queue =
Everyone
, All other setting can stay default
- Change directory to
server/service
. - Run
npm install
to install all the dependencies - Copy
.env.sample
to.env
, and modify the settings to match your environment
# SQL Server connection
SQL_USER=
SQL_PASSWORD=
SQL_DATABASE=
SQL_SERVER=
SQL_ENCRYPT=false
# TWILIO
ACCOUNT_SID=AC...
AUTH_TOKEN=
WORKSPACE_SID=WS...
CALLBACK_WORKFLOW_SID=WW... # workflow sid created in the previous step
- Run
node cron-callback-schedule.js