twilio-taskrouter-routing
БесплатноБез исполняемых скриптовНе проверенRoute tasks to agents using Twilio TaskRouter. Covers Workers, Task Queues, Workflows, Reservations, skills-based routing, and common gotchas (hyphen…
от openai★ 8 494 звезды на GitHubОб этом скилле
Overview
TaskRouter is Twilio's skills-based routing engine. Instead of building custom queuing logic, you define Workers (agents), Task Queues (groups), and Workflows (routing rules). TaskRouter matches incoming tasks to the best available worker.
Incoming Task → Workflow (routing rules) → Task Queue (skill match) → Worker (agent)
↓
Reservation
(accept/reject)
Common mistake: Developers reinvent TaskRouter in custom Node.js — don't. If you're building skills-based routing, queue management, or agent assignment, use TaskRouter.
Prerequisites
- Twilio account — see
twilio-account-setup TWILIO_ACCOUNT_SIDandTWILIO_AUTH_TOKEN— seetwilio-iam-auth-setup- SDK:
pip install twilio/npm install twilio - For voice routing: a Twilio phone number with webhook configured — see
twilio-voice-twiml - For AI escalation: ConversationRelay with escalation tools — see
twilio-voice-conversation-relay
Quickstart
Step 1 — Create a Workspace
A Workspace is the top-level container for all TaskRouter resources.
Python
import os
from twilio.rest import Client
client = Client(os.environ["TWILIO_ACCOUNT_SID"], os.environ["TWILIO_AUTH_TOKEN"])
workspace = client.taskrouter.v1.workspaces.create(
friendly_name="Support Center",
event_callback_url="https://yourapp.com/taskrouter-events"
)
workspace_sid = workspace.sid # WSxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
print(workspace_sid)
Node.js
const twilio = require("twilio");
const client = twilio(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);
const workspace = await client.taskrouter.v1.workspaces.create({
friendlyName: "Support Center",
eventCallbackUrl: "https://yourapp.com/taskrouter-events",
});
const workspaceSid = workspace.sid;
Step 2 — Create Activities (agent states)
Python
# Available — worker can receive tasks
available = client.taskrouter.v1.workspaces(workspace_sid).activities.create(
friendly_name="Available", available=True
)
# Offline — worker cannot receive tasks
offline = client.taskrouter.v1.workspaces(workspace_sid).activities.create(
friendly_name="Offline", available=False
)
# On a task — worker is busy
on_task = client.taskrouter.v1.workspaces(workspace_sid).activities.create(
friendly_name="On Task", available=False
)
Step 3 — Create Workers (agents)
Security: Always use
json.dumps()(Python) orJSON.stringify()(Node.js) to construct attribute payloads. String interpolation is vulnerable to JSON injection.
Python
worker = client.taskrouter.v1.workspaces(workspace_sid).workers.create(
friendly_name="Alice",
attributes='{"skills": ["billing", "technical"], "languages": ["en", "es"], "department": "support"}'
)
Node.js
const worker = await client.taskrouter.v1.workspaces(workspaceSid).workers.create({
friendlyName: "Alice",
attributes: JSON.stringify({
skills: ["billing", "technical"],
languages: ["en", "es"],
department: "support",
}),
});
Step 4 — Create Task Queues
Python
# Billing queue — matches workers with "billing" skill
billing_queue = client.taskrouter.v1.workspaces(workspace_sid).task_queues.create(
friendly_name="Billing",
target_workers='skills HAS "billing"'
)
# Technical queue
tech_queue = client.taskrouter.v1.workspaces(workspace_sid).task_queues.create(
friendly_name="Technical",
target_workers='skills HAS "technical"'
)
# Catch-all queue
default_queue = client.taskrouter.v1.workspaces(workspace_sid).task_queues.create(
friendly_name="Default",
target_workers='1==1' # matches all workers
)
Step 5 — Create a Workflow (routing rules)
Python
import json
workflow_config = {
"task_routing": {
"filters": [
{
"filter_friendly_name": "Billing",
"expression": "department == 'billing'",
"targets": [
{"queue": billing_queue.sid, "timeout": 120}
]
},
{
"filter_friendly_name": "Technical",
"expression": "department == 'technical'",
"targets": [
{"queue": tech_queue.sid, "timeout": 120}
]
}
],
"default_filter": {
"queue": default_queue.sid
}
}
}
workflow = client.taskrouter.v1.workspaces(workspace_sid).workflows.create(
friendly_name="Support Routing",
configuration=json.dumps(workflow_config),
assignment_callback_url="https://yourapp.com/assignment"
)
Step 6 — Create a Task (from an incoming call)
Python
task = client.taskrouter.v
Установить twilio-taskrouter-routing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл twilio-taskrouter-routing?
Route tasks to agents using Twilio TaskRouter. Covers Workers, Task Queues, Workflows, Reservations, skills-based routing, and common gotchas (hyphen attributes, HAS operator, reservation cascade). Use this skill for any multi-agent contact center, support queue, or AI agent escalation routing.
Как установить скилл twilio-taskrouter-routing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл twilio-taskrouter-routing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic