@kody/twilio
README.md
148 lines · 5.1 KB · Markdown@kody/twilio
Official Twilio four-dot mark (Simple Icons path of Twilio's logo) in Signal Red #F22F46. Twilio® is a trademark of Twilio Inc. This package is not affiliated with or endorsed by Twilio.
Intent
Provide reusable, account-agnostic Twilio helpers so Kody can look up the
caller's account, list incoming numbers, read message logs, and send SMS.
Auth is a saved Account SID plus Auth Token. Sends default to dry-run and
need confirm: true for a live message. No personal phone numbers belong in
this package — pass from/to or a Messaging Service SID at call time.
This listing is meant to be forked. The live @kody/twilio package does not
talk to a shared Twilio account.
Auth
Account SID + Auth Token (secret-backed HTTP Basic). There is no Twilio
OAuth integration and no baked-in sender. Do not open /connect/oauth for
Twilio.
| Secret | Purpose |
|---|---|
twilioAccountSid | Account SID (AC…) used as the Basic username and in the REST path |
twilioAuthToken | Auth Token used as the Basic password |
Optional readable default (not a secret): store a Messaging Service SID (MG…)
in this package's packageStorage() after you fork. Live @kody/twilio
storage is the platform bucket — fork first.
Required setup
- Copy the Account SID and Auth Token from the Twilio Console. Never paste them into chat.
- Save the Account SID:
- Save the Auth Token:
- Approve host
api.twilio.comfor both secrets. - Run the smoke test below.
Required host: api.twilio.com.
Additional accounts
Pass account: "work" to use twilioAccountSid-work / twilioAuthToken-work,
or pass accountSidSecret / authTokenSecret explicitly.
Exports
kody:@kody/twilio— package overview and safety metadatakody:@kody/twilio/guide— console steps and prefilled secret URLskody:@kody/twilio/smoke-test— dry-run self-check, plus live account lookup when secrets existkody:@kody/twilio/account— slim account profile (never returnsauth_token)kody:@kody/twilio/incoming-numbers— incoming phone numberskody:@kody/twilio/messages— recent SMS/MMS logskody:@kody/twilio/send-message— preview or send; defaults to dry-runkody:@kody/twilio/config— optional Messaging Service SID inpackageStorage()kody:@kody/twilio/request— escape hatch for other 2010-04-01 Account paths
Smoke test
./smoke-test is safe before anyone saves credentials: it returns
{ ok: true, live: false } and the setup URLs. After both secrets and host
approval, invoke the package (not a static import) so Basic Auth placeholders
resolve and account lookup runs:
import { packages } from 'kody:runtime'
export default async function main() {
return await packages.invoke({
kodyId: 'twilio',
exportName: './smoke-test',
})
}A live result is account + one page of numbers and message logs. It does not send SMS.
Static overview (no secret mounts required):
import twilio from 'kody:@kody/twilio'
export default async function main() {
return await twilio()
}dryRun
send-message and other POST helpers default to dry-run. They return the
Twilio form payload without calling the API unless confirm: true (and
dryRun is not true). Live sends also need from or messagingServiceSid.
import sendMessage from 'kody:@kody/twilio/send-message'
export default async function main() {
return sendMessage({
to: '+15555550100',
from: '+15555550101',
body: 'Hello from Kody',
})
}That call previews. A live send after explicit user approval of the exact destination and body:
import sendMessage from 'kody:@kody/twilio/send-message'
export default async function main() {
return sendMessage({
to: '+15555550100',
from: '+15555550101',
body: 'Hello from Kody',
confirm: true,
})
}Errors
| Twilio response | What to do |
|---|---|
| 401 Authenticate | Save twilioAccountSid and twilioAuthToken at the URLs above and approve api.twilio.com for both. |
| 403 | The SID and token must belong to the same account. |
| 404 | Confirm the Account SID and that the resource path exists. |
| 400 missing From | Pass from (E.164) or a Messaging Service SID. This package has no default sender. |