aidevops 2.52.1 → 2.53.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/VERSION +1 -1
- package/aidevops.sh +15 -9
- package/package.json +4 -4
- package/scripts/npm-postinstall.js +6 -7
- package/setup.sh +1 -1
- package/templates/deploy-templates.sh +144 -0
- package/templates/home/.agent/README.md +33 -0
- package/templates/home/AGENTS.md +96 -0
- package/templates/home/git/.agent/README.md +48 -0
- package/templates/home/git/AGENTS.md +97 -0
- package/templates/standard-functions.sh +179 -0
- package/templates/wordpress-performance-workflow.md +217 -0
- package/.agent/AGENTS.md +0 -614
- package/.agent/accounts.md +0 -65
- package/.agent/aidevops/add-new-mcp-to-aidevops.md +0 -456
- package/.agent/aidevops/api-integrations.md +0 -335
- package/.agent/aidevops/architecture.md +0 -510
- package/.agent/aidevops/configs.md +0 -274
- package/.agent/aidevops/docs.md +0 -244
- package/.agent/aidevops/extension.md +0 -311
- package/.agent/aidevops/mcp-integrations.md +0 -340
- package/.agent/aidevops/mcp-troubleshooting.md +0 -162
- package/.agent/aidevops/memory-patterns.md +0 -172
- package/.agent/aidevops/providers.md +0 -217
- package/.agent/aidevops/recommendations.md +0 -321
- package/.agent/aidevops/requirements.md +0 -301
- package/.agent/aidevops/resources.md +0 -214
- package/.agent/aidevops/security-requirements.md +0 -174
- package/.agent/aidevops/security.md +0 -350
- package/.agent/aidevops/service-links.md +0 -400
- package/.agent/aidevops/services.md +0 -357
- package/.agent/aidevops/setup.md +0 -153
- package/.agent/aidevops/troubleshooting.md +0 -389
- package/.agent/aidevops.md +0 -124
- package/.agent/build-plus.md +0 -244
- package/.agent/content/guidelines.md +0 -109
- package/.agent/content.md +0 -87
- package/.agent/health.md +0 -59
- package/.agent/legal.md +0 -59
- package/.agent/loop-state/full-loop.local.md +0 -16
- package/.agent/loop-state/ralph-loop.local.md +0 -10
- package/.agent/marketing.md +0 -440
- package/.agent/memory/README.md +0 -260
- package/.agent/onboarding.md +0 -796
- package/.agent/plan-plus.md +0 -245
- package/.agent/research.md +0 -100
- package/.agent/sales.md +0 -333
- package/.agent/scripts/101domains-helper.sh +0 -701
- package/.agent/scripts/add-missing-returns.sh +0 -140
- package/.agent/scripts/agent-browser-helper.sh +0 -311
- package/.agent/scripts/agno-setup.sh +0 -712
- package/.agent/scripts/ahrefs-mcp-wrapper.js +0 -168
- package/.agent/scripts/aidevops-update-check.sh +0 -71
- package/.agent/scripts/ampcode-cli.sh +0 -522
- package/.agent/scripts/auto-version-bump.sh +0 -156
- package/.agent/scripts/autogen-helper.sh +0 -512
- package/.agent/scripts/beads-sync-helper.sh +0 -596
- package/.agent/scripts/closte-helper.sh +0 -5
- package/.agent/scripts/cloudron-helper.sh +0 -321
- package/.agent/scripts/codacy-cli-chunked.sh +0 -581
- package/.agent/scripts/codacy-cli.sh +0 -442
- package/.agent/scripts/code-audit-helper.sh +0 -5
- package/.agent/scripts/coderabbit-cli.sh +0 -417
- package/.agent/scripts/coderabbit-pro-analysis.sh +0 -238
- package/.agent/scripts/commands/code-simplifier.md +0 -86
- package/.agent/scripts/commands/full-loop.md +0 -246
- package/.agent/scripts/commands/postflight-loop.md +0 -103
- package/.agent/scripts/commands/recall.md +0 -182
- package/.agent/scripts/commands/remember.md +0 -132
- package/.agent/scripts/commands/save-todo.md +0 -175
- package/.agent/scripts/commands/session-review.md +0 -154
- package/.agent/scripts/comprehensive-quality-fix.sh +0 -106
- package/.agent/scripts/context-builder-helper.sh +0 -522
- package/.agent/scripts/coolify-cli-helper.sh +0 -674
- package/.agent/scripts/coolify-helper.sh +0 -380
- package/.agent/scripts/crawl4ai-examples.sh +0 -401
- package/.agent/scripts/crawl4ai-helper.sh +0 -1078
- package/.agent/scripts/crewai-helper.sh +0 -681
- package/.agent/scripts/dev-browser-helper.sh +0 -513
- package/.agent/scripts/dns-helper.sh +0 -396
- package/.agent/scripts/domain-research-helper.sh +0 -917
- package/.agent/scripts/dspy-helper.sh +0 -285
- package/.agent/scripts/dspyground-helper.sh +0 -291
- package/.agent/scripts/eeat-score-helper.sh +0 -1242
- package/.agent/scripts/efficient-return-fix.sh +0 -92
- package/.agent/scripts/extract-opencode-prompts.sh +0 -128
- package/.agent/scripts/find-missing-returns.sh +0 -113
- package/.agent/scripts/fix-auth-headers.sh +0 -104
- package/.agent/scripts/fix-common-strings.sh +0 -254
- package/.agent/scripts/fix-content-type.sh +0 -100
- package/.agent/scripts/fix-error-messages.sh +0 -130
- package/.agent/scripts/fix-misplaced-returns.sh +0 -74
- package/.agent/scripts/fix-remaining-literals.sh +0 -152
- package/.agent/scripts/fix-return-statements.sh +0 -41
- package/.agent/scripts/fix-s131-default-cases.sh +0 -249
- package/.agent/scripts/fix-sc2155-simple.sh +0 -102
- package/.agent/scripts/fix-shellcheck-critical.sh +0 -187
- package/.agent/scripts/fix-string-literals.sh +0 -273
- package/.agent/scripts/full-loop-helper.sh +0 -773
- package/.agent/scripts/generate-opencode-agents.sh +0 -497
- package/.agent/scripts/generate-opencode-commands.sh +0 -1629
- package/.agent/scripts/generate-skills.sh +0 -366
- package/.agent/scripts/git-platforms-helper.sh +0 -640
- package/.agent/scripts/gitea-cli-helper.sh +0 -743
- package/.agent/scripts/github-cli-helper.sh +0 -702
- package/.agent/scripts/gitlab-cli-helper.sh +0 -682
- package/.agent/scripts/gsc-add-user-helper.sh +0 -325
- package/.agent/scripts/gsc-sitemap-helper.sh +0 -678
- package/.agent/scripts/hetzner-helper.sh +0 -485
- package/.agent/scripts/hostinger-helper.sh +0 -229
- package/.agent/scripts/keyword-research-helper.sh +0 -1815
- package/.agent/scripts/langflow-helper.sh +0 -544
- package/.agent/scripts/linkedin-automation.py +0 -241
- package/.agent/scripts/linter-manager.sh +0 -599
- package/.agent/scripts/linters-local.sh +0 -434
- package/.agent/scripts/list-keys-helper.sh +0 -488
- package/.agent/scripts/local-browser-automation.py +0 -339
- package/.agent/scripts/localhost-helper.sh +0 -744
- package/.agent/scripts/loop-common.sh +0 -806
- package/.agent/scripts/mainwp-helper.sh +0 -728
- package/.agent/scripts/markdown-formatter.sh +0 -338
- package/.agent/scripts/markdown-lint-fix.sh +0 -311
- package/.agent/scripts/mass-fix-returns.sh +0 -58
- package/.agent/scripts/mcp-diagnose.sh +0 -167
- package/.agent/scripts/mcp-inspector-helper.sh +0 -449
- package/.agent/scripts/memory-helper.sh +0 -650
- package/.agent/scripts/monitor-code-review.sh +0 -255
- package/.agent/scripts/onboarding-helper.sh +0 -706
- package/.agent/scripts/opencode-github-setup-helper.sh +0 -797
- package/.agent/scripts/opencode-test-helper.sh +0 -213
- package/.agent/scripts/pagespeed-helper.sh +0 -464
- package/.agent/scripts/pandoc-helper.sh +0 -362
- package/.agent/scripts/postflight-check.sh +0 -555
- package/.agent/scripts/pre-commit-hook.sh +0 -259
- package/.agent/scripts/pre-edit-check.sh +0 -169
- package/.agent/scripts/qlty-cli.sh +0 -356
- package/.agent/scripts/quality-cli-manager.sh +0 -525
- package/.agent/scripts/quality-feedback-helper.sh +0 -462
- package/.agent/scripts/quality-fix.sh +0 -263
- package/.agent/scripts/quality-loop-helper.sh +0 -1108
- package/.agent/scripts/ralph-loop-helper.sh +0 -836
- package/.agent/scripts/ralph-upstream-check.sh +0 -341
- package/.agent/scripts/secretlint-helper.sh +0 -847
- package/.agent/scripts/servers-helper.sh +0 -241
- package/.agent/scripts/ses-helper.sh +0 -619
- package/.agent/scripts/session-review-helper.sh +0 -404
- package/.agent/scripts/setup-linters-wizard.sh +0 -379
- package/.agent/scripts/setup-local-api-keys.sh +0 -330
- package/.agent/scripts/setup-mcp-integrations.sh +0 -472
- package/.agent/scripts/shared-constants.sh +0 -246
- package/.agent/scripts/site-crawler-helper.sh +0 -1487
- package/.agent/scripts/snyk-helper.sh +0 -940
- package/.agent/scripts/sonarcloud-autofix.sh +0 -193
- package/.agent/scripts/sonarcloud-cli.sh +0 -191
- package/.agent/scripts/sonarscanner-cli.sh +0 -455
- package/.agent/scripts/spaceship-helper.sh +0 -747
- package/.agent/scripts/stagehand-helper.sh +0 -321
- package/.agent/scripts/stagehand-python-helper.sh +0 -321
- package/.agent/scripts/stagehand-python-setup.sh +0 -441
- package/.agent/scripts/stagehand-setup.sh +0 -439
- package/.agent/scripts/system-cleanup.sh +0 -340
- package/.agent/scripts/terminal-title-helper.sh +0 -388
- package/.agent/scripts/terminal-title-setup.sh +0 -549
- package/.agent/scripts/test-stagehand-both-integration.sh +0 -317
- package/.agent/scripts/test-stagehand-integration.sh +0 -309
- package/.agent/scripts/test-stagehand-python-integration.sh +0 -341
- package/.agent/scripts/todo-ready.sh +0 -263
- package/.agent/scripts/tool-version-check.sh +0 -362
- package/.agent/scripts/toon-helper.sh +0 -469
- package/.agent/scripts/twilio-helper.sh +0 -917
- package/.agent/scripts/updown-helper.sh +0 -279
- package/.agent/scripts/validate-mcp-integrations.sh +0 -250
- package/.agent/scripts/validate-version-consistency.sh +0 -131
- package/.agent/scripts/vaultwarden-helper.sh +0 -597
- package/.agent/scripts/vercel-cli-helper.sh +0 -816
- package/.agent/scripts/verify-mirrors.sh +0 -169
- package/.agent/scripts/version-manager.sh +0 -831
- package/.agent/scripts/webhosting-helper.sh +0 -471
- package/.agent/scripts/webhosting-verify.sh +0 -238
- package/.agent/scripts/wordpress-mcp-helper.sh +0 -508
- package/.agent/scripts/worktree-helper.sh +0 -595
- package/.agent/scripts/worktree-sessions.sh +0 -577
- package/.agent/seo/dataforseo.md +0 -215
- package/.agent/seo/domain-research.md +0 -532
- package/.agent/seo/eeat-score.md +0 -659
- package/.agent/seo/google-search-console.md +0 -366
- package/.agent/seo/gsc-sitemaps.md +0 -282
- package/.agent/seo/keyword-research.md +0 -521
- package/.agent/seo/serper.md +0 -278
- package/.agent/seo/site-crawler.md +0 -387
- package/.agent/seo.md +0 -236
- package/.agent/services/accounting/quickfile.md +0 -159
- package/.agent/services/communications/telfon.md +0 -470
- package/.agent/services/communications/twilio.md +0 -569
- package/.agent/services/crm/fluentcrm.md +0 -449
- package/.agent/services/email/ses.md +0 -399
- package/.agent/services/hosting/101domains.md +0 -378
- package/.agent/services/hosting/closte.md +0 -177
- package/.agent/services/hosting/cloudflare.md +0 -251
- package/.agent/services/hosting/cloudron.md +0 -478
- package/.agent/services/hosting/dns-providers.md +0 -335
- package/.agent/services/hosting/domain-purchasing.md +0 -344
- package/.agent/services/hosting/hetzner.md +0 -327
- package/.agent/services/hosting/hostinger.md +0 -287
- package/.agent/services/hosting/localhost.md +0 -419
- package/.agent/services/hosting/spaceship.md +0 -353
- package/.agent/services/hosting/webhosting.md +0 -330
- package/.agent/social-media.md +0 -69
- package/.agent/templates/plans-template.md +0 -114
- package/.agent/templates/prd-template.md +0 -129
- package/.agent/templates/tasks-template.md +0 -108
- package/.agent/templates/todo-template.md +0 -89
- package/.agent/tools/ai-assistants/agno.md +0 -471
- package/.agent/tools/ai-assistants/capsolver.md +0 -326
- package/.agent/tools/ai-assistants/configuration.md +0 -221
- package/.agent/tools/ai-assistants/overview.md +0 -209
- package/.agent/tools/ai-assistants/status.md +0 -171
- package/.agent/tools/ai-assistants/windsurf.md +0 -193
- package/.agent/tools/ai-orchestration/autogen.md +0 -406
- package/.agent/tools/ai-orchestration/crewai.md +0 -445
- package/.agent/tools/ai-orchestration/langflow.md +0 -405
- package/.agent/tools/ai-orchestration/openprose.md +0 -487
- package/.agent/tools/ai-orchestration/overview.md +0 -362
- package/.agent/tools/ai-orchestration/packaging.md +0 -647
- package/.agent/tools/browser/agent-browser.md +0 -464
- package/.agent/tools/browser/browser-automation.md +0 -400
- package/.agent/tools/browser/chrome-devtools.md +0 -282
- package/.agent/tools/browser/crawl4ai-integration.md +0 -422
- package/.agent/tools/browser/crawl4ai-resources.md +0 -277
- package/.agent/tools/browser/crawl4ai-usage.md +0 -416
- package/.agent/tools/browser/crawl4ai.md +0 -585
- package/.agent/tools/browser/dev-browser.md +0 -341
- package/.agent/tools/browser/pagespeed.md +0 -260
- package/.agent/tools/browser/playwright.md +0 -266
- package/.agent/tools/browser/playwriter.md +0 -310
- package/.agent/tools/browser/stagehand-examples.md +0 -456
- package/.agent/tools/browser/stagehand-python.md +0 -483
- package/.agent/tools/browser/stagehand.md +0 -421
- package/.agent/tools/build-agent/agent-review.md +0 -224
- package/.agent/tools/build-agent/build-agent.md +0 -784
- package/.agent/tools/build-mcp/aidevops-plugin.md +0 -476
- package/.agent/tools/build-mcp/api-wrapper.md +0 -445
- package/.agent/tools/build-mcp/build-mcp.md +0 -240
- package/.agent/tools/build-mcp/deployment.md +0 -401
- package/.agent/tools/build-mcp/server-patterns.md +0 -632
- package/.agent/tools/build-mcp/transports.md +0 -366
- package/.agent/tools/code-review/auditing.md +0 -383
- package/.agent/tools/code-review/automation.md +0 -219
- package/.agent/tools/code-review/best-practices.md +0 -203
- package/.agent/tools/code-review/codacy.md +0 -151
- package/.agent/tools/code-review/code-simplifier.md +0 -174
- package/.agent/tools/code-review/code-standards.md +0 -309
- package/.agent/tools/code-review/coderabbit.md +0 -101
- package/.agent/tools/code-review/management.md +0 -155
- package/.agent/tools/code-review/qlty.md +0 -248
- package/.agent/tools/code-review/secretlint.md +0 -565
- package/.agent/tools/code-review/setup.md +0 -250
- package/.agent/tools/code-review/snyk.md +0 -563
- package/.agent/tools/code-review/tools.md +0 -230
- package/.agent/tools/content/summarize.md +0 -353
- package/.agent/tools/context/augment-context-engine.md +0 -468
- package/.agent/tools/context/context-builder-agent.md +0 -76
- package/.agent/tools/context/context-builder.md +0 -375
- package/.agent/tools/context/context7.md +0 -371
- package/.agent/tools/context/dspy.md +0 -302
- package/.agent/tools/context/dspyground.md +0 -374
- package/.agent/tools/context/llm-tldr.md +0 -219
- package/.agent/tools/context/osgrep.md +0 -488
- package/.agent/tools/context/prompt-optimization.md +0 -338
- package/.agent/tools/context/toon.md +0 -292
- package/.agent/tools/conversion/pandoc.md +0 -304
- package/.agent/tools/credentials/api-key-management.md +0 -154
- package/.agent/tools/credentials/api-key-setup.md +0 -224
- package/.agent/tools/credentials/environment-variables.md +0 -180
- package/.agent/tools/credentials/vaultwarden.md +0 -382
- package/.agent/tools/data-extraction/outscraper.md +0 -974
- package/.agent/tools/deployment/coolify-cli.md +0 -388
- package/.agent/tools/deployment/coolify-setup.md +0 -353
- package/.agent/tools/deployment/coolify.md +0 -345
- package/.agent/tools/deployment/vercel.md +0 -390
- package/.agent/tools/git/authentication.md +0 -132
- package/.agent/tools/git/gitea-cli.md +0 -193
- package/.agent/tools/git/github-actions.md +0 -207
- package/.agent/tools/git/github-cli.md +0 -223
- package/.agent/tools/git/gitlab-cli.md +0 -190
- package/.agent/tools/git/opencode-github-security.md +0 -350
- package/.agent/tools/git/opencode-github.md +0 -328
- package/.agent/tools/git/opencode-gitlab.md +0 -252
- package/.agent/tools/git/security.md +0 -196
- package/.agent/tools/git.md +0 -207
- package/.agent/tools/opencode/oh-my-opencode.md +0 -375
- package/.agent/tools/opencode/opencode-anthropic-auth.md +0 -446
- package/.agent/tools/opencode/opencode.md +0 -651
- package/.agent/tools/social-media/bird.md +0 -437
- package/.agent/tools/task-management/beads.md +0 -336
- package/.agent/tools/terminal/terminal-title.md +0 -251
- package/.agent/tools/ui/shadcn.md +0 -196
- package/.agent/tools/ui/ui-skills.md +0 -115
- package/.agent/tools/wordpress/localwp.md +0 -311
- package/.agent/tools/wordpress/mainwp.md +0 -391
- package/.agent/tools/wordpress/scf.md +0 -527
- package/.agent/tools/wordpress/wp-admin.md +0 -729
- package/.agent/tools/wordpress/wp-dev.md +0 -940
- package/.agent/tools/wordpress/wp-preferred.md +0 -398
- package/.agent/tools/wordpress.md +0 -95
- package/.agent/workflows/branch/bugfix.md +0 -63
- package/.agent/workflows/branch/chore.md +0 -95
- package/.agent/workflows/branch/experiment.md +0 -115
- package/.agent/workflows/branch/feature.md +0 -59
- package/.agent/workflows/branch/hotfix.md +0 -98
- package/.agent/workflows/branch/refactor.md +0 -92
- package/.agent/workflows/branch/release.md +0 -96
- package/.agent/workflows/branch.md +0 -347
- package/.agent/workflows/bug-fixing.md +0 -267
- package/.agent/workflows/changelog.md +0 -129
- package/.agent/workflows/code-audit-remote.md +0 -279
- package/.agent/workflows/conversation-starter.md +0 -69
- package/.agent/workflows/error-feedback.md +0 -578
- package/.agent/workflows/feature-development.md +0 -355
- package/.agent/workflows/git-workflow.md +0 -702
- package/.agent/workflows/multi-repo-workspace.md +0 -268
- package/.agent/workflows/plans.md +0 -709
- package/.agent/workflows/postflight.md +0 -604
- package/.agent/workflows/pr.md +0 -571
- package/.agent/workflows/preflight.md +0 -278
- package/.agent/workflows/ralph-loop.md +0 -773
- package/.agent/workflows/release.md +0 -498
- package/.agent/workflows/session-manager.md +0 -254
- package/.agent/workflows/session-review.md +0 -311
- package/.agent/workflows/sql-migrations.md +0 -631
- package/.agent/workflows/version-bump.md +0 -283
- package/.agent/workflows/wiki-update.md +0 -333
- package/.agent/workflows/worktree.md +0 -477
|
@@ -1,917 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# shellcheck disable=SC2034,SC2155,SC2317,SC2329,SC2016,SC2181,SC1091,SC2154,SC2015,SC2086,SC2129,SC2030,SC2031,SC2119,SC2120,SC2001,SC2162,SC2088,SC2089,SC2090,SC2029,SC2006,SC2153
|
|
3
|
-
|
|
4
|
-
# Twilio Helper Script
|
|
5
|
-
# Comprehensive Twilio management for AI assistants
|
|
6
|
-
# Supports SMS, Voice, WhatsApp, Verify, Lookup, Recordings, Transcriptions
|
|
7
|
-
|
|
8
|
-
# Colors for output
|
|
9
|
-
GREEN='\033[0;32m'
|
|
10
|
-
BLUE='\033[0;34m'
|
|
11
|
-
YELLOW='\033[1;33m'
|
|
12
|
-
RED='\033[0;31m'
|
|
13
|
-
NC='\033[0m' # No Color
|
|
14
|
-
|
|
15
|
-
# Common message constants
|
|
16
|
-
readonly HELP_SHOW_MESSAGE="Show this help"
|
|
17
|
-
readonly USAGE_COMMAND_OPTIONS="Usage: $0 <command> [account] [options]"
|
|
18
|
-
|
|
19
|
-
print_info() {
|
|
20
|
-
local msg="$1"
|
|
21
|
-
echo -e "${BLUE}[INFO]${NC} $msg"
|
|
22
|
-
return 0
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
print_success() {
|
|
26
|
-
local msg="$1"
|
|
27
|
-
echo -e "${GREEN}[SUCCESS]${NC} $msg"
|
|
28
|
-
return 0
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
print_warning() {
|
|
32
|
-
local msg="$1"
|
|
33
|
-
echo -e "${YELLOW}[WARNING]${NC} $msg"
|
|
34
|
-
return 0
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
print_error() {
|
|
38
|
-
local msg="$1"
|
|
39
|
-
echo -e "${RED}[ERROR]${NC} $msg" >&2
|
|
40
|
-
return 0
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
# Script directory for relative paths
|
|
44
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || exit
|
|
45
|
-
# Config can be in repo configs/ or ~/.aidevops/configs/
|
|
46
|
-
if [[ -f "${SCRIPT_DIR}/../../configs/twilio-config.json" ]]; then
|
|
47
|
-
CONFIG_FILE="${SCRIPT_DIR}/../../configs/twilio-config.json"
|
|
48
|
-
elif [[ -f "${HOME}/.aidevops/configs/twilio-config.json" ]]; then
|
|
49
|
-
CONFIG_FILE="${HOME}/.aidevops/configs/twilio-config.json"
|
|
50
|
-
else
|
|
51
|
-
CONFIG_FILE="${SCRIPT_DIR}/../../configs/twilio-config.json"
|
|
52
|
-
fi
|
|
53
|
-
|
|
54
|
-
# Check if Twilio CLI or curl is available
|
|
55
|
-
check_dependencies() {
|
|
56
|
-
if ! command -v curl &> /dev/null; then
|
|
57
|
-
print_error "curl is required but not installed"
|
|
58
|
-
exit 1
|
|
59
|
-
fi
|
|
60
|
-
|
|
61
|
-
if ! command -v jq &> /dev/null; then
|
|
62
|
-
print_error "jq is required but not installed"
|
|
63
|
-
print_info "Install on macOS: brew install jq"
|
|
64
|
-
print_info "Install on Ubuntu: sudo apt-get install jq"
|
|
65
|
-
exit 1
|
|
66
|
-
fi
|
|
67
|
-
|
|
68
|
-
# Twilio CLI is optional but recommended
|
|
69
|
-
if command -v twilio &> /dev/null; then
|
|
70
|
-
TWILIO_CLI_AVAILABLE=true
|
|
71
|
-
else
|
|
72
|
-
TWILIO_CLI_AVAILABLE=false
|
|
73
|
-
fi
|
|
74
|
-
|
|
75
|
-
return 0
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
# Load Twilio configuration
|
|
79
|
-
load_config() {
|
|
80
|
-
if [[ ! -f "$CONFIG_FILE" ]]; then
|
|
81
|
-
print_error "Configuration file not found: $CONFIG_FILE"
|
|
82
|
-
print_info "Copy and customize: cp configs/twilio-config.json.txt configs/twilio-config.json"
|
|
83
|
-
exit 1
|
|
84
|
-
fi
|
|
85
|
-
return 0
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
# Get account configuration
|
|
89
|
-
get_account_config() {
|
|
90
|
-
local account_name="$1"
|
|
91
|
-
|
|
92
|
-
if [[ -z "$account_name" ]]; then
|
|
93
|
-
print_error "Account name is required"
|
|
94
|
-
list_accounts
|
|
95
|
-
exit 1
|
|
96
|
-
fi
|
|
97
|
-
|
|
98
|
-
local account_config
|
|
99
|
-
account_config=$(jq -r ".accounts.\"$account_name\"" "$CONFIG_FILE")
|
|
100
|
-
if [[ "$account_config" == "null" ]]; then
|
|
101
|
-
print_error "Account '$account_name' not found in configuration"
|
|
102
|
-
list_accounts
|
|
103
|
-
exit 1
|
|
104
|
-
fi
|
|
105
|
-
|
|
106
|
-
echo "$account_config"
|
|
107
|
-
return 0
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
# Set Twilio credentials for account
|
|
111
|
-
set_twilio_credentials() {
|
|
112
|
-
local account_name="$1"
|
|
113
|
-
local config
|
|
114
|
-
config=$(get_account_config "$account_name")
|
|
115
|
-
|
|
116
|
-
TWILIO_ACCOUNT_SID=$(echo "$config" | jq -r '.account_sid')
|
|
117
|
-
TWILIO_AUTH_TOKEN=$(echo "$config" | jq -r '.auth_token')
|
|
118
|
-
TWILIO_DEFAULT_FROM=$(echo "$config" | jq -r '.default_from // empty')
|
|
119
|
-
|
|
120
|
-
if [[ "$TWILIO_ACCOUNT_SID" == "null" || "$TWILIO_AUTH_TOKEN" == "null" ]]; then
|
|
121
|
-
print_error "Invalid Twilio credentials for account '$account_name'"
|
|
122
|
-
exit 1
|
|
123
|
-
fi
|
|
124
|
-
|
|
125
|
-
export TWILIO_ACCOUNT_SID
|
|
126
|
-
export TWILIO_AUTH_TOKEN
|
|
127
|
-
return 0
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
# Make Twilio API request
|
|
131
|
-
twilio_api() {
|
|
132
|
-
local method="$1"
|
|
133
|
-
local endpoint="$2"
|
|
134
|
-
shift 2
|
|
135
|
-
local data="$*"
|
|
136
|
-
|
|
137
|
-
local url="https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}${endpoint}"
|
|
138
|
-
|
|
139
|
-
if [[ "$method" == "GET" ]]; then
|
|
140
|
-
curl -s -X GET "$url" \
|
|
141
|
-
-u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}"
|
|
142
|
-
else
|
|
143
|
-
curl -s -X "$method" "$url" \
|
|
144
|
-
-u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}" \
|
|
145
|
-
$data
|
|
146
|
-
fi
|
|
147
|
-
return 0
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
# List all configured accounts
|
|
151
|
-
list_accounts() {
|
|
152
|
-
load_config
|
|
153
|
-
print_info "Available Twilio accounts:"
|
|
154
|
-
jq -r '.accounts | keys[]' "$CONFIG_FILE" | while read -r account; do
|
|
155
|
-
local description
|
|
156
|
-
description=$(jq -r ".accounts.\"$account\".description" "$CONFIG_FILE")
|
|
157
|
-
local default_from
|
|
158
|
-
default_from=$(jq -r ".accounts.\"$account\".default_from // \"not set\"" "$CONFIG_FILE")
|
|
159
|
-
echo " - $account (from: $default_from) - $description"
|
|
160
|
-
done
|
|
161
|
-
return 0
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
# Get account balance
|
|
165
|
-
get_balance() {
|
|
166
|
-
local account_name="$1"
|
|
167
|
-
set_twilio_credentials "$account_name"
|
|
168
|
-
|
|
169
|
-
print_info "Getting balance for account: $account_name"
|
|
170
|
-
local response
|
|
171
|
-
response=$(twilio_api GET "/Balance.json")
|
|
172
|
-
|
|
173
|
-
local balance currency
|
|
174
|
-
balance=$(echo "$response" | jq -r '.balance')
|
|
175
|
-
currency=$(echo "$response" | jq -r '.currency')
|
|
176
|
-
|
|
177
|
-
echo "Balance: $currency $balance"
|
|
178
|
-
return 0
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
# List phone numbers
|
|
182
|
-
list_numbers() {
|
|
183
|
-
local account_name="$1"
|
|
184
|
-
set_twilio_credentials "$account_name"
|
|
185
|
-
|
|
186
|
-
print_info "Phone numbers for account: $account_name"
|
|
187
|
-
local response
|
|
188
|
-
response=$(twilio_api GET "/IncomingPhoneNumbers.json")
|
|
189
|
-
|
|
190
|
-
echo "$response" | jq -r '.incoming_phone_numbers[] | "\(.phone_number) - \(.friendly_name) [\(.capabilities | to_entries | map(select(.value == true) | .key) | join(", "))]"'
|
|
191
|
-
return 0
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
# Search available numbers
|
|
195
|
-
search_numbers() {
|
|
196
|
-
local account_name="$1"
|
|
197
|
-
local country="$2"
|
|
198
|
-
shift 2
|
|
199
|
-
|
|
200
|
-
set_twilio_credentials "$account_name"
|
|
201
|
-
|
|
202
|
-
local params=""
|
|
203
|
-
while [[ $# -gt 0 ]]; do
|
|
204
|
-
case "$1" in
|
|
205
|
-
--area-code)
|
|
206
|
-
params="${params}&AreaCode=$2"
|
|
207
|
-
shift 2
|
|
208
|
-
;;
|
|
209
|
-
--contains)
|
|
210
|
-
params="${params}&Contains=$2"
|
|
211
|
-
shift 2
|
|
212
|
-
;;
|
|
213
|
-
--sms)
|
|
214
|
-
params="${params}&SmsEnabled=true"
|
|
215
|
-
shift
|
|
216
|
-
;;
|
|
217
|
-
--voice)
|
|
218
|
-
params="${params}&VoiceEnabled=true"
|
|
219
|
-
shift
|
|
220
|
-
;;
|
|
221
|
-
--mms)
|
|
222
|
-
params="${params}&MmsEnabled=true"
|
|
223
|
-
shift
|
|
224
|
-
;;
|
|
225
|
-
*)
|
|
226
|
-
shift
|
|
227
|
-
;;
|
|
228
|
-
esac
|
|
229
|
-
done
|
|
230
|
-
|
|
231
|
-
print_info "Searching for available numbers in $country..."
|
|
232
|
-
local url="https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}/AvailablePhoneNumbers/${country}/Local.json?${params}"
|
|
233
|
-
|
|
234
|
-
local response
|
|
235
|
-
response=$(curl -s -X GET "$url" -u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}")
|
|
236
|
-
|
|
237
|
-
local count
|
|
238
|
-
count=$(echo "$response" | jq -r '.available_phone_numbers | length')
|
|
239
|
-
|
|
240
|
-
if [[ "$count" == "0" ]]; then
|
|
241
|
-
print_warning "No numbers available with those criteria"
|
|
242
|
-
print_info "Try different search parameters or contact Twilio support for special numbers"
|
|
243
|
-
return 1
|
|
244
|
-
fi
|
|
245
|
-
|
|
246
|
-
echo "$response" | jq -r '.available_phone_numbers[] | "\(.phone_number) - \(.locality // "N/A"), \(.region // "N/A") [\(.capabilities | to_entries | map(select(.value == true) | .key) | join(", "))]"'
|
|
247
|
-
return 0
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
# Buy a phone number
|
|
251
|
-
buy_number() {
|
|
252
|
-
local account_name="$1"
|
|
253
|
-
local phone_number="$2"
|
|
254
|
-
|
|
255
|
-
set_twilio_credentials "$account_name"
|
|
256
|
-
|
|
257
|
-
print_warning "About to purchase number: $phone_number"
|
|
258
|
-
read -p "Confirm purchase? (yes/no): " confirm
|
|
259
|
-
|
|
260
|
-
if [[ "$confirm" != "yes" ]]; then
|
|
261
|
-
print_info "Purchase cancelled"
|
|
262
|
-
return 1
|
|
263
|
-
fi
|
|
264
|
-
|
|
265
|
-
local response
|
|
266
|
-
response=$(twilio_api POST "/IncomingPhoneNumbers.json" -d "PhoneNumber=$phone_number")
|
|
267
|
-
|
|
268
|
-
if echo "$response" | jq -e '.sid' > /dev/null 2>&1; then
|
|
269
|
-
print_success "Number purchased successfully!"
|
|
270
|
-
echo "$response" | jq -r '"SID: \(.sid)\nNumber: \(.phone_number)\nFriendly Name: \(.friendly_name)"'
|
|
271
|
-
else
|
|
272
|
-
print_error "Failed to purchase number"
|
|
273
|
-
echo "$response" | jq -r '.message // .'
|
|
274
|
-
fi
|
|
275
|
-
return 0
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
# Send SMS
|
|
279
|
-
send_sms() {
|
|
280
|
-
local account_name="$1"
|
|
281
|
-
local to="$2"
|
|
282
|
-
local body="$3"
|
|
283
|
-
local from="${4:-$TWILIO_DEFAULT_FROM}"
|
|
284
|
-
|
|
285
|
-
set_twilio_credentials "$account_name"
|
|
286
|
-
|
|
287
|
-
if [[ -z "$from" ]]; then
|
|
288
|
-
from="$TWILIO_DEFAULT_FROM"
|
|
289
|
-
fi
|
|
290
|
-
|
|
291
|
-
if [[ -z "$from" ]]; then
|
|
292
|
-
print_error "No 'from' number specified and no default configured"
|
|
293
|
-
return 1
|
|
294
|
-
fi
|
|
295
|
-
|
|
296
|
-
# AUP compliance check
|
|
297
|
-
print_info "Sending SMS from $from to $to"
|
|
298
|
-
|
|
299
|
-
local response
|
|
300
|
-
response=$(twilio_api POST "/Messages.json" \
|
|
301
|
-
-d "To=$to" \
|
|
302
|
-
-d "From=$from" \
|
|
303
|
-
-d "Body=$body")
|
|
304
|
-
|
|
305
|
-
if echo "$response" | jq -e '.sid' > /dev/null 2>&1; then
|
|
306
|
-
print_success "SMS sent successfully!"
|
|
307
|
-
echo "$response" | jq -r '"SID: \(.sid)\nStatus: \(.status)\nTo: \(.to)\nFrom: \(.from)"'
|
|
308
|
-
else
|
|
309
|
-
print_error "Failed to send SMS"
|
|
310
|
-
echo "$response" | jq -r '.message // .'
|
|
311
|
-
fi
|
|
312
|
-
return 0
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
# List messages
|
|
316
|
-
list_messages() {
|
|
317
|
-
local account_name="$1"
|
|
318
|
-
local limit="${2:-20}"
|
|
319
|
-
|
|
320
|
-
set_twilio_credentials "$account_name"
|
|
321
|
-
|
|
322
|
-
print_info "Recent messages for account: $account_name"
|
|
323
|
-
local response
|
|
324
|
-
response=$(twilio_api GET "/Messages.json?PageSize=$limit")
|
|
325
|
-
|
|
326
|
-
echo "$response" | jq -r '.messages[] | "\(.date_sent) | \(.direction) | \(.from) -> \(.to) | \(.status) | \(.body[0:50])..."'
|
|
327
|
-
return 0
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
# Get message status
|
|
331
|
-
get_message_status() {
|
|
332
|
-
local account_name="$1"
|
|
333
|
-
local message_sid="$2"
|
|
334
|
-
|
|
335
|
-
set_twilio_credentials "$account_name"
|
|
336
|
-
|
|
337
|
-
print_info "Getting status for message: $message_sid"
|
|
338
|
-
local response
|
|
339
|
-
response=$(twilio_api GET "/Messages/${message_sid}.json")
|
|
340
|
-
|
|
341
|
-
echo "$response" | jq -r '"SID: \(.sid)\nStatus: \(.status)\nDirection: \(.direction)\nFrom: \(.from)\nTo: \(.to)\nBody: \(.body)\nDate Sent: \(.date_sent)\nError Code: \(.error_code // "none")\nError Message: \(.error_message // "none")"'
|
|
342
|
-
return 0
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
# Make a call
|
|
346
|
-
make_call() {
|
|
347
|
-
local account_name="$1"
|
|
348
|
-
local to="$2"
|
|
349
|
-
shift 2
|
|
350
|
-
|
|
351
|
-
set_twilio_credentials "$account_name"
|
|
352
|
-
|
|
353
|
-
local from="$TWILIO_DEFAULT_FROM"
|
|
354
|
-
local twiml=""
|
|
355
|
-
local url=""
|
|
356
|
-
local record="false"
|
|
357
|
-
|
|
358
|
-
while [[ $# -gt 0 ]]; do
|
|
359
|
-
case "$1" in
|
|
360
|
-
--from)
|
|
361
|
-
from="$2"
|
|
362
|
-
shift 2
|
|
363
|
-
;;
|
|
364
|
-
--twiml)
|
|
365
|
-
twiml="$2"
|
|
366
|
-
shift 2
|
|
367
|
-
;;
|
|
368
|
-
--url)
|
|
369
|
-
url="$2"
|
|
370
|
-
shift 2
|
|
371
|
-
;;
|
|
372
|
-
--record)
|
|
373
|
-
record="true"
|
|
374
|
-
shift
|
|
375
|
-
;;
|
|
376
|
-
*)
|
|
377
|
-
shift
|
|
378
|
-
;;
|
|
379
|
-
esac
|
|
380
|
-
done
|
|
381
|
-
|
|
382
|
-
if [[ -z "$from" ]]; then
|
|
383
|
-
print_error "No 'from' number specified and no default configured"
|
|
384
|
-
return 1
|
|
385
|
-
fi
|
|
386
|
-
|
|
387
|
-
print_info "Initiating call from $from to $to"
|
|
388
|
-
|
|
389
|
-
local data="-d To=$to -d From=$from"
|
|
390
|
-
|
|
391
|
-
if [[ -n "$twiml" ]]; then
|
|
392
|
-
data="$data -d Twiml=$twiml"
|
|
393
|
-
elif [[ -n "$url" ]]; then
|
|
394
|
-
data="$data -d Url=$url"
|
|
395
|
-
else
|
|
396
|
-
# Default TwiML
|
|
397
|
-
data="$data -d Twiml=<Response><Say>Hello from AI DevOps!</Say></Response>"
|
|
398
|
-
fi
|
|
399
|
-
|
|
400
|
-
if [[ "$record" == "true" ]]; then
|
|
401
|
-
data="$data -d Record=true"
|
|
402
|
-
fi
|
|
403
|
-
|
|
404
|
-
local response
|
|
405
|
-
response=$(twilio_api POST "/Calls.json" $data)
|
|
406
|
-
|
|
407
|
-
if echo "$response" | jq -e '.sid' > /dev/null 2>&1; then
|
|
408
|
-
print_success "Call initiated successfully!"
|
|
409
|
-
echo "$response" | jq -r '"SID: \(.sid)\nStatus: \(.status)\nTo: \(.to)\nFrom: \(.from)"'
|
|
410
|
-
else
|
|
411
|
-
print_error "Failed to initiate call"
|
|
412
|
-
echo "$response" | jq -r '.message // .'
|
|
413
|
-
fi
|
|
414
|
-
return 0
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
# List calls
|
|
418
|
-
list_calls() {
|
|
419
|
-
local account_name="$1"
|
|
420
|
-
local limit="${2:-20}"
|
|
421
|
-
|
|
422
|
-
set_twilio_credentials "$account_name"
|
|
423
|
-
|
|
424
|
-
print_info "Recent calls for account: $account_name"
|
|
425
|
-
local response
|
|
426
|
-
response=$(twilio_api GET "/Calls.json?PageSize=$limit")
|
|
427
|
-
|
|
428
|
-
echo "$response" | jq -r '.calls[] | "\(.start_time) | \(.direction) | \(.from) -> \(.to) | \(.status) | \(.duration)s"'
|
|
429
|
-
return 0
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
# List recordings
|
|
433
|
-
list_recordings() {
|
|
434
|
-
local account_name="$1"
|
|
435
|
-
local limit="${2:-20}"
|
|
436
|
-
|
|
437
|
-
set_twilio_credentials "$account_name"
|
|
438
|
-
|
|
439
|
-
print_info "Recordings for account: $account_name"
|
|
440
|
-
local response
|
|
441
|
-
response=$(twilio_api GET "/Recordings.json?PageSize=$limit")
|
|
442
|
-
|
|
443
|
-
echo "$response" | jq -r '.recordings[] | "\(.date_created) | \(.sid) | \(.duration)s | \(.call_sid)"'
|
|
444
|
-
return 0
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
# Get recording details
|
|
448
|
-
get_recording() {
|
|
449
|
-
local account_name="$1"
|
|
450
|
-
local recording_sid="$2"
|
|
451
|
-
|
|
452
|
-
set_twilio_credentials "$account_name"
|
|
453
|
-
|
|
454
|
-
print_info "Getting recording: $recording_sid"
|
|
455
|
-
local response
|
|
456
|
-
response=$(twilio_api GET "/Recordings/${recording_sid}.json")
|
|
457
|
-
|
|
458
|
-
echo "$response" | jq -r '"SID: \(.sid)\nCall SID: \(.call_sid)\nDuration: \(.duration)s\nDate: \(.date_created)\nStatus: \(.status)"'
|
|
459
|
-
|
|
460
|
-
echo ""
|
|
461
|
-
echo "Download URL: https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}/Recordings/${recording_sid}.mp3"
|
|
462
|
-
return 0
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
# Download recording
|
|
466
|
-
download_recording() {
|
|
467
|
-
local account_name="$1"
|
|
468
|
-
local recording_sid="$2"
|
|
469
|
-
local output_dir="${3:-.}"
|
|
470
|
-
|
|
471
|
-
set_twilio_credentials "$account_name"
|
|
472
|
-
|
|
473
|
-
local url="https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}/Recordings/${recording_sid}.mp3"
|
|
474
|
-
local output_file="${output_dir}/${recording_sid}.mp3"
|
|
475
|
-
|
|
476
|
-
print_info "Downloading recording to: $output_file"
|
|
477
|
-
curl -s -o "$output_file" -u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}" "$url"
|
|
478
|
-
|
|
479
|
-
if [[ -f "$output_file" ]]; then
|
|
480
|
-
print_success "Recording downloaded: $output_file"
|
|
481
|
-
else
|
|
482
|
-
print_error "Failed to download recording"
|
|
483
|
-
fi
|
|
484
|
-
return 0
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
# List transcriptions
|
|
488
|
-
list_transcriptions() {
|
|
489
|
-
local account_name="$1"
|
|
490
|
-
local limit="${2:-20}"
|
|
491
|
-
|
|
492
|
-
set_twilio_credentials "$account_name"
|
|
493
|
-
|
|
494
|
-
print_info "Transcriptions for account: $account_name"
|
|
495
|
-
local response
|
|
496
|
-
response=$(twilio_api GET "/Transcriptions.json?PageSize=$limit")
|
|
497
|
-
|
|
498
|
-
echo "$response" | jq -r '.transcriptions[] | "\(.date_created) | \(.sid) | \(.status) | \(.recording_sid)"'
|
|
499
|
-
return 0
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
# Get transcription
|
|
503
|
-
get_transcription() {
|
|
504
|
-
local account_name="$1"
|
|
505
|
-
local transcription_sid="$2"
|
|
506
|
-
|
|
507
|
-
set_twilio_credentials "$account_name"
|
|
508
|
-
|
|
509
|
-
print_info "Getting transcription: $transcription_sid"
|
|
510
|
-
local response
|
|
511
|
-
response=$(twilio_api GET "/Transcriptions/${transcription_sid}.json")
|
|
512
|
-
|
|
513
|
-
echo "$response" | jq -r '"SID: \(.sid)\nRecording SID: \(.recording_sid)\nStatus: \(.status)\nDate: \(.date_created)\n\nTranscription:\n\(.transcription_text)"'
|
|
514
|
-
return 0
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
# Send WhatsApp message
|
|
518
|
-
send_whatsapp() {
|
|
519
|
-
local account_name="$1"
|
|
520
|
-
local to="$2"
|
|
521
|
-
local body="$3"
|
|
522
|
-
local from="${4:-}"
|
|
523
|
-
|
|
524
|
-
set_twilio_credentials "$account_name"
|
|
525
|
-
|
|
526
|
-
# WhatsApp numbers need whatsapp: prefix
|
|
527
|
-
if [[ ! "$to" =~ ^whatsapp: ]]; then
|
|
528
|
-
to="whatsapp:$to"
|
|
529
|
-
fi
|
|
530
|
-
|
|
531
|
-
if [[ -z "$from" ]]; then
|
|
532
|
-
# Get WhatsApp sender from config
|
|
533
|
-
from=$(jq -r ".accounts.\"$account_name\".whatsapp_from // empty" "$CONFIG_FILE")
|
|
534
|
-
fi
|
|
535
|
-
|
|
536
|
-
if [[ -z "$from" ]]; then
|
|
537
|
-
print_error "No WhatsApp sender configured for account '$account_name'"
|
|
538
|
-
return 1
|
|
539
|
-
fi
|
|
540
|
-
|
|
541
|
-
if [[ ! "$from" =~ ^whatsapp: ]]; then
|
|
542
|
-
from="whatsapp:$from"
|
|
543
|
-
fi
|
|
544
|
-
|
|
545
|
-
print_info "Sending WhatsApp message from $from to $to"
|
|
546
|
-
|
|
547
|
-
local response
|
|
548
|
-
response=$(twilio_api POST "/Messages.json" \
|
|
549
|
-
-d "To=$to" \
|
|
550
|
-
-d "From=$from" \
|
|
551
|
-
-d "Body=$body")
|
|
552
|
-
|
|
553
|
-
if echo "$response" | jq -e '.sid' > /dev/null 2>&1; then
|
|
554
|
-
print_success "WhatsApp message sent successfully!"
|
|
555
|
-
echo "$response" | jq -r '"SID: \(.sid)\nStatus: \(.status)"'
|
|
556
|
-
else
|
|
557
|
-
print_error "Failed to send WhatsApp message"
|
|
558
|
-
echo "$response" | jq -r '.message // .'
|
|
559
|
-
fi
|
|
560
|
-
return 0
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
# Lookup phone number
|
|
564
|
-
lookup_number() {
|
|
565
|
-
local account_name="$1"
|
|
566
|
-
local phone_number="$2"
|
|
567
|
-
local lookup_type="${3:-}"
|
|
568
|
-
|
|
569
|
-
set_twilio_credentials "$account_name"
|
|
570
|
-
|
|
571
|
-
local url="https://lookups.twilio.com/v1/PhoneNumbers/${phone_number}"
|
|
572
|
-
|
|
573
|
-
if [[ -n "$lookup_type" ]]; then
|
|
574
|
-
url="${url}?Type=${lookup_type}"
|
|
575
|
-
fi
|
|
576
|
-
|
|
577
|
-
print_info "Looking up: $phone_number"
|
|
578
|
-
local response
|
|
579
|
-
response=$(curl -s -X GET "$url" -u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}")
|
|
580
|
-
|
|
581
|
-
echo "$response" | jq '.'
|
|
582
|
-
return 0
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
# Verify - Create service
|
|
586
|
-
verify_create_service() {
|
|
587
|
-
local account_name="$1"
|
|
588
|
-
local friendly_name="$2"
|
|
589
|
-
|
|
590
|
-
set_twilio_credentials "$account_name"
|
|
591
|
-
|
|
592
|
-
print_info "Creating Verify service: $friendly_name"
|
|
593
|
-
|
|
594
|
-
local response
|
|
595
|
-
response=$(curl -s -X POST "https://verify.twilio.com/v2/Services" \
|
|
596
|
-
-u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}" \
|
|
597
|
-
-d "FriendlyName=$friendly_name")
|
|
598
|
-
|
|
599
|
-
if echo "$response" | jq -e '.sid' > /dev/null 2>&1; then
|
|
600
|
-
print_success "Verify service created!"
|
|
601
|
-
echo "$response" | jq -r '"SID: \(.sid)\nName: \(.friendly_name)"'
|
|
602
|
-
print_info "Save this SID in your config as 'verify_service_sid'"
|
|
603
|
-
else
|
|
604
|
-
print_error "Failed to create Verify service"
|
|
605
|
-
echo "$response" | jq -r '.message // .'
|
|
606
|
-
fi
|
|
607
|
-
return 0
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
# Verify - Send code
|
|
611
|
-
verify_send() {
|
|
612
|
-
local account_name="$1"
|
|
613
|
-
local to="$2"
|
|
614
|
-
local channel="${3:-sms}"
|
|
615
|
-
|
|
616
|
-
set_twilio_credentials "$account_name"
|
|
617
|
-
|
|
618
|
-
local service_sid
|
|
619
|
-
service_sid=$(jq -r ".accounts.\"$account_name\".verify_service_sid // empty" "$CONFIG_FILE")
|
|
620
|
-
|
|
621
|
-
if [[ -z "$service_sid" ]]; then
|
|
622
|
-
print_error "No Verify service SID configured for account '$account_name'"
|
|
623
|
-
print_info "Create one with: $0 verify-create-service $account_name \"Service Name\""
|
|
624
|
-
return 1
|
|
625
|
-
fi
|
|
626
|
-
|
|
627
|
-
print_info "Sending verification code to $to via $channel"
|
|
628
|
-
|
|
629
|
-
local response
|
|
630
|
-
response=$(curl -s -X POST "https://verify.twilio.com/v2/Services/${service_sid}/Verifications" \
|
|
631
|
-
-u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}" \
|
|
632
|
-
-d "To=$to" \
|
|
633
|
-
-d "Channel=$channel")
|
|
634
|
-
|
|
635
|
-
if echo "$response" | jq -e '.sid' > /dev/null 2>&1; then
|
|
636
|
-
print_success "Verification code sent!"
|
|
637
|
-
echo "$response" | jq -r '"Status: \(.status)\nChannel: \(.channel)\nTo: \(.to)"'
|
|
638
|
-
else
|
|
639
|
-
print_error "Failed to send verification code"
|
|
640
|
-
echo "$response" | jq -r '.message // .'
|
|
641
|
-
fi
|
|
642
|
-
return 0
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
# Verify - Check code
|
|
646
|
-
verify_check() {
|
|
647
|
-
local account_name="$1"
|
|
648
|
-
local to="$2"
|
|
649
|
-
local code="$3"
|
|
650
|
-
|
|
651
|
-
set_twilio_credentials "$account_name"
|
|
652
|
-
|
|
653
|
-
local service_sid
|
|
654
|
-
service_sid=$(jq -r ".accounts.\"$account_name\".verify_service_sid // empty" "$CONFIG_FILE")
|
|
655
|
-
|
|
656
|
-
if [[ -z "$service_sid" ]]; then
|
|
657
|
-
print_error "No Verify service SID configured for account '$account_name'"
|
|
658
|
-
return 1
|
|
659
|
-
fi
|
|
660
|
-
|
|
661
|
-
print_info "Checking verification code for $to"
|
|
662
|
-
|
|
663
|
-
local response
|
|
664
|
-
response=$(curl -s -X POST "https://verify.twilio.com/v2/Services/${service_sid}/VerificationCheck" \
|
|
665
|
-
-u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}" \
|
|
666
|
-
-d "To=$to" \
|
|
667
|
-
-d "Code=$code")
|
|
668
|
-
|
|
669
|
-
local status
|
|
670
|
-
status=$(echo "$response" | jq -r '.status')
|
|
671
|
-
|
|
672
|
-
if [[ "$status" == "approved" ]]; then
|
|
673
|
-
print_success "Verification successful!"
|
|
674
|
-
else
|
|
675
|
-
print_error "Verification failed"
|
|
676
|
-
fi
|
|
677
|
-
|
|
678
|
-
echo "$response" | jq -r '"Status: \(.status)\nTo: \(.to)\nValid: \(.valid)"'
|
|
679
|
-
return 0
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
# Get usage summary
|
|
683
|
-
get_usage() {
|
|
684
|
-
local account_name="$1"
|
|
685
|
-
local period="${2:-today}"
|
|
686
|
-
|
|
687
|
-
set_twilio_credentials "$account_name"
|
|
688
|
-
|
|
689
|
-
local start_date end_date
|
|
690
|
-
case "$period" in
|
|
691
|
-
today)
|
|
692
|
-
start_date=$(date +%Y-%m-%d)
|
|
693
|
-
end_date=$(date +%Y-%m-%d)
|
|
694
|
-
;;
|
|
695
|
-
week)
|
|
696
|
-
start_date=$(date -v-7d +%Y-%m-%d 2>/dev/null || date -d "7 days ago" +%Y-%m-%d)
|
|
697
|
-
end_date=$(date +%Y-%m-%d)
|
|
698
|
-
;;
|
|
699
|
-
month)
|
|
700
|
-
start_date=$(date -v-30d +%Y-%m-%d 2>/dev/null || date -d "30 days ago" +%Y-%m-%d)
|
|
701
|
-
end_date=$(date +%Y-%m-%d)
|
|
702
|
-
;;
|
|
703
|
-
*)
|
|
704
|
-
start_date="$period"
|
|
705
|
-
end_date=$(date +%Y-%m-%d)
|
|
706
|
-
;;
|
|
707
|
-
esac
|
|
708
|
-
|
|
709
|
-
print_info "Usage for account: $account_name ($start_date to $end_date)"
|
|
710
|
-
local response
|
|
711
|
-
response=$(twilio_api GET "/Usage/Records.json?StartDate=$start_date&EndDate=$end_date")
|
|
712
|
-
|
|
713
|
-
echo "$response" | jq -r '.usage_records[] | select(.count != "0") | "\(.category): \(.count) (\(.price) \(.price_unit))"'
|
|
714
|
-
return 0
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
# Audit account
|
|
718
|
-
audit_account() {
|
|
719
|
-
local account_name="$1"
|
|
720
|
-
set_twilio_credentials "$account_name"
|
|
721
|
-
|
|
722
|
-
print_info "=== Twilio Account Audit: $account_name ==="
|
|
723
|
-
echo ""
|
|
724
|
-
|
|
725
|
-
print_info "Account Balance:"
|
|
726
|
-
get_balance "$account_name"
|
|
727
|
-
echo ""
|
|
728
|
-
|
|
729
|
-
print_info "Phone Numbers:"
|
|
730
|
-
list_numbers "$account_name"
|
|
731
|
-
echo ""
|
|
732
|
-
|
|
733
|
-
print_info "Recent Messages (last 5):"
|
|
734
|
-
list_messages "$account_name" 5
|
|
735
|
-
echo ""
|
|
736
|
-
|
|
737
|
-
print_info "Recent Calls (last 5):"
|
|
738
|
-
list_calls "$account_name" 5
|
|
739
|
-
echo ""
|
|
740
|
-
|
|
741
|
-
print_info "Usage Summary (this month):"
|
|
742
|
-
get_usage "$account_name" month
|
|
743
|
-
|
|
744
|
-
return 0
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
# Show help
|
|
748
|
-
show_help() {
|
|
749
|
-
cat << EOF
|
|
750
|
-
Twilio Helper Script - Comprehensive Twilio management for AI assistants
|
|
751
|
-
|
|
752
|
-
$USAGE_COMMAND_OPTIONS
|
|
753
|
-
|
|
754
|
-
ACCOUNT COMMANDS:
|
|
755
|
-
accounts List all configured accounts
|
|
756
|
-
balance <account> Get account balance
|
|
757
|
-
usage <account> [period] Get usage summary (today|week|month)
|
|
758
|
-
audit <account> Full account audit
|
|
759
|
-
status <account> Check account status
|
|
760
|
-
|
|
761
|
-
PHONE NUMBER COMMANDS:
|
|
762
|
-
numbers <account> List owned phone numbers
|
|
763
|
-
search-numbers <account> <country> [options]
|
|
764
|
-
Search available numbers
|
|
765
|
-
--area-code <code> Filter by area code
|
|
766
|
-
--contains <digits> Filter by containing digits
|
|
767
|
-
--sms Must support SMS
|
|
768
|
-
--voice Must support voice
|
|
769
|
-
--mms Must support MMS
|
|
770
|
-
buy-number <account> <number> Purchase a phone number
|
|
771
|
-
release-number <account> <number> Release a phone number
|
|
772
|
-
|
|
773
|
-
SMS COMMANDS:
|
|
774
|
-
sms <account> <to> <body> [from] Send SMS message
|
|
775
|
-
messages <account> [limit] List recent messages
|
|
776
|
-
message-status <account> <sid> Get message status
|
|
777
|
-
|
|
778
|
-
VOICE COMMANDS:
|
|
779
|
-
call <account> <to> [options] Make outbound call
|
|
780
|
-
--from <number> From number
|
|
781
|
-
--twiml <xml> TwiML instructions
|
|
782
|
-
--url <url> TwiML URL
|
|
783
|
-
--record Record the call
|
|
784
|
-
calls <account> [limit] List recent calls
|
|
785
|
-
call-details <account> <sid> Get call details
|
|
786
|
-
|
|
787
|
-
RECORDING COMMANDS:
|
|
788
|
-
recordings <account> [limit] List recordings
|
|
789
|
-
recording <account> <sid> Get recording details
|
|
790
|
-
download-recording <account> <sid> [dir]
|
|
791
|
-
Download recording MP3
|
|
792
|
-
|
|
793
|
-
TRANSCRIPTION COMMANDS:
|
|
794
|
-
transcriptions <account> [limit] List transcriptions
|
|
795
|
-
transcription <account> <sid> Get transcription text
|
|
796
|
-
|
|
797
|
-
WHATSAPP COMMANDS:
|
|
798
|
-
whatsapp <account> <to> <body> Send WhatsApp message
|
|
799
|
-
|
|
800
|
-
VERIFY (2FA) COMMANDS:
|
|
801
|
-
verify-create-service <account> <name>
|
|
802
|
-
Create Verify service
|
|
803
|
-
verify-send <account> <to> [channel]
|
|
804
|
-
Send verification code (sms|call|email)
|
|
805
|
-
verify-check <account> <to> <code>
|
|
806
|
-
Check verification code
|
|
807
|
-
|
|
808
|
-
LOOKUP COMMANDS:
|
|
809
|
-
lookup <account> <number> [type] Lookup phone number info
|
|
810
|
-
Types: carrier, caller-name
|
|
811
|
-
|
|
812
|
-
EXAMPLES:
|
|
813
|
-
$0 accounts
|
|
814
|
-
$0 sms production "+1234567890" "Hello!"
|
|
815
|
-
$0 search-numbers production US --area-code 415 --sms
|
|
816
|
-
$0 call production "+1234567890" --record
|
|
817
|
-
$0 verify-send production "+1234567890" sms
|
|
818
|
-
$0 audit production
|
|
819
|
-
|
|
820
|
-
CONFIGURATION:
|
|
821
|
-
Config file: configs/twilio-config.json
|
|
822
|
-
Template: configs/twilio-config.json.txt
|
|
823
|
-
|
|
824
|
-
For more information, see: .agent/services/communications/twilio.md
|
|
825
|
-
EOF
|
|
826
|
-
return 0
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
# Main function
|
|
830
|
-
main() {
|
|
831
|
-
local command="${1:-help}"
|
|
832
|
-
local account_name="${2:-}"
|
|
833
|
-
shift 2 2>/dev/null || true
|
|
834
|
-
|
|
835
|
-
check_dependencies
|
|
836
|
-
load_config
|
|
837
|
-
|
|
838
|
-
case "$command" in
|
|
839
|
-
"accounts")
|
|
840
|
-
list_accounts
|
|
841
|
-
;;
|
|
842
|
-
"balance")
|
|
843
|
-
get_balance "$account_name"
|
|
844
|
-
;;
|
|
845
|
-
"numbers")
|
|
846
|
-
list_numbers "$account_name"
|
|
847
|
-
;;
|
|
848
|
-
"search-numbers")
|
|
849
|
-
local country="$1"
|
|
850
|
-
shift
|
|
851
|
-
search_numbers "$account_name" "$country" "$@"
|
|
852
|
-
;;
|
|
853
|
-
"buy-number")
|
|
854
|
-
buy_number "$account_name" "$1"
|
|
855
|
-
;;
|
|
856
|
-
"sms")
|
|
857
|
-
send_sms "$account_name" "$1" "$2" "${3:-}"
|
|
858
|
-
;;
|
|
859
|
-
"messages")
|
|
860
|
-
list_messages "$account_name" "${1:-20}"
|
|
861
|
-
;;
|
|
862
|
-
"message-status")
|
|
863
|
-
get_message_status "$account_name" "$1"
|
|
864
|
-
;;
|
|
865
|
-
"call")
|
|
866
|
-
make_call "$account_name" "$1" "${@:2}"
|
|
867
|
-
;;
|
|
868
|
-
"calls")
|
|
869
|
-
list_calls "$account_name" "${1:-20}"
|
|
870
|
-
;;
|
|
871
|
-
"recordings")
|
|
872
|
-
list_recordings "$account_name" "${1:-20}"
|
|
873
|
-
;;
|
|
874
|
-
"recording")
|
|
875
|
-
get_recording "$account_name" "$1"
|
|
876
|
-
;;
|
|
877
|
-
"download-recording")
|
|
878
|
-
download_recording "$account_name" "$1" "${2:-.}"
|
|
879
|
-
;;
|
|
880
|
-
"transcriptions")
|
|
881
|
-
list_transcriptions "$account_name" "${1:-20}"
|
|
882
|
-
;;
|
|
883
|
-
"transcription")
|
|
884
|
-
get_transcription "$account_name" "$1"
|
|
885
|
-
;;
|
|
886
|
-
"whatsapp")
|
|
887
|
-
send_whatsapp "$account_name" "$1" "$2"
|
|
888
|
-
;;
|
|
889
|
-
"lookup")
|
|
890
|
-
lookup_number "$account_name" "$1" "${2:-}"
|
|
891
|
-
;;
|
|
892
|
-
"verify-create-service")
|
|
893
|
-
verify_create_service "$account_name" "$1"
|
|
894
|
-
;;
|
|
895
|
-
"verify-send")
|
|
896
|
-
verify_send "$account_name" "$1" "${2:-sms}"
|
|
897
|
-
;;
|
|
898
|
-
"verify-check")
|
|
899
|
-
verify_check "$account_name" "$1" "$2"
|
|
900
|
-
;;
|
|
901
|
-
"usage")
|
|
902
|
-
get_usage "$account_name" "${1:-today}"
|
|
903
|
-
;;
|
|
904
|
-
"audit")
|
|
905
|
-
audit_account "$account_name"
|
|
906
|
-
;;
|
|
907
|
-
"status")
|
|
908
|
-
get_balance "$account_name"
|
|
909
|
-
;;
|
|
910
|
-
"help"|*)
|
|
911
|
-
show_help
|
|
912
|
-
;;
|
|
913
|
-
esac
|
|
914
|
-
return 0
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
main "$@"
|