Twilio setup (advanced: use your own account)

Most people do not need this page. The default way to get a phone line is a Mishu number: sign in, choose a plan, verify your phone and pick a number in the app (or run mishu cloud numbers setup). Use this guide only if you want your own Twilio account.

This is a generic, placeholder-only guide for connecting a fork of Mishu (working name) to your Twilio account. The in-app wizard is the supported path. It provisions routing on that account; you stay on the hook for Twilio charges, TCPA (and analogous local rules), recording-consent law, and carrier acceptable use.

Do not paste Account SIDs, auth tokens, API secrets, live numbers, or Function hostnames into issues, docs, or screenshots. Examples below are placeholders: Account SID AC…, API key SK…, Functions Service ZS…, TwiML App AP…, number +1 (555) 01x-xxxx.

#Use the in-app wizard

From the Welcome screen choose Advanced: use your own Twilio account (or, when giving a Mishu a phone number, the Advanced: use my Twilio account tab).

  1. Paste Account SID, API Key SID, and API Key Secret. Prefer an API key over putting the Account Auth Token in the desktop app. Connect Twilio account checks the account over Twilio's REST API, then stores the secret in the main process (twilio-settings.json, mode 0600). The secret is never returned over IPC.
  2. Choose a Voice-capable number already on the account, or Find numbers by a 3-digit US area code. Search is read-only until you confirm a purchase. The list is US local numbers with Voice enabled.
  3. Connect this number first shows a preview of every action (and its cost label). Nothing is bought, deployed, or re-routed until you confirm those actions one at a time.

If the account already has this call-routing app, the wizard warns Will replace the call-routing app and lists Function paths plus the number's current Voice URL. Keep my current routing saves the credentials and number locally and does not deploy Functions or change Twilio routing. Re-running a full connect is idempotent: the Service, Functions, Environment, and TwiML App are reused by fixed names from app identity.

Settings → Phone line remains available afterward if you need to inspect the saved TwiML App SID, number, or client name.

#What the wizard deploys

After you confirm, provisioning follows this order. A failure reports the step name in the UI; Retry resumes from the last completed step.

  1. Validate credentials — GET the account resource.
  2. Reuse or create a Serverless Service — unique/friendly name mishu in official public builds.
  3. Reuse or create Functions — friendly names voice-incoming, voice-incoming-fallback and voice-outgoing.
  4. Upload Function versions — paths /voice-incoming, /voice-incoming-fallback and /voice-outgoing, visibility protected. If the desktop does not answer within 25 seconds (app closed, Mac asleep, busy), /voice-incoming-fallback plays a short English message and records a voicemail that stays in Twilio; /voice-outgoing adds a server-side timeLimit (1800 s by default, optional MAX_CALL_DURATION_SEC). The Build copies the Service's current Node runtime, or omits Runtime so Twilio applies its platform default. Retired runtimes such as node18 are never sent.
  5. Create a Build of those versions and wait until Twilio marks it completed.
  6. Reuse or create an Environment — unique name ui, domain suffix ui.
  7. Create a Deployment of that Build onto the Environment.
  8. Reuse or create a TwiML App — friendly name Mishu in official public builds. Its Voice request URL is https://{environment-domain}/voice-outgoing (POST).
  9. Buy the number only when you confirmed a purchase and the number is not already in the account. Otherwise the existing Incoming Phone Number SID is reused.
  10. Point the number at Mishu — the number's Voice URL becomes https://{environment-domain}/voice-incoming (POST). The wizard then writes the two Environment variables below.
  11. Save local settings — TwiML App SID, E.164 number, and Voice SDK client identity on this Mac.

Incoming TwiML dials the Voice SDK client and passes calledNumber. Outgoing TwiML dials with answerOnBridge: true and uses PHONE_NUMBER as caller ID.

A fork that changes app identity will see those Service / TwiML App / client names change with it. Do not assume a hostname; look up the Environment domain in Console.

#What it costs

The wizard previews charges before it calls Twilio to buy, deploy, or re-route. Confirm tokens:

ConfirmWhat it allowsCost label you will see
replace-existing-routingRedeploy the same-named Functions Service / TwiML App, or overwrite a number that already has a Voice URLReplaces existing routing
buy-numberIncomingPhoneNumbers.createTwilio's US local current_price as $… / month, or see Twilio pricing if the Pricing API is unavailable
deploy-functionsCreate or reuse the Serverless Service, Functions, Build, Environment, Deployment, and TwiML AppTwilio Functions usage
update-number-routingPoint the number's Voice URL at /voice-incomingNo extra number fee

Twilio then bills voice minutes on that number to your account (inbound and outbound). Mishu does not meter the account. GPT-Live API voice, if you choose that source, is billed per second by OpenAI. The Codex app-server (optional local adapter) uses a local Codex CLI login instead of that per-second API.

Keep my current routing and choosing an already-owned number do not buy a number. Missing any required confirm is rejected; the wizard does not fail open into a paid step.

#CLIENT_IDENTITY and PHONE_NUMBER

These are Twilio Functions Environment variables on the ui Environment. The wizard upserts them; you do not set them by hand unless you are debugging.

VariableWhat it isIf it is missing
CLIENT_IDENTITYVoice SDK client identity that /voice-incoming dials. Official public builds use mishu. Must match the identity the desktop uses to register.Incoming TwiML still dials the desktop's default identity. The caller is not hung up.
PHONE_NUMBERE.164 caller ID for /voice-outgoing.Outbound TwiML dials with an empty callerId. Fix the variable rather than editing Function source.

A blank CLIENT_IDENTITY is treated the same as missing. Matching identity still matters: a fallback that does not match the running desktop will ring nobody.

#What you should see in Twilio Console

After a successful connect (not Keep my current routing), open the same account and confirm:

ResourceWhereWhat to look for
Functions ServiceFunctions and Assets → ServicesUnique name mishu (placeholder SID ZS…)
Incoming Functionthat Service → FunctionsPath /voice-incoming, protected
Outgoing Functionthat Service → FunctionsPath /voice-outgoing, protected
Environmentthat Service → EnvironmentsUnique name ui; variables CLIENT_IDENTITY and PHONE_NUMBER
TwiML AppVoice → TwiML → TwiML AppsFriendly name Mishu (placeholder SID AP…); Voice URL ends with /voice-outgoing
Phone numberPhone Numbers → Manage → Active numbersYour number's Voice URL ends with /voice-incoming, method POST

Exact Function hostnames are yours. This guide does not list any.

#Troubleshooting

SymptomWhat to check
Account will not connectUse an API Key SID (SK…) and its secret, not the Account Auth Token. Account SID must be AC…. The wizard rejects malformed SIDs before calling Twilio. If the shape is valid, the next failure is Twilio rejecting the key: create a Standard API key in Console → Account → API keys & tokens, and paste the secret once (it is shown only at creation).
No numbers to pick / search is emptyOwned numbers must be Voice-capable. Find numbers only searches US local inventory for a 3-digit area code (VoiceEnabled=true). Try another area code, or buy a Voice number in Console and reconnect so it appears under already-owned numbers.
Function deploy failsRead the failed step in the error (create-build, upload-function-versions, and so on). Retry resumes; it does not buy the number twice if that step already completed. In Console, open Service mishu → Builds and confirm the latest build is completed, not failed or stuck. Runtime must be a currently supported Node version; node18 is retired and returns error 82007.
Number routing did not changeIf you chose Keep my current routing, that is expected: Voice URL is untouched. Otherwise open the number in Console and confirm Voice URL is https://{environment-domain}/voice-incoming (POST), not the TwiML App URL. The TwiML App itself should point at /voice-outgoing (client-originated calls), which is a different path. Twilio can take a short moment to serve the new URL.
Inbound call, nothing happens on the desktopLeave mock mode (LIVE_PHONE_USE_MOCKS=1 keeps simulated telephony). Keep the desktop running so the Voice SDK can register as CLIENT_IDENTITY. Confirm Console CLIENT_IDENTITY matches Settings → Phone line → Client name. A missing variable falls back instead of hanging up, so a mismatch still looks like "the phone never rang." Grant microphone permission. Then place a test call to the number and confirm Twilio's call log hit /voice-incoming.

#Access tokens stay on this machine

Real Twilio mode needs a short-lived Voice SDK token. The desktop signs tokens in the main process when Settings → Phone line has the API key, secret, TwiML App SID, and number.

For a source checkout you can also run the localhost helper:

pnpm dev:twilio

That serves /token on 127.0.0.1:8787 only. Do not expose /token on the public internet. If the helper is not bound to loopback, it requires a strong bearer secret (APP_TOKEN_SECRET in .env.example, at least 32 random bytes). /token must not fail open.

Preferred credentials store: Settings → Phone line. Alternative for development: .env next to the checkout (or in the app user-data folder when packaged). Copy .env.example and fill placeholders. Keep the file mode 0600. Never commit it. Environment values override the saved settings file per field.

#Compliance

  • You are responsible for TCPA, Telemarketing Sales Rule, state mini-TCPA rules, and two-party / all-party recording-consent law in every jurisdiction you call.
  • Official builds disclose that the caller is speaking with AI on the first turn. A campaign cannot turn that off. Recording disclosure is a separate campaign toggle and does not replace AI identity disclosure.
  • Do not route emergency numbers through this engine.

When you leave mock mode, bring your own account and your own compliance program. Mishu Cloud multi-tenant number reputation and Trust Hub operations are not part of this repository.

View this page on GitHub