Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Releasing Flex plugins with the Plugins API


This document guides you through using the Plugins API to release Flex Plugins to your contact center.


Prerequisites

prerequisites page anchor

You must already have a plugin available and hosted somewhere. You will need its destination URL when creating a PluginVersion. For retrieving the destination URL of a plugin version already hosted, run the following command in the folder of your plugin.

This command will list all the versions of the Plugin you have deployed along with its destination URL.


_10
npm run list

Our guide on configuring your local environment will help you use the Plugin Builder to build a plugin and deploy it using Twilio Assets.


Create a Plugin Resource

create-a-plugin-resource page anchor

For a new plugin, you must first create a Plugin resource. We recommend using the same UniqueName that you used when creating your local plugin directory, such as plugin-sample. This Plugin entity will be used for all subsequent versions of the plugin that you plan to release.

Create a Plugin Resource

create-a-plugin-resource-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = require('twilio')(accountSid, authToken);
_14
_14
client.flexApi.v1.plugins
_14
.create({
_14
friendlyName: 'Sample Plugin',
_14
description: 'My first plugin',
_14
uniqueName: 'plugin-sample'
_14
})
_14
.then(plugin => console.log(plugin.sid));

Output

_14
{
_14
"sid": "FPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14
"unique_name": "plugin-sample",
_14
"friendly_name": "Sample Plugin",
_14
"description": "My first plugin",
_14
"archived": false,
_14
"date_created": "2020-01-10T20:00:00Z",
_14
"date_updated": "2020-01-10T20:00:00Z",
_14
"url": "https://flex-api.twilio.com/v1/PluginService/Plugins/FPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_14
"links": {
_14
"plugin_versions": "https://flex-api.twilio.com/v1/PluginService/Plugins/FPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Versions"
_14
}
_14
}


Now, you can create a Version resource to indicate which version of the Plugin that you want to use in Flex. Use version 0.0.1, since that's the version of the deployed Sample Plugin.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_15
// Download the helper library from https://www.twilio.com/docs/node/install
_15
// Find your Account SID and Auth Token at twilio.com/console
_15
// and set the environment variables. See http://twil.io/secure
_15
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_15
const authToken = process.env.TWILIO_AUTH_TOKEN;
_15
const client = require('twilio')(accountSid, authToken);
_15
_15
client.flexApi.v1.plugins('FPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_15
.pluginVersions
_15
.create({
_15
private: true,
_15
version: '0.0.1',
_15
pluginUrl: 'https://default-3254-f021k.twil.io/plugins/plugin-sample/0.0.1/bundle.js'
_15
})
_15
.then(plugin_versions => console.log(plugin_versions.sid));

Output

_12
{
_12
"sid": "FVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12
"plugin_sid": "FPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12
"version": "0.0.1",
_12
"plugin_url": "https://default-3254-f021k.twil.io/plugins/plugin-sample/0.0.1/bundle.js",
_12
"changelog": "the changelog",
_12
"private": true,
_12
"archived": false,
_12
"date_created": "2020-01-10T20:00:00Z",
_12
"url": "https://flex-api.twilio.com/v1/PluginService/Plugins/FPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Versions/FVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_12
}


Create a Plugin Configuration

create-a-plugin-configuration page anchor

You now have a Plugin with a Version. You can prepare to load it into Flex by including the returned Version SID in a Configuration. The Configuration describes all of the Plugins that we'll eventually want to release to Flex.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_13
// Download the helper library from https://www.twilio.com/docs/node/install
_13
// Find your Account SID and Auth Token at twilio.com/console
_13
// and set the environment variables. See http://twil.io/secure
_13
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_13
const authToken = process.env.TWILIO_AUTH_TOKEN;
_13
const client = require('twilio')(accountSid, authToken);
_13
_13
client.flexApi.v1.pluginConfigurations
_13
.create({
_13
plugins: [{'plugin_version': 'FV00000000000000000000000000000000'}],
_13
name: 'name'
_13
})
_13
.then(plugin_configuration => console.log(plugin_configuration.sid));

Output

_12
{
_12
"sid": "FJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12
"name": "some name",
_12
"description": "description",
_12
"archived": false,
_12
"date_created": "2020-01-10T20:00:00Z",
_12
"url": "https://flex-api.twilio.com/v1/PluginService/Configurations/FJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_12
"links": {
_12
"plugins": "https://flex-api.twilio.com/v1/PluginService/Configurations/FJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Plugins"
_12
}
_12
}


Release the Configuration

release-the-configuration page anchor

For our purposes we're only deploying one plugin, but you could include many plugins in a single configuration. Once your configuration includes all of your plugins at the correct version, you can create a new Release.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_12
// Download the helper library from https://www.twilio.com/docs/node/install
_12
// Find your Account SID and Auth Token at twilio.com/console
_12
// and set the environment variables. See http://twil.io/secure
_12
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12
const authToken = process.env.TWILIO_AUTH_TOKEN;
_12
const client = require('twilio')(accountSid, authToken);
_12
_12
client.flexApi.v1.pluginReleases
_12
.create({
_12
configurationId: 'FJ00000000000000000000000000000000'
_12
})
_12
.then(plugin_release => console.log(plugin_release.sid));

Output

_10
{
_10
"sid": "FKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"configuration_sid": "FJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_10
"date_created": "2020-01-10T20:00:00Z",
_10
"url": "https://flex-api.twilio.com/v1/PluginService/Releases/FKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_10
}

Congratulations - your Plugin(s) should now be deployed!

You can confirm whether your plugin is enabled by logging into your Flex instance, navigating to the Developer Setup Page(link takes you to an external page) and seeing it listed under the Installed Plugins section. Or, just start playing around with the new Configuration in the Flex UI to see all of the Plugins you configured at work!



Rate this page: