Twilio Flex-connector

Verbind je Twilio Flex-contactcenter met Brevo voor uniforme klantinteractiehistorie, marketingflows na gesprekken en support-gedreven engagement-analytics via Tajo.

Overzicht

EigenschapWaarde
PlatformTwilio Flex
CategorieCustom
SetupcomplexiteitGeavanceerd
Officiële integratieNee
Gesynchroniseerde dataKlanten, Conversaties, Events
Gebruikte API’sFlex API, Conversations API, TaskRouter API
AuthenticatieAccount SID + Auth Token / API Key
Base URLhttps://flex-api.twilio.com

Functies

  • Conversatiesynchronisatie - Stuur voice-, SMS-, WhatsApp- en chat-interacties door naar Brevo-tijdlijnen
  • Klantprofielverrijking - Synchroniseer Flex-klantdata naar Brevo-contactattributen
  • Post-interactie-campagnes - Trigger Brevo-workflows nadat supportgesprekken eindigen
  • CSAT-event-tracking - Synchroniseer resultaten van tevredenheidsonderzoeken als Brevo-events
  • Agent-activiteitsdata - Volg agent-prestatiemetrics voor operationele rapportage
  • Wachtrij-analytics - Stuur wachttijd- en abandonmentdata door voor experience-optimalisatie

Vereisten

Voordat je begint, zorg dat je beschikt over:

  1. Een Twilio-account met Flex ingeschakeld
  2. Je Twilio Account SID en Auth Token
  3. Een Flex-instantie met actieve kanalen (voice, SMS, chat of WhatsApp)
  4. Geconfigureerde TaskRouter-workspace
  5. Een Brevo-account met API-toegang
  6. Een Tajo-account met een actief abonnement

Authenticatie

Twilio Flex gebruikt Twilio’s standaardauthenticatiemethoden.

Accountcredentials

Terminal window
# Basic Auth: Account SID as username, Auth Token as password
curl -X GET "https://flex-api.twilio.com/v1/Configuration" \
-u "$TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN"

API Key (aanbevolen voor productie)

  1. Ga naar Twilio Console > Account > API keys & tokens
  2. Klik op Create API Key
  3. Selecteer keytype Standard
  4. Bewaar de SID en Secret veilig
Terminal window
curl -X GET "https://flex-api.twilio.com/v1/Configuration" \
-u "$TWILIO_API_KEY_SID:$TWILIO_API_KEY_SECRET"

Auth Token vs API Key

Je Auth Token heeft volledige accounttoegang. Gebruik voor productie scoped API Keys. API Keys kunnen individueel worden ingetrokken zonder andere integraties te verstoren.

Verbinden met Tajo

Terminal window
tajo connectors install twilio-flex \
--account-sid $TWILIO_ACCOUNT_SID \
--auth-token $TWILIO_AUTH_TOKEN \
--flex-flow-sid $TWILIO_FLEX_FLOW_SID

Configuratie

Basisinstelling

connectors:
twilio_flex:
enabled: true
account_sid: "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
flex_flow_sid: "FOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
sync:
conversations: true
tasks: true
customers: true
csat: true
agent_activity: false
lists:
support_contacts: 32
csat_respondents: 33
channels:
- voice
- sms
- whatsapp
- webchat

Veldmapping

Map Flex-klant- en interactiedata naar Brevo-attributen:

field_mapping:
# Customer fields
identity: FLEX_IDENTITY
friendly_name: FIRSTNAME
attributes.email: email
attributes.phone: SMS
# Interaction metrics
last_conversation_date: LAST_SUPPORT_DATE
total_conversations: SUPPORT_TICKET_COUNT
avg_wait_time: AVG_WAIT_TIME
last_csat_score: CSAT_SCORE
preferred_channel: PREFERRED_CHANNEL
# Custom attributes
customer_tier: VIP_TIER
account_id: ACCOUNT_ID

Eventmapping

event_mapping:
task.created: SUPPORT_REQUESTED
task.completed: SUPPORT_RESOLVED
task.canceled: SUPPORT_ABANDONED
conversation.ended: CONVERSATION_ENDED
survey.completed: CSAT_SUBMITTED

API-endpoints

Tajo integreert met de volgende Twilio Flex- en gerelateerde API-endpoints:

EndpointMethodAPIDoel
/v1/ConfigurationGETFlexFlex-configuratie ophalen
/v1/InteractionsGETFlexInteracties opvragen
/v1/ChannelsGETFlexFlex-kanalen opvragen
/v1/WebChannelsPOSTFlexWebchat-kanaal aanmaken
/v1/ConversationsGETConversationsConversaties opvragen
/v1/Conversations/{sid}/MessagesGETConversationsBerichten van conversatie opvragen
/v1/Conversations/{sid}/ParticipantsGETConversationsDeelnemers opvragen
/v1/Workspaces/{sid}/TasksGETTaskRouterTasks opvragen
/v1/Workspaces/{sid}/WorkersGETTaskRouterWorkers (agents) opvragen
/v1/Workspaces/{sid}/TaskQueuesGETTaskRouterTask queues opvragen
/v1/Workspaces/{sid}/EventsGETTaskRouterWorkspace-events opvragen

Codevoorbeelden

Connector initialiseren

import { TajoClient } from '@tajo/sdk';
const tajo = new TajoClient({
apiKey: process.env.TAJO_API_KEY,
brevoApiKey: process.env.BREVO_API_KEY
});
await tajo.connectors.connect('twilio-flex', {
accountSid: process.env.TWILIO_ACCOUNT_SID,
authToken: process.env.TWILIO_AUTH_TOKEN,
flexFlowSid: process.env.TWILIO_FLEX_FLOW_SID
});

Conversatiehistorie synchroniseren

await tajo.connectors.sync('twilio-flex', {
type: 'incremental',
resources: ['conversations'],
since: '2024-01-01',
channels: ['voice', 'sms', 'whatsapp']
});
const status = await tajo.connectors.status('twilio-flex');
console.log(status);
// {
// connected: true,
// lastSync: '2024-03-15T16:00:00Z',
// conversationsTracked: 12400,
// customersLinked: 8900,
// agentsMonitored: 45
// }

Trigger voor post-conversatie-campagne

// Trigger a Brevo follow-up after a support conversation ends
app.post('/webhooks/flex/task-complete', async (req, res) => {
const task = req.body;
await tajo.connectors.handleEvent('twilio-flex', {
type: 'task.completed',
payload: {
taskSid: task.TaskSid,
customerEmail: task.TaskAttributes?.email,
channel: task.TaskChannelUniqueName,
duration: task.Age,
queueName: task.TaskQueueFriendlyName
}
});
res.status(200).send('OK');
});

Flex Plugin-integratie

// Inside a Flex UI Plugin - send data to Tajo
import { FlexPlugin } from '@twilio/flex-plugin';
class TajoPlugin extends FlexPlugin {
init(flex, manager) {
flex.Actions.addListener('afterCompleteTask', async (payload) => {
await fetch('https://api.tajo.io/webhooks/flex/task-complete', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
TaskSid: payload.task.sid,
TaskAttributes: payload.task.attributes,
TaskChannelUniqueName: payload.task.taskChannelUniqueName,
Age: payload.task.age
})
});
});
}
}

Rate limits

Twilio hanteert rate limits over zijn API’s:

APIRate limitOpmerkingen
Flex API100 requests/secondePer account
Conversations API100 requests/secondePer account
TaskRouter API30 lees-requests/secondePer workspace
TaskRouter Events20 requests/secondePer workspace

Event Streams

Voor eventverwerking met hoog volume kun je beter Twilio Event Streams gebruiken in plaats van het pollen van TaskRouter-events. Event Streams pushen events realtime via webhooks of Kinesis.

Probleemoplossing

Veelvoorkomende problemen

ProbleemOorzaakOplossing
401 UnauthorizedOngeldige SID of tokenVerifieer Account SID en Auth Token in Twilio Console
403 ForbiddenFlex niet ingeschakeldZorg dat Flex is geactiveerd op je Twilio-account
Conversaties ontbrekenVerkeerde datumrangeVerbreed de sync-datumrange of controleer conversatiestatus
Tasks niet getracktTaskRouter workspace-mismatchVerifieer de juiste workspace SID
Plugin vuurt nietEvent listener niet geregistreerdControleer of Flex-plugin gedeployed en actief is

Debugmodus

connectors:
twilio_flex:
debug: true
log_level: verbose
log_api_calls: true

Verbinding testen

Terminal window
tajo connectors test twilio-flex
# ✓ Flex API connection successful
# ✓ Conversations API accessible
# ✓ TaskRouter workspace found
# ✓ Agent list readable
# ✓ Queue configuration loaded

Best practices

  1. Gebruik API Keys boven Auth Tokens - API Keys kunnen worden gescoped en individueel ingetrokken
  2. Maak gebruik van Event Streams - Push-gebaseerde events zijn efficiënter dan het pollen van TaskRouter
  3. Bouw een Flex Plugin - Gebruik een UI-plugin om task-completion-events realtime vast te leggen
  4. Map kanalen consistent - Normaliseer voice-, SMS- en chatdata naar uniforme Brevo-events
  5. Volg CSAT-scores - Synchroniseer tevredenheidsdata naar Brevo voor experience-gedreven segmentatie
  6. Monitor wachtrijmetrics - Gebruik wachttijddata om proactieve klantcommunicatie te triggeren

Beveiliging

  • Account SID + Auth Token - Standaard Twilio-authenticatie
  • API Keys - Intrekbare, niet-root credentials voor productiegebruik
  • Alleen HTTPS - Alle API-communicatie versleuteld via TLS 1.2+
  • Webhook-validatie - Verifieer Twilio-webhook-signatures met X-Twilio-Signature
  • PCI-compliance - Twilio Flex is PCI DSS Level 1-compliant
  • Versleutelde opslag - Credentials versleuteld in rust binnen Tajo

Gerelateerde bronnen

Subscribe to updates

developer-docs

Drop your email or phone number — we'll send you what matters next.

auto-detect
AI-assistent

Hallo! Stel me vragen over de documentatie.