Twilio SMS — TwilioConnector

The sms_send step type sends an SMS to a recipient number using Twilio's Messaging API. Authentication uses HTTP Basic auth (Account SID as username, Auth Token as password). The message body is a template string containing {{case.*}} and {{user.*}} variable substitutions, resolved at send time from live case data.

The recipient number is derived from a configured case data field (e.g., case.data.customer_phone) or can be set as a static value in the connector config. All sent messages are stored in the sms_messages table with Twilio SID, delivery status, and timestamp.

Slack Notifications — SlackConnector

The slack_notify step type posts a message to a Slack channel via Incoming Webhook URL. Slack's native markdown is supported in the message body — bold (*text*), code blocks (```text```), and links (<URL|label>). The webhook URL determines which channel receives the message, so different SlackConnector instances route to different channels.

Webhook URLs are stored encrypted in the connector record. All sent notifications are logged in slack_notifications. There is no delivery receipt (Slack Incoming Webhooks are fire-and-forget at the HTTP layer), but a 2xx response from Slack confirms the message was accepted.

Per-channel routing: Configure one SlackConnector instance per channel. For example, create SlackConnector-Legal pointing to #legal-cases and SlackConnector-Finance pointing to #finance-ops. Each connector instance stores its own webhook URL. When adding a slack_notify step, choose the appropriate connector instance.

Step Types

Step Type Connector Work Center Panel Panel Contents Auto-Advance Trigger
sms_send TwilioConnector SMS Panel 📱 Recipient number (resolved from case field), message preview with substitutions rendered, Send SMS button, delivery status badge Twilio API returns HTTP 201 (message accepted)
slack_notify SlackConnector Slack Panel 💬 Channel name (from connector), message preview with substitutions rendered, Send to Slack button, delivery status badge Slack Incoming Webhook returns HTTP 200

Message Template Variables

Both sms_send and slack_notify message templates support the following variable substitutions. Variables are resolved at send time from live case data and the sending user's profile.

Variable Resolves to Example output
{{case.ref}} Case reference number REF-2024-0087
{{case.title}} Case title Home Insurance Claim — J. Smith
{{case.status}} Current case status In Progress
{{case.stage}} Current stage name Document Review
{{case.data.FIELD}} Any case data field by name {{case.data.claim_amount}} > £15,000
{{user.name}} Full name of the sending agent Alice Okafor
{{user.email}} Email address of the sending agent alice.okafor@firm.com

Example SMS template:

Hi, your case {{case.ref}} ({{case.title}}) has moved to the
{{case.stage}} stage. Your case handler is {{user.name}}.
For queries contact {{user.email}}.

Example Slack template with Slack markdown:

*New case ready for review*
Case: `{{case.ref}}` — {{case.title}}
Stage: {{case.stage}} | Status: {{case.status}}
Assigned agent: {{user.name}}
<https://your-domain.com/agent/cases/{{case.id}}|Open in Velaris>

Twilio Configuration

  1. Get Twilio credentials. Log in to the Twilio Console. From the dashboard, copy your Account SID and Auth Token. Navigate to Phone Numbers > Manage > Active Numbers and copy the phone number you want to send from (E.164 format, e.g., +441234567890).

  2. Set environment variables. Add the following and restart the case-service:

    TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    TWILIO_AUTH_TOKEN=your_auth_token
    TWILIO_FROM_NUMBER=+441234567890
  3. Add the connector in Studio. Navigate to Studio > HxConnect > SMS and click Add Connector. Configure:

    • Account SID: {{env.TWILIO_ACCOUNT_SID}}
    • Auth Token: {{env.TWILIO_AUTH_TOKEN}}
    • From Number: {{env.TWILIO_FROM_NUMBER}}
    • Recipient Field: e.g., case.data.customer_phone
    • Message Template: your template string with {{case.*}} vars

Slack Configuration

  1. Create a Slack App with Incoming Webhooks. Go to api.slack.com/apps > Create New App > From scratch. Under Features > Incoming Webhooks, toggle Incoming Webhooks on. Click Add New Webhook to Workspace, select the target channel, and authorise. Copy the webhook URL (format: https://hooks.slack.com/services/T.../B.../...).

  2. Repeat for each channel. Each channel requires a separate webhook URL. You can use the same Slack App or create separate apps per channel.

  3. Add a connector instance per channel in Studio. Navigate to Studio > HxConnect > Slack and click Add Connector for each channel. The webhook URL is stored encrypted in the connector record — it does not need an environment variable, though you may use {{env.SLACK_WEBHOOK_LEGAL}} if you prefer centralised secret management.

API Reference

Method Endpoint Description Auth
POST /api/comms/sms/cases/{id}/send Sends an SMS for the case using the linked TwilioConnector. Resolves template variables and sends via Twilio API. Returns Twilio SID and status. JWT
POST /api/comms/slack/cases/{id}/send Posts a Slack notification for the case using the linked SlackConnector. Returns HTTP status from Slack. JWT
GET /api/comms/sms/messages Lists all SMS messages from sms_messages. Supports ?case_id=, ?status= filters. Returns Twilio SID, recipient, status, timestamp. JWT (Admin/Manager)
GET /api/comms/slack/notifications Lists all Slack notifications from slack_notifications. Supports ?case_id=, ?connector_id= filters. JWT (Admin/Manager)

Example: Send an SMS via API

curl -s -X POST https://your-domain.com/api/comms/sms/cases/c_01HZ.../send \
  -H "Authorization: Bearer $VELARIS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "connector_id": "conn_twilio_01",
    "override_message": "Your case {{case.ref}} requires your attention. Please log in to the portal."
  }'

Omit override_message to use the template configured on the connector. The override_message field also supports {{case.*}} substitutions.

Planned Extensions

The following communications channels are planned for a future release (P51b) and are not yet available:
  • WhatsApp — via Twilio WhatsApp Business API, same template variable system
  • Twilio Voice — outbound call scheduling with text-to-speech script templates
  • Microsoft Teams — Teams Incoming Webhook, equivalent to SlackConnector
  • Jira — issue creation and status sync as a case step type
These connectors are deferred to P51b. Do not implement workarounds via HttpCustomConnector for Teams or Jira — native connectors with full audit trail support are on the roadmap.