Deploy via CLI
Pre-requisites
- Twilio Flex Account (Guide)
- Node.js v16.x.x only (Guide)
- Typescript v.5.1.6 or above (Guide)
- Twilio CLI v5.8.1 or above (Guide)
- Twilio CLI Serverless Plugin v3.1.3 or above (Guide)
Instructions
On your computer, open up your preferred terminal and clone this repository
// Clone Project
git clone https://github.com/leroychan/twilio-flex-conversations-adapters.git
// Change to working directory
cd twilio-flex-conversations-adapters/serverless-functions
// Install NPM Packages
npm install
// Copy sample enviroment file
cp .env.example .env
For each custom channel that you would like to enable, it is recommended that you create 1 Studio per custom channel (Guide).
- You will need to have the Studio Flow SID (starting with
FWxxxxxxxxx
) of each custom channel that you would like to enable. - For channels that you do not want to enable, you do not need to create the Studio Flow.
- You will need to have the Studio Flow SID (starting with
For each custom channel that you would like to enable, perform the necessary setup and obtain the required values. The required variables per custom channel can be found in the Channels Overview page.
Configure the
.env
file using your preferred code editor with all the required values obtained previously. You can leaveACCOUNT_SID=xxx
andAUTH_TOKEN=xxx
empty as it will be populated by default during run time. Before you deploy, ensure thattwilio profiles:list
has an active account set.- Required variables per custom channel that you want to enable
- Example: To enable only LINE, you would need the following variables:
LINE_STUDIO_FLOW_SID=FWxxxx
LINE_CHANNEL_ID=xxxx
LINE_CHANNEL_SECRET=xxxx
LINE_CHANNEL_ACCESS_TOKEN=xxxx
- Example: To enable both LINE and Viber, you would need the following variables:
LINE_STUDIO_FLOW_SID=FWxxxx
LINE_CHANNEL_ID=xxxx
LINE_CHANNEL_SECRET=xxxx
LINE_CHANNEL_ACCESS_TOKEN=xxxx
VIBER_STUDIO_FLOW_SID=FWxxxxxx
VIBER_AUTH_TOKEN=xxxx
- Example: To enable only LINE, you would need the following variables:
- Required variables per custom channel that you want to enable
Once configured and you are ready to deploy it, go back to your terminal and issue the following command:
npm run deploy
Within Twilio Console, on the left hand side menu bar, navigate to
Functions and Assets > Services
. Look fortwilio-flex-conversations-adapters
and click onService Details
. UnderEnvironments > Domain
, take note of the domain URL.- The domain URL should be in the format of
twilio-flex-conversations-adapters-<RANDOMNUMBER>-dev.twil.io
.
- The domain URL should be in the format of
We will need the respective custom channels
incoming
webhook URL that is in the format ofhttps://twilio-flex-conversations-adapters-<RANDOMNUMBER>-dev.twil.io/api/<CHANNEL>/incoming
- Example:
LINE
:https://twilio-flex-conversations-adapters-<RANDOMNUMBER>-dev.twil.io/api/line/incoming
Viber
:https://twilio-flex-conversations-adapters-<RANDOMNUMBER>-dev.twil.io/api/viber/incoming
- Example:
Configure each custom channel's webhook setting in their respective consoles with the
incoming
webhook URL in the previous step. Refer to the respective documentation page underChannels
for exact instructions.You have now completed the setup. Proceed to test the integration by logging into your Flex Agent console and put yourself as
Available
. Send a test message to your custom channnel and it should appear in your Flex Agent console.[Optional] In order to have the icons of their respective custom channel displayed in Flex agent interface, you will need to deploy the Converasations Icons Plugin, perform the following on your CLI:
cd ..
cd plugin-conversations-icons
npm run deploy
npm run release