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

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

Output

_14
{
_14
"sid": "FPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_14
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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/FPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_14
"links": {
_14
"plugin_versions": "https://flex-api.twilio.com/v1/PluginService/Plugins/FPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/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

_23
// Download the helper library from https://www.twilio.com/docs/node/install
_23
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_23
_23
// Find your Account SID and Auth Token at twilio.com/console
_23
// and set the environment variables. See http://twil.io/secure
_23
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_23
const authToken = process.env.TWILIO_AUTH_TOKEN;
_23
const client = twilio(accountSid, authToken);
_23
_23
async function createPluginVersion() {
_23
const pluginVersion = await client.flexApi.v1
_23
.plugins("PluginSid")
_23
.pluginVersions.create({
_23
pluginUrl:
_23
"https://default-3254-f021k.twil.io/plugins/plugin-sample/0.0.1/bundle.js",
_23
private: true,
_23
version: "0.0.1",
_23
});
_23
_23
console.log(pluginVersion.sid);
_23
}
_23
_23
createPluginVersion();

Output

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


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

_24
// Download the helper library from https://www.twilio.com/docs/node/install
_24
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_24
_24
// Find your Account SID and Auth Token at twilio.com/console
_24
// and set the environment variables. See http://twil.io/secure
_24
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_24
const authToken = process.env.TWILIO_AUTH_TOKEN;
_24
const client = twilio(accountSid, authToken);
_24
_24
async function createPluginConfiguration() {
_24
const pluginConfiguration =
_24
await client.flexApi.v1.pluginConfigurations.create({
_24
name: "Name",
_24
plugins: [
_24
{
_24
plugin_version: "FV00000000000000000000000000000000",
_24
},
_24
],
_24
});
_24
_24
console.log(pluginConfiguration.sid);
_24
}
_24
_24
createPluginConfiguration();

Output

_12
{
_12
"sid": "FJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_12
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_12
"name": "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/FJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_12
"links": {
_12
"plugins": "https://flex-api.twilio.com/v1/PluginService/Configurations/FJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/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

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function createPluginRelease() {
_18
const pluginRelease = await client.flexApi.v1.pluginReleases.create({
_18
configurationId: "FJ00000000000000000000000000000000",
_18
});
_18
_18
console.log(pluginRelease.sid);
_18
}
_18
_18
createPluginRelease();

Output

_10
{
_10
"sid": "FKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"configuration_sid": "FJaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"date_created": "2020-01-10T20:00:00Z",
_10
"url": "https://flex-api.twilio.com/v1/PluginService/Releases/FKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_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: