@signalwire/sdk 2.0.4 → 3.5.0
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/CHANGELOG.md +785 -0
- package/LICENSE +21 -0
- package/README.md +163 -68
- package/dist/AGENTS.md +13 -0
- package/dist/AgentBase.d.ts +550 -163
- package/dist/AgentBase.js +1640 -514
- package/dist/AgentBase.js.map +1 -1
- package/dist/AgentServer.d.ts +21 -0
- package/dist/AgentServer.js +154 -47
- package/dist/AgentServer.js.map +1 -1
- package/dist/AuthHandler.d.ts +14 -2
- package/dist/AuthHandler.js +7 -2
- package/dist/AuthHandler.js.map +1 -1
- package/dist/ConfigLoader.d.ts +5 -13
- package/dist/ConfigLoader.js +15 -29
- package/dist/ConfigLoader.js.map +1 -1
- package/dist/ContextBuilder.d.ts +202 -9
- package/dist/ContextBuilder.js +219 -36
- package/dist/ContextBuilder.js.map +1 -1
- package/dist/DataMap.d.ts +158 -45
- package/dist/DataMap.js +167 -52
- package/dist/DataMap.js.map +1 -1
- package/dist/FunctionResult.d.ts +277 -83
- package/dist/FunctionResult.js +444 -116
- package/dist/FunctionResult.js.map +1 -1
- package/dist/Logger.d.ts +30 -5
- package/dist/Logger.js +77 -19
- package/dist/Logger.js.map +1 -1
- package/dist/POM/PromptObjectModel.d.ts +163 -0
- package/dist/POM/PromptObjectModel.js +481 -0
- package/dist/POM/PromptObjectModel.js.map +1 -0
- package/dist/ParameterSchema.d.ts +306 -0
- package/dist/ParameterSchema.js +251 -0
- package/dist/ParameterSchema.js.map +1 -0
- package/dist/PlatformContracts.d.ts +21 -0
- package/dist/PlatformContracts.generated.d.ts +109 -0
- package/dist/PlatformContracts.generated.js +8 -0
- package/dist/PlatformContracts.generated.js.map +1 -0
- package/dist/PlatformContracts.js +2 -0
- package/dist/PlatformContracts.js.map +1 -0
- package/dist/PomBuilder.d.ts +28 -0
- package/dist/PomBuilder.js +81 -3
- package/dist/PomBuilder.js.map +1 -1
- package/dist/PostPrompt.d.ts +110 -0
- package/dist/PostPrompt.js +204 -0
- package/dist/PostPrompt.js.map +1 -0
- package/dist/PromptManager.d.ts +29 -1
- package/dist/PromptManager.js +37 -1
- package/dist/PromptManager.js.map +1 -1
- package/dist/PublicFetch.d.ts +132 -0
- package/dist/PublicFetch.js +311 -0
- package/dist/PublicFetch.js.map +1 -0
- package/dist/RobotsTxt.d.ts +41 -0
- package/dist/RobotsTxt.js +152 -0
- package/dist/RobotsTxt.js.map +1 -0
- package/dist/SWMLHandler.js.map +1 -1
- package/dist/SWMLService.d.ts +265 -66
- package/dist/SWMLService.js +652 -112
- package/dist/SWMLService.js.map +1 -1
- package/dist/SchemaUtils.d.ts +115 -2
- package/dist/SchemaUtils.js +444 -12
- package/dist/SchemaUtils.js.map +1 -1
- package/dist/SecurityUtils.d.ts +55 -8
- package/dist/SecurityUtils.js +162 -49
- package/dist/SecurityUtils.js.map +1 -1
- package/dist/ServerlessAdapter.d.ts +156 -7
- package/dist/ServerlessAdapter.js +399 -42
- package/dist/ServerlessAdapter.js.map +1 -1
- package/dist/SessionManager.d.ts +11 -2
- package/dist/SessionManager.js +50 -18
- package/dist/SessionManager.js.map +1 -1
- package/dist/SslConfig.d.ts +2 -1
- package/dist/SslConfig.js +4 -1
- package/dist/SslConfig.js.map +1 -1
- package/dist/SwaigActions.generated.d.ts +23 -0
- package/dist/SwaigActions.generated.js +8 -0
- package/dist/SwaigActions.generated.js.map +1 -0
- package/dist/SwaigContracts.d.ts +15 -0
- package/dist/SwaigContracts.generated.d.ts +264 -0
- package/dist/SwaigContracts.generated.js +12 -0
- package/dist/SwaigContracts.generated.js.map +1 -0
- package/dist/SwaigContracts.js +2 -0
- package/dist/SwaigContracts.js.map +1 -0
- package/dist/SwaigFunction.d.ts +110 -4
- package/dist/SwaigFunction.js +151 -19
- package/dist/SwaigFunction.js.map +1 -1
- package/dist/SwmlBuilder.d.ts +68 -19
- package/dist/SwmlBuilder.js +74 -38
- package/dist/SwmlBuilder.js.map +1 -1
- package/dist/SwmlVerbMethods.generated.d.ts +41 -4
- package/dist/SwmlVerbMethods.generated.js +1 -1
- package/dist/TypeInference.d.ts +39 -3
- package/dist/TypeInference.js +256 -16
- package/dist/TypeInference.js.map +1 -1
- package/dist/WebService.d.ts +79 -11
- package/dist/WebService.js +320 -109
- package/dist/WebService.js.map +1 -1
- package/dist/WebhookMiddleware.d.ts +119 -0
- package/dist/WebhookMiddleware.js +271 -0
- package/dist/WebhookMiddleware.js.map +1 -0
- package/dist/WebhookValidator.d.ts +92 -0
- package/dist/WebhookValidator.js +409 -0
- package/dist/WebhookValidator.js.map +1 -0
- package/dist/agents/BedrockAgent.d.ts +162 -0
- package/dist/agents/BedrockAgent.js +323 -0
- package/dist/agents/BedrockAgent.js.map +1 -0
- package/dist/ai-chat/AIChatClient.d.ts +316 -0
- package/dist/ai-chat/AIChatClient.js +535 -0
- package/dist/ai-chat/AIChatClient.js.map +1 -0
- package/dist/ai-chat/ChatGateway.d.ts +408 -0
- package/dist/ai-chat/ChatGateway.js +747 -0
- package/dist/ai-chat/ChatGateway.js.map +1 -0
- package/dist/ai-chat/HandoffRouter.d.ts +282 -0
- package/dist/ai-chat/HandoffRouter.js +518 -0
- package/dist/ai-chat/HandoffRouter.js.map +1 -0
- package/dist/ai-chat/index.d.ts +12 -0
- package/dist/ai-chat/index.js +10 -0
- package/dist/ai-chat/index.js.map +1 -0
- package/dist/capabilities.d.ts +64 -0
- package/dist/capabilities.js +95 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/cli/agent-loader.d.ts +32 -6
- package/dist/cli/agent-loader.js +95 -34
- package/dist/cli/agent-loader.js.map +1 -1
- package/dist/cli/datamap-exec.d.ts +175 -0
- package/dist/cli/datamap-exec.js +1284 -0
- package/dist/cli/datamap-exec.js.map +1 -0
- package/dist/cli/function-args.d.ts +40 -0
- package/dist/cli/function-args.js +146 -0
- package/dist/cli/function-args.js.map +1 -0
- package/dist/cli/simulation.d.ts +99 -0
- package/dist/cli/simulation.js +490 -0
- package/dist/cli/simulation.js.map +1 -0
- package/dist/cli/swaig-test.d.ts +12 -25
- package/dist/cli/swaig-test.js +935 -367
- package/dist/cli/swaig-test.js.map +1 -1
- package/dist/cli/tsdocs/agentsNote.d.ts +30 -0
- package/dist/cli/tsdocs/agentsNote.js +92 -0
- package/dist/cli/tsdocs/agentsNote.js.map +1 -0
- package/dist/cli/tsdocs/api-index.json +1 -0
- package/dist/cli/tsdocs/api.d.ts +91 -0
- package/dist/cli/tsdocs/api.js +372 -0
- package/dist/cli/tsdocs/api.js.map +1 -0
- package/dist/cli/tsdocs/apiTypes.d.ts +64 -0
- package/dist/cli/tsdocs/apiTypes.js +7 -0
- package/dist/cli/tsdocs/apiTypes.js.map +1 -0
- package/dist/cli/tsdocs/bin.d.ts +6 -0
- package/dist/cli/tsdocs/bin.js +23 -0
- package/dist/cli/tsdocs/bin.js.map +1 -0
- package/dist/cli/tsdocs/files.d.ts +108 -0
- package/dist/cli/tsdocs/files.js +287 -0
- package/dist/cli/tsdocs/files.js.map +1 -0
- package/dist/cli/tsdocs/index.d.ts +28 -0
- package/dist/cli/tsdocs/index.js +307 -0
- package/dist/cli/tsdocs/index.js.map +1 -0
- package/dist/cli/tsdocs/live.d.ts +41 -0
- package/dist/cli/tsdocs/live.js +202 -0
- package/dist/cli/tsdocs/live.js.map +1 -0
- package/dist/cli/tsdocs/locate.d.ts +51 -0
- package/dist/cli/tsdocs/locate.js +75 -0
- package/dist/cli/tsdocs/locate.js.map +1 -0
- package/dist/cli/tsdocs/render.d.ts +75 -0
- package/dist/cli/tsdocs/render.js +323 -0
- package/dist/cli/tsdocs/render.js.map +1 -0
- package/dist/cli/tsdocs/topics.d.ts +43 -0
- package/dist/cli/tsdocs/topics.js +916 -0
- package/dist/cli/tsdocs/topics.js.map +1 -0
- package/dist/index.d.ts +102 -39
- package/dist/index.js +107 -30
- package/dist/index.js.map +1 -1
- package/dist/livewire/index.d.ts +229 -155
- package/dist/livewire/index.js +298 -195
- package/dist/livewire/index.js.map +1 -1
- package/dist/llms.txt +65 -0
- package/dist/prefabs/CallSessionStore.d.ts +52 -0
- package/dist/prefabs/CallSessionStore.js +72 -0
- package/dist/prefabs/CallSessionStore.js.map +1 -0
- package/dist/prefabs/ConciergeAgent.d.ts +13 -1
- package/dist/prefabs/ConciergeAgent.js +36 -31
- package/dist/prefabs/ConciergeAgent.js.map +1 -1
- package/dist/prefabs/FAQBotAgent.d.ts +9 -1
- package/dist/prefabs/FAQBotAgent.js +113 -47
- package/dist/prefabs/FAQBotAgent.js.map +1 -1
- package/dist/prefabs/InfoGathererAgent.d.ts +22 -3
- package/dist/prefabs/InfoGathererAgent.js +67 -58
- package/dist/prefabs/InfoGathererAgent.js.map +1 -1
- package/dist/prefabs/ReceptionistAgent.d.ts +16 -5
- package/dist/prefabs/ReceptionistAgent.js +39 -31
- package/dist/prefabs/ReceptionistAgent.js.map +1 -1
- package/dist/prefabs/SurveyAgent.d.ts +22 -4
- package/dist/prefabs/SurveyAgent.js +84 -68
- package/dist/prefabs/SurveyAgent.js.map +1 -1
- package/dist/relay/Action.d.ts +44 -21
- package/dist/relay/Action.js +75 -17
- package/dist/relay/Action.js.map +1 -1
- package/dist/relay/Call.d.ts +312 -47
- package/dist/relay/Call.js +369 -18
- package/dist/relay/Call.js.map +1 -1
- package/dist/relay/Deferred.js.map +1 -1
- package/dist/relay/Message.d.ts +26 -5
- package/dist/relay/Message.js +36 -6
- package/dist/relay/Message.js.map +1 -1
- package/dist/relay/RelayClient.d.ts +79 -14
- package/dist/relay/RelayClient.js +268 -61
- package/dist/relay/RelayClient.js.map +1 -1
- package/dist/relay/RelayError.d.ts +14 -0
- package/dist/relay/RelayError.js +15 -0
- package/dist/relay/RelayError.js.map +1 -1
- package/dist/relay/RelayEvent.d.ts +96 -65
- package/dist/relay/RelayEvent.js +85 -56
- package/dist/relay/RelayEvent.js.map +1 -1
- package/dist/relay/closedSets.d.ts +111 -0
- package/dist/relay/closedSets.js +83 -0
- package/dist/relay/closedSets.js.map +1 -0
- package/dist/relay/index.d.ts +3 -1
- package/dist/relay/index.js +1 -0
- package/dist/relay/index.js.map +1 -1
- package/dist/relay/normalize.js.map +1 -1
- package/dist/relay/protocol.types.generated.d.ts +1195 -0
- package/dist/relay/protocol.types.generated.js +8 -0
- package/dist/relay/protocol.types.generated.js.map +1 -0
- package/dist/relay/types.d.ts +81 -39
- package/dist/rest/HttpClient.d.ts +36 -8
- package/dist/rest/HttpClient.js +233 -40
- package/dist/rest/HttpClient.js.map +1 -1
- package/dist/rest/RequestOptions.d.ts +110 -0
- package/dist/rest/RequestOptions.js +113 -0
- package/dist/rest/RequestOptions.js.map +1 -0
- package/dist/rest/RestError.d.ts +52 -6
- package/dist/rest/RestError.js +89 -5
- package/dist/rest/RestError.js.map +1 -1
- package/dist/rest/base/CrudResource.d.ts +16 -26
- package/dist/rest/base/CrudResource.js +19 -33
- package/dist/rest/base/CrudResource.js.map +1 -1
- package/dist/rest/base/CrudWithAddresses.d.ts +3 -2
- package/dist/rest/base/CrudWithAddresses.js +2 -2
- package/dist/rest/base/CrudWithAddresses.js.map +1 -1
- package/dist/rest/base/FabricResource.d.ts +15 -0
- package/dist/rest/base/FabricResource.js +16 -0
- package/dist/rest/base/FabricResource.js.map +1 -0
- package/dist/rest/base/ReadResource.d.ts +62 -0
- package/dist/rest/base/ReadResource.js +69 -0
- package/dist/rest/base/ReadResource.js.map +1 -0
- package/dist/rest/callHandler.d.ts +63 -0
- package/dist/rest/callHandler.js +62 -0
- package/dist/rest/callHandler.js.map +1 -0
- package/dist/rest/index.d.ts +19 -76
- package/dist/rest/index.js +49 -120
- package/dist/rest/index.js.map +1 -1
- package/dist/rest/namespaces/_client_tree_generated.d.ts +103 -0
- package/dist/rest/namespaces/_client_tree_generated.js +171 -0
- package/dist/rest/namespaces/_client_tree_generated.js.map +1 -0
- package/dist/rest/namespaces/addresses.d.ts +3 -42
- package/dist/rest/namespaces/addresses.js +3 -50
- package/dist/rest/namespaces/addresses.js.map +1 -1
- package/dist/rest/namespaces/calling.d.ts +6 -378
- package/dist/rest/namespaces/calling.js +6 -473
- package/dist/rest/namespaces/calling.js.map +1 -1
- package/dist/rest/namespaces/calling.resources.generated.d.ts +165 -0
- package/dist/rest/namespaces/calling.resources.generated.js +477 -0
- package/dist/rest/namespaces/calling.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/calling.types.generated.d.ts +2917 -0
- package/dist/rest/namespaces/calling.types.generated.js +8 -0
- package/dist/rest/namespaces/calling.types.generated.js.map +1 -0
- package/dist/rest/namespaces/chat.d.ts +4 -18
- package/dist/rest/namespaces/chat.js +4 -21
- package/dist/rest/namespaces/chat.js.map +1 -1
- package/dist/rest/namespaces/chat.resources.generated.d.ts +12 -0
- package/dist/rest/namespaces/chat.resources.generated.js +29 -0
- package/dist/rest/namespaces/chat.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/chat.types.generated.d.ts +56 -0
- package/dist/rest/namespaces/chat.types.generated.js +8 -0
- package/dist/rest/namespaces/chat.types.generated.js.map +1 -0
- package/dist/rest/namespaces/datasphere.d.ts +6 -62
- package/dist/rest/namespaces/datasphere.js +6 -72
- package/dist/rest/namespaces/datasphere.js.map +1 -1
- package/dist/rest/namespaces/datasphere.resources.generated.d.ts +25 -0
- package/dist/rest/namespaces/datasphere.resources.generated.js +50 -0
- package/dist/rest/namespaces/datasphere.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/datasphere.types.generated.d.ts +180 -0
- package/dist/rest/namespaces/datasphere.types.generated.js +8 -0
- package/dist/rest/namespaces/datasphere.types.generated.js.map +1 -0
- package/dist/rest/namespaces/fabric.d.ts +11 -273
- package/dist/rest/namespaces/fabric.js +14 -363
- package/dist/rest/namespaces/fabric.js.map +1 -1
- package/dist/rest/namespaces/fabric.resources.generated.d.ts +195 -0
- package/dist/rest/namespaces/fabric.resources.generated.js +399 -0
- package/dist/rest/namespaces/fabric.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/fabric.types.generated.d.ts +4557 -0
- package/dist/rest/namespaces/fabric.types.generated.js +8 -0
- package/dist/rest/namespaces/fabric.types.generated.js.map +1 -0
- package/dist/rest/namespaces/fax.resources.generated.d.ts +6 -0
- package/dist/rest/namespaces/fax.resources.generated.js +14 -0
- package/dist/rest/namespaces/fax.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/fax.types.generated.d.ts +131 -0
- package/dist/rest/namespaces/fax.types.generated.js +8 -0
- package/dist/rest/namespaces/fax.types.generated.js.map +1 -0
- package/dist/rest/namespaces/imported-numbers.d.ts +3 -18
- package/dist/rest/namespaces/imported-numbers.js +3 -21
- package/dist/rest/namespaces/imported-numbers.js.map +1 -1
- package/dist/rest/namespaces/logs.d.ts +10 -101
- package/dist/rest/namespaces/logs.js +10 -128
- package/dist/rest/namespaces/logs.js.map +1 -1
- package/dist/rest/namespaces/logs.resources.generated.d.ts +9 -0
- package/dist/rest/namespaces/logs.resources.generated.js +17 -0
- package/dist/rest/namespaces/logs.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/logs.types.generated.d.ts +131 -0
- package/dist/rest/namespaces/logs.types.generated.js +8 -0
- package/dist/rest/namespaces/logs.types.generated.js.map +1 -0
- package/dist/rest/namespaces/lookup.d.ts +3 -25
- package/dist/rest/namespaces/lookup.js +3 -27
- package/dist/rest/namespaces/lookup.js.map +1 -1
- package/dist/rest/namespaces/message.resources.generated.d.ts +6 -0
- package/dist/rest/namespaces/message.resources.generated.js +14 -0
- package/dist/rest/namespaces/message.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/message.types.generated.d.ts +122 -0
- package/dist/rest/namespaces/message.types.generated.js +8 -0
- package/dist/rest/namespaces/message.types.generated.js.map +1 -0
- package/dist/rest/namespaces/messages.resources.generated.d.ts +18 -0
- package/dist/rest/namespaces/messages.resources.generated.js +44 -0
- package/dist/rest/namespaces/messages.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/messages.types.generated.d.ts +99 -0
- package/dist/rest/namespaces/messages.types.generated.js +8 -0
- package/dist/rest/namespaces/messages.types.generated.js.map +1 -0
- package/dist/rest/namespaces/mfa.d.ts +3 -42
- package/dist/rest/namespaces/mfa.js +3 -49
- package/dist/rest/namespaces/mfa.js.map +1 -1
- package/dist/rest/namespaces/number-groups.d.ts +3 -45
- package/dist/rest/namespaces/number-groups.js +3 -53
- package/dist/rest/namespaces/number-groups.js.map +1 -1
- package/dist/rest/namespaces/phone-numbers.d.ts +9 -57
- package/dist/rest/namespaces/phone-numbers.js +9 -63
- package/dist/rest/namespaces/phone-numbers.js.map +1 -1
- package/dist/rest/namespaces/project.d.ts +6 -42
- package/dist/rest/namespaces/project.js +6 -51
- package/dist/rest/namespaces/project.js.map +1 -1
- package/dist/rest/namespaces/project.resources.generated.d.ts +17 -0
- package/dist/rest/namespaces/project.resources.generated.js +44 -0
- package/dist/rest/namespaces/project.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/project.types.generated.d.ts +58 -0
- package/dist/rest/namespaces/project.types.generated.js +8 -0
- package/dist/rest/namespaces/project.types.generated.js.map +1 -0
- package/dist/rest/namespaces/projects.resources.generated.d.ts +12 -0
- package/dist/rest/namespaces/projects.resources.generated.js +25 -0
- package/dist/rest/namespaces/projects.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/projects.types.generated.d.ts +77 -0
- package/dist/rest/namespaces/projects.types.generated.js +8 -0
- package/dist/rest/namespaces/projects.types.generated.js.map +1 -0
- package/dist/rest/namespaces/pubsub.d.ts +4 -18
- package/dist/rest/namespaces/pubsub.js +4 -21
- package/dist/rest/namespaces/pubsub.js.map +1 -1
- package/dist/rest/namespaces/pubsub.resources.generated.d.ts +12 -0
- package/dist/rest/namespaces/pubsub.resources.generated.js +29 -0
- package/dist/rest/namespaces/pubsub.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/pubsub.types.generated.d.ts +60 -0
- package/dist/rest/namespaces/pubsub.types.generated.js +8 -0
- package/dist/rest/namespaces/pubsub.types.generated.js.map +1 -0
- package/dist/rest/namespaces/queues.d.ts +3 -38
- package/dist/rest/namespaces/queues.js +3 -44
- package/dist/rest/namespaces/queues.js.map +1 -1
- package/dist/rest/namespaces/recordings.d.ts +3 -34
- package/dist/rest/namespaces/recordings.js +3 -40
- package/dist/rest/namespaces/recordings.js.map +1 -1
- package/dist/rest/namespaces/registry.d.ts +6 -137
- package/dist/rest/namespaces/registry.js +6 -173
- package/dist/rest/namespaces/registry.js.map +1 -1
- package/dist/rest/namespaces/relay-rest.resources.generated.d.ts +168 -0
- package/dist/rest/namespaces/relay-rest.resources.generated.js +430 -0
- package/dist/rest/namespaces/relay-rest.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/relay-rest.types.generated.d.ts +1906 -0
- package/dist/rest/namespaces/relay-rest.types.generated.js +8 -0
- package/dist/rest/namespaces/relay-rest.types.generated.js.map +1 -0
- package/dist/rest/namespaces/short-codes.d.ts +3 -35
- package/dist/rest/namespaces/short-codes.js +3 -41
- package/dist/rest/namespaces/short-codes.js.map +1 -1
- package/dist/rest/namespaces/sip-profile.d.ts +3 -24
- package/dist/rest/namespaces/sip-profile.js +3 -29
- package/dist/rest/namespaces/sip-profile.js.map +1 -1
- package/dist/rest/namespaces/verified-callers.d.ts +3 -29
- package/dist/rest/namespaces/verified-callers.js +3 -34
- package/dist/rest/namespaces/verified-callers.js.map +1 -1
- package/dist/rest/namespaces/video.d.ts +10 -227
- package/dist/rest/namespaces/video.js +10 -288
- package/dist/rest/namespaces/video.js.map +1 -1
- package/dist/rest/namespaces/video.resources.generated.d.ts +81 -0
- package/dist/rest/namespaces/video.resources.generated.js +171 -0
- package/dist/rest/namespaces/video.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/video.types.generated.d.ts +771 -0
- package/dist/rest/namespaces/video.types.generated.js +8 -0
- package/dist/rest/namespaces/video.types.generated.js.map +1 -0
- package/dist/rest/namespaces/voice.resources.generated.d.ts +9 -0
- package/dist/rest/namespaces/voice.resources.generated.js +17 -0
- package/dist/rest/namespaces/voice.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/voice.types.generated.d.ts +214 -0
- package/dist/rest/namespaces/voice.types.generated.js +8 -0
- package/dist/rest/namespaces/voice.types.generated.js.map +1 -0
- package/dist/rest/pagination.d.ts +5 -1
- package/dist/rest/pagination.js +40 -20
- package/dist/rest/pagination.js.map +1 -1
- package/dist/rest/types.d.ts +21 -3
- package/dist/schema.json +299 -98
- package/dist/skills/SkillBase.d.ts +97 -20
- package/dist/skills/SkillBase.js +100 -17
- package/dist/skills/SkillBase.js.map +1 -1
- package/dist/skills/SkillManager.d.ts +66 -13
- package/dist/skills/SkillManager.js +101 -20
- package/dist/skills/SkillManager.js.map +1 -1
- package/dist/skills/SkillName.d.ts +44 -0
- package/dist/skills/SkillName.js +2 -0
- package/dist/skills/SkillName.js.map +1 -0
- package/dist/skills/SkillRegistry.d.ts +47 -7
- package/dist/skills/SkillRegistry.js +85 -13
- package/dist/skills/SkillRegistry.js.map +1 -1
- package/dist/skills/builtin/api_ninjas_trivia.d.ts +3 -1
- package/dist/skills/builtin/api_ninjas_trivia.js +24 -8
- package/dist/skills/builtin/api_ninjas_trivia.js.map +1 -1
- package/dist/skills/builtin/ask_claude.d.ts +14 -4
- package/dist/skills/builtin/ask_claude.js +36 -14
- package/dist/skills/builtin/ask_claude.js.map +1 -1
- package/dist/skills/builtin/claude_skills.d.ts +3 -1
- package/dist/skills/builtin/claude_skills.js +19 -15
- package/dist/skills/builtin/claude_skills.js.map +1 -1
- package/dist/skills/builtin/custom_skills.d.ts +10 -3
- package/dist/skills/builtin/custom_skills.js +26 -9
- package/dist/skills/builtin/custom_skills.js.map +1 -1
- package/dist/skills/builtin/datasphere.d.ts +5 -3
- package/dist/skills/builtin/datasphere.js +34 -25
- package/dist/skills/builtin/datasphere.js.map +1 -1
- package/dist/skills/builtin/datasphere_serverless.d.ts +12 -1
- package/dist/skills/builtin/datasphere_serverless.js +17 -6
- package/dist/skills/builtin/datasphere_serverless.js.map +1 -1
- package/dist/skills/builtin/datetime.d.ts +3 -1
- package/dist/skills/builtin/datetime.js +11 -7
- package/dist/skills/builtin/datetime.js.map +1 -1
- package/dist/skills/builtin/google_maps.d.ts +29 -14
- package/dist/skills/builtin/google_maps.js +89 -269
- package/dist/skills/builtin/google_maps.js.map +1 -1
- package/dist/skills/builtin/index.d.ts +8 -6
- package/dist/skills/builtin/index.js +8 -6
- package/dist/skills/builtin/index.js.map +1 -1
- package/dist/skills/builtin/info_gatherer.d.ts +4 -2
- package/dist/skills/builtin/info_gatherer.js +20 -12
- package/dist/skills/builtin/info_gatherer.js.map +1 -1
- package/dist/skills/builtin/joke.d.ts +16 -6
- package/dist/skills/builtin/joke.js +54 -37
- package/dist/skills/builtin/joke.js.map +1 -1
- package/dist/skills/builtin/math.d.ts +3 -1
- package/dist/skills/builtin/math.js +14 -9
- package/dist/skills/builtin/math.js.map +1 -1
- package/dist/skills/builtin/mcp_gateway.d.ts +34 -5
- package/dist/skills/builtin/mcp_gateway.js +77 -46
- package/dist/skills/builtin/mcp_gateway.js.map +1 -1
- package/dist/skills/builtin/native_vector_search.d.ts +19 -5
- package/dist/skills/builtin/native_vector_search.js +179 -61
- package/dist/skills/builtin/native_vector_search.js.map +1 -1
- package/dist/skills/builtin/play_background_file.d.ts +21 -15
- package/dist/skills/builtin/play_background_file.js +43 -122
- package/dist/skills/builtin/play_background_file.js.map +1 -1
- package/dist/skills/builtin/spider.d.ts +46 -1
- package/dist/skills/builtin/spider.js +317 -101
- package/dist/skills/builtin/spider.js.map +1 -1
- package/dist/skills/builtin/swml_transfer.d.ts +14 -3
- package/dist/skills/builtin/swml_transfer.js +45 -24
- package/dist/skills/builtin/swml_transfer.js.map +1 -1
- package/dist/skills/builtin/weather_api.d.ts +24 -13
- package/dist/skills/builtin/weather_api.js +57 -31
- package/dist/skills/builtin/weather_api.js.map +1 -1
- package/dist/skills/builtin/web_search.d.ts +48 -10
- package/dist/skills/builtin/web_search.js +301 -84
- package/dist/skills/builtin/web_search.js.map +1 -1
- package/dist/skills/builtin/wikipedia_search.d.ts +4 -2
- package/dist/skills/builtin/wikipedia_search.js +32 -14
- package/dist/skills/builtin/wikipedia_search.js.map +1 -1
- package/dist/skills/index.d.ts +3 -2
- package/dist/skills/index.js +1 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/swml_verbs_generated.d.ts +2824 -0
- package/dist/swml_verbs_generated.js +12 -0
- package/dist/swml_verbs_generated.js.map +1 -0
- package/dist/types.d.ts +65 -6
- package/dist/web.d.ts +27 -0
- package/dist/web.js +20 -0
- package/dist/web.js.map +1 -0
- package/docs/agent-guide.md +1034 -0
- package/docs/ai_chat.md +560 -0
- package/docs/api-reference.md +3534 -0
- package/docs/architecture.md +846 -0
- package/docs/bedrock_agent.md +411 -0
- package/docs/cli-guide.md +403 -0
- package/docs/cloud_functions_guide.md +399 -0
- package/docs/configuration.md +548 -0
- package/docs/contexts-guide.md +884 -0
- package/docs/datamap-guide.md +1160 -0
- package/docs/developer_pain_points.md +548 -0
- package/docs/llm_parameters.md +298 -0
- package/docs/mcp_gateway_reference.md +354 -0
- package/docs/mcp_integration.md +162 -0
- package/docs/pgi_agent_guide.md +1820 -0
- package/docs/prefabs-guide.md +815 -0
- package/docs/programmatically_governed_inference.md +301 -0
- package/docs/sdk_features.md +501 -0
- package/docs/security.md +559 -0
- package/docs/serverless-guide.md +520 -0
- package/docs/skills-guide.md +1223 -0
- package/docs/skills-system.md +405 -0
- package/docs/skills_parameter_schema.md +417 -0
- package/docs/swaig-reference.md +1938 -0
- package/docs/swml_service_guide.md +573 -0
- package/docs/third_party_skills.md +410 -0
- package/docs/web_service.md +666 -0
- package/examples/README.md +202 -0
- package/examples/advanced-datamap.ts +108 -0
- package/examples/advanced-dynamic-config.ts +70 -0
- package/examples/auto-vivified.ts +95 -0
- package/examples/call-flow.ts +65 -0
- package/examples/comprehensive-dynamic.ts +125 -0
- package/examples/contexts-steps.ts +65 -0
- package/examples/custom-path.ts +45 -0
- package/examples/datamap-tools.ts +51 -0
- package/examples/datasphere-multi-instance.ts +66 -0
- package/examples/datasphere-serverless-env.ts +87 -0
- package/examples/datasphere-webhook-env.ts +65 -0
- package/examples/datasphere.ts +56 -0
- package/examples/declarative.ts +100 -0
- package/examples/dynamic-config.ts +54 -0
- package/examples/dynamic-info-gatherer.ts +69 -0
- package/examples/dynamic-swml-service.ts +67 -0
- package/examples/gather-info.ts +95 -0
- package/examples/gather-per-question-functions-demo.ts +139 -0
- package/examples/joke-agent.ts +34 -0
- package/examples/kubernetes-agent.ts +45 -0
- package/examples/llm-params.ts +75 -0
- package/examples/mcp-agent.ts +89 -0
- package/examples/mcp-gateway.ts +81 -0
- package/examples/multi-agent.ts +80 -0
- package/examples/multi-endpoint.ts +79 -0
- package/examples/pgi/case-domain.ts +114 -0
- package/examples/pgi/serve.ts +16 -0
- package/examples/pgi/support-agent.ts +265 -0
- package/examples/pom-prompt.ts +70 -0
- package/examples/prefab-concierge.ts +42 -0
- package/examples/prefab-faq.ts +58 -0
- package/examples/prefab-info-gatherer.ts +33 -0
- package/examples/prefab-receptionist.ts +36 -0
- package/examples/prefab-survey.ts +69 -0
- package/examples/quickstart-agent.ts +29 -0
- package/examples/quickstart-relay.ts +25 -0
- package/examples/quickstart-rest.ts +25 -0
- package/examples/record-call.ts +65 -0
- package/examples/relay-demo.ts +33 -0
- package/examples/room-and-sip.ts +93 -0
- package/examples/serverless-lambda.ts +43 -0
- package/examples/session-state.ts +83 -0
- package/examples/simple-agent.ts +36 -0
- package/examples/simple-static.ts +29 -0
- package/examples/skills-demo.ts +41 -0
- package/examples/step-function-inheritance-demo.ts +124 -0
- package/examples/swaig-features.ts +193 -0
- package/examples/swml-service-routing.ts +66 -0
- package/examples/swml-service.ts +38 -0
- package/examples/swmlservice_ai_sidecar.ts +104 -0
- package/examples/swmlservice_swaig_standalone.ts +79 -0
- package/examples/tap.ts +67 -0
- package/examples/typed-tools.ts +68 -0
- package/examples/verb-methods.ts +45 -0
- package/examples/web-search-multi-instance.ts +75 -0
- package/examples/web-search.ts +38 -0
- package/examples/wikipedia.ts +36 -0
- package/livewire/README.md +164 -0
- package/livewire/docs/migration-guide.md +251 -0
- package/livewire/examples/livewire-basic-agent.ts +74 -0
- package/livewire/examples/livewire-handoff.ts +196 -0
- package/livewire/examples/livewire-multi-tool.ts +121 -0
- package/package.json +88 -13
- package/relay/README.md +101 -0
- package/relay/docs/call-methods.md +622 -0
- package/relay/docs/client-reference.md +281 -0
- package/relay/docs/events.md +193 -0
- package/relay/docs/getting-started.md +221 -0
- package/relay/docs/guide.md +386 -0
- package/relay/docs/messaging.md +246 -0
- package/relay/examples/relay-inbound.ts +66 -0
- package/relay/examples/relay-messaging.ts +74 -0
- package/relay/examples/relay-outbound.ts +76 -0
- package/rest/README.md +141 -0
- package/rest/docs/calling.md +313 -0
- package/rest/docs/client-reference.md +149 -0
- package/rest/docs/fabric.md +192 -0
- package/rest/docs/getting-started.md +138 -0
- package/rest/docs/guide.md +421 -0
- package/rest/docs/namespaces.md +367 -0
- package/rest/docs/phone-binding.md +116 -0
- package/rest/examples/rest-10dlc-registration.ts +177 -0
- package/rest/examples/rest-bind-phone-to-swml-webhook.ts +66 -0
- package/rest/examples/rest-calling-ivr-and-ai.ts +136 -0
- package/rest/examples/rest-calling-play-and-record.ts +98 -0
- package/rest/examples/rest-client.ts +59 -0
- package/rest/examples/rest-datasphere-search.ts +81 -0
- package/rest/examples/rest-fabric-conferences-and-routing.ts +147 -0
- package/rest/examples/rest-fabric-subscribers-and-sip.ts +106 -0
- package/rest/examples/rest-fabric-swml-and-callflows.ts +101 -0
- package/rest/examples/rest-manage-resources.ts +64 -0
- package/rest/examples/rest-phone-number-management.ts +200 -0
- package/rest/examples/rest-queues-mfa-and-recordings.ts +143 -0
- package/rest/examples/rest-video-rooms.ts +186 -0
- package/tutorial/fred/fred.ts +218 -0
- package/tutorial/fred/tutorial/01-introduction.md +141 -0
- package/tutorial/fred/tutorial/02-setup.md +304 -0
- package/tutorial/fred/tutorial/03-basic-agent.md +284 -0
- package/tutorial/fred/tutorial/04-wikipedia-skill.md +298 -0
- package/tutorial/fred/tutorial/05-custom-functions.md +347 -0
- package/tutorial/fred/tutorial/06-running-testing.md +642 -0
- package/tutorial/fred/tutorial/README.md +56 -0
- package/tutorial/fred/tutorial/appendix-complete-code.md +632 -0
- package/tutorial/fred/tutorial/appendix-docker-deployment.md +504 -0
- package/tutorial/full-guardrails-agent/handlers.ts +436 -0
- package/tutorial/full-guardrails-agent/penny.ts +305 -0
- package/tutorial/full-guardrails-agent/reservations.ts +1109 -0
- package/tutorial/full-guardrails-agent/tutorial/01-why-guardrails.md +149 -0
- package/tutorial/full-guardrails-agent/tutorial/02-design-first.md +139 -0
- package/tutorial/full-guardrails-agent/tutorial/03-rules-first.md +422 -0
- package/tutorial/full-guardrails-agent/tutorial/04-the-shell.md +238 -0
- package/tutorial/full-guardrails-agent/tutorial/05-steps-and-scoping.md +247 -0
- package/tutorial/full-guardrails-agent/tutorial/06-tools-that-decide.md +467 -0
- package/tutorial/full-guardrails-agent/tutorial/07-gather-and-projection.md +160 -0
- package/tutorial/full-guardrails-agent/tutorial/08-the-verification-gate.md +333 -0
- package/tutorial/full-guardrails-agent/tutorial/09-people-and-endings.md +313 -0
- package/tutorial/full-guardrails-agent/tutorial/10-testing-and-running.md +387 -0
- package/tutorial/full-guardrails-agent/tutorial/README.md +106 -0
- package/tutorial/full-guardrails-agent/tutorial/appendix-complete-code.md +2207 -0
- package/tutorial/full-guardrails-agent/tutorial/appendix-deployment.md +191 -0
- package/tutorial/full-guardrails-agent/tutorial/appendix-technique-map.md +117 -0
- package/tutorial/full-guardrails-agent/workflow.ts +219 -0
- package/tutorial/multi_agents/README.md +175 -0
- package/tutorial/multi_agents/advanced_agent.ts +395 -0
- package/tutorial/multi_agents/extending_agents.ts +641 -0
- package/tutorial/multi_agents/knowledge.ts +59 -0
- package/tutorial/multi_agents/lesson1_first_agent.md +368 -0
- package/tutorial/multi_agents/lesson2_knowledge_bases.md +404 -0
- package/tutorial/multi_agents/lesson3_multi_agent_systems.md +621 -0
- package/tutorial/multi_agents/lesson4_advanced_features.md +805 -0
- package/tutorial/multi_agents/lesson5_extending_agents.md +856 -0
- package/tutorial/multi_agents/pc_builder.ts +529 -0
- package/tutorial/multi_agents/sales_agent.ts +88 -0
- package/tutorial/multi_agents/sales_agent_with_search.ts +116 -0
- package/tutorial/multi_agents/sales_knowledge.md +139 -0
- package/tutorial/multi_agents/support_knowledge.md +256 -0
- package/dist/cli/mock-data.d.ts +0 -37
- package/dist/cli/mock-data.js +0 -80
- package/dist/cli/mock-data.js.map +0 -1
- package/dist/generateVerbTypes.d.ts +0 -11
- package/dist/generateVerbTypes.js +0 -265
- package/dist/generateVerbTypes.js.map +0 -1
- package/dist/rest/namespaces/compat.d.ts +0 -585
- package/dist/rest/namespaces/compat.js +0 -735
- package/dist/rest/namespaces/compat.js.map +0 -1
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
# All Namespaces
|
|
2
|
+
|
|
3
|
+
This page covers every namespace except Fabric and Calling, which have their own pages: [Fabric Resources](fabric.md) and [Calling Commands](calling.md). Every method is async, so `await` it. Every method also takes an optional `requestOptions` object as its last argument, as [Request Options](guide.md#request-options-timeout-retries-abort) describes.
|
|
4
|
+
|
|
5
|
+
<!-- snippet-setup -->
|
|
6
|
+
```ts
|
|
7
|
+
export {}; // treat each example as a module so top-level `await` is allowed
|
|
8
|
+
// Shared context the fragments on this page assume: `client` is a constructed RestClient
|
|
9
|
+
// (see the Getting Started page). Declared here so each example can `await client.<ns>...`.
|
|
10
|
+
declare const client: import('@signalwire/sdk').RestClient;
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Phone Numbers
|
|
14
|
+
|
|
15
|
+
`client.phoneNumbers` lists, searches, purchases, updates and releases phone numbers:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// List your phone numbers
|
|
19
|
+
let numbers = await client.phoneNumbers.list();
|
|
20
|
+
numbers = await client.phoneNumbers.list({ filter_name: 'Main' });
|
|
21
|
+
|
|
22
|
+
// Search available numbers to purchase
|
|
23
|
+
const available = await client.phoneNumbers.search({ areacode: '512', number_type: 'local' });
|
|
24
|
+
|
|
25
|
+
// Purchase a number
|
|
26
|
+
const number = await client.phoneNumbers.create({ number: '+15551234567' });
|
|
27
|
+
|
|
28
|
+
// Get / update / release
|
|
29
|
+
const found = await client.phoneNumbers.get('pn-uuid');
|
|
30
|
+
await client.phoneNumbers.update('pn-uuid', { name: 'Support Line' });
|
|
31
|
+
await client.phoneNumbers.delete('pn-uuid');
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The SDK sends query parameters unchanged, so use the API's parameter names: `areacode` (all lowercase), `number_type` and `filter_name`, not `areaCode` or `numberType`. The `number_type` parameter selects `local` (the default) or toll-free numbers. To route a number's inbound calls, see [phone-binding.md](phone-binding.md).
|
|
35
|
+
|
|
36
|
+
## Messages
|
|
37
|
+
|
|
38
|
+
`client.messages.create` sends an SMS or MMS message. `to` and `from` are positional, and `body`, `media` and the other fields are options. `update` redacts a sent message, and its only accepted body is an empty string:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
const message = await client.messages.create('+15551234567', '+15559876543', {
|
|
42
|
+
body: 'Your order has shipped.',
|
|
43
|
+
});
|
|
44
|
+
await client.messages.update(message.id, '');
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Addresses
|
|
48
|
+
|
|
49
|
+
`client.addresses` lists, creates, gets and deletes addresses:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
const addresses = await client.addresses.list();
|
|
53
|
+
// create takes positional required fields:
|
|
54
|
+
// (label, country, first_name, last_name, street_number, street_name, city, state, postal_code)
|
|
55
|
+
const address = await client.addresses.create(
|
|
56
|
+
'Office', 'US', 'Jane', 'Doe', '123', 'Main St', 'Austin', 'TX', '78701',
|
|
57
|
+
);
|
|
58
|
+
const found = await client.addresses.get('addr-uuid');
|
|
59
|
+
await client.addresses.delete('addr-uuid');
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Queues
|
|
63
|
+
|
|
64
|
+
`client.queues` manages queues and reads their members:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
const queues = await client.queues.list();
|
|
68
|
+
const queue = await client.queues.create({ name: 'Support' });
|
|
69
|
+
const found = await client.queues.get('q-uuid');
|
|
70
|
+
await client.queues.update('q-uuid', { name: 'VIP Support' });
|
|
71
|
+
await client.queues.delete('q-uuid');
|
|
72
|
+
|
|
73
|
+
// Members
|
|
74
|
+
const members = await client.queues.listMembers('q-uuid');
|
|
75
|
+
const nextMember = await client.queues.getNextMember('q-uuid');
|
|
76
|
+
const member = await client.queues.getMember('q-uuid', 'member-uuid');
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Recordings
|
|
80
|
+
|
|
81
|
+
`client.recordings` lists, gets and deletes recordings:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
const recordings = await client.recordings.list();
|
|
85
|
+
const recording = await client.recordings.get('rec-uuid');
|
|
86
|
+
await client.recordings.delete('rec-uuid');
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Number Groups
|
|
90
|
+
|
|
91
|
+
`client.numberGroups` manages number groups and their memberships:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
const groups = await client.numberGroups.list();
|
|
95
|
+
const group = await client.numberGroups.create({ name: 'Marketing' });
|
|
96
|
+
const found = await client.numberGroups.get('ng-uuid');
|
|
97
|
+
await client.numberGroups.update('ng-uuid', { name: 'Sales' });
|
|
98
|
+
await client.numberGroups.delete('ng-uuid');
|
|
99
|
+
|
|
100
|
+
// Memberships
|
|
101
|
+
const memberships = await client.numberGroups.listMemberships('ng-uuid');
|
|
102
|
+
await client.numberGroups.addMembership('ng-uuid', 'pn-uuid');
|
|
103
|
+
const membership = await client.numberGroups.getMembership('mem-uuid');
|
|
104
|
+
await client.numberGroups.deleteMembership('mem-uuid');
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Verified Caller IDs
|
|
108
|
+
|
|
109
|
+
`client.verifiedCallers` manages verified caller IDs and runs the verification flow:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
const callers = await client.verifiedCallers.list();
|
|
113
|
+
const caller = await client.verifiedCallers.create({
|
|
114
|
+
number: '+15551234567',
|
|
115
|
+
name: 'Office',
|
|
116
|
+
});
|
|
117
|
+
const found = await client.verifiedCallers.get('vc-uuid');
|
|
118
|
+
await client.verifiedCallers.update('vc-uuid', { name: 'Main Office' });
|
|
119
|
+
await client.verifiedCallers.delete('vc-uuid');
|
|
120
|
+
|
|
121
|
+
// Verification flow
|
|
122
|
+
await client.verifiedCallers.redialVerification('vc-uuid');
|
|
123
|
+
await client.verifiedCallers.submitVerification('vc-uuid', '123456');
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## SIP Profile
|
|
127
|
+
|
|
128
|
+
Each project has one SIP profile, so `get()` and `update()` take no ID:
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
const profile = await client.sipProfile.get();
|
|
132
|
+
await client.sipProfile.update({ domain_identifier: 'myproject', default_encryption: 'required' });
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Phone Number Lookup
|
|
136
|
+
|
|
137
|
+
`client.lookup.phoneNumber` looks up a number in E.164 format. The `include` parameter adds `carrier` or `cnam` information, or both:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
let info = await client.lookup.phoneNumber('+15551234567');
|
|
141
|
+
info = await client.lookup.phoneNumber('+15551234567', { include: 'carrier,cnam' });
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The API reference describes some of the `include` lookups as billable.
|
|
145
|
+
|
|
146
|
+
## Short Codes
|
|
147
|
+
|
|
148
|
+
`client.shortCodes` lists, gets and updates short codes:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
const codes = await client.shortCodes.list();
|
|
152
|
+
const code = await client.shortCodes.get('sc-uuid');
|
|
153
|
+
// update takes positional (id, name, messageHandler) plus optional handler URLs
|
|
154
|
+
await client.shortCodes.update('sc-uuid', 'Alerts', 'laml_webhooks', {
|
|
155
|
+
message_request_url: 'https://example.com/sms',
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Imported Phone Numbers
|
|
160
|
+
|
|
161
|
+
`client.importedNumbers.create` imports a number you host elsewhere:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
// create takes (number, number_type) positionally, with optional capabilities
|
|
165
|
+
await client.importedNumbers.create('+15559999999', 'longcode', {
|
|
166
|
+
capabilities: ['sms', 'voice'],
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## MFA (Multi-Factor Authentication)
|
|
171
|
+
|
|
172
|
+
`client.mfa` sends a verification code by SMS or phone call, then checks the code the user enters. The `message` option is text sent before the code:
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
// Request a verification code via SMS; `to` is positional, and the rest are options
|
|
176
|
+
const result = await client.mfa.sms('+15551234567', {
|
|
177
|
+
from: '+15559876543',
|
|
178
|
+
message: 'Your verification code is:',
|
|
179
|
+
});
|
|
180
|
+
const requestId = result.id;
|
|
181
|
+
|
|
182
|
+
// Or via phone call
|
|
183
|
+
await client.mfa.call('+15551234567', {
|
|
184
|
+
from: '+15559876543',
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Verify the code; requestId and token are positional
|
|
188
|
+
await client.mfa.verify(requestId, '123456');
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## 10DLC Campaign Registry
|
|
192
|
+
|
|
193
|
+
`client.registry` registers 10DLC brands and campaigns, and assigns numbers to campaigns:
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
// Brands; a self-registered (CSP) brand needs its approved TCR brand reference
|
|
197
|
+
const brands = await client.registry.brands.list();
|
|
198
|
+
const brand = await client.registry.brands.create({
|
|
199
|
+
csp_self_registered: true,
|
|
200
|
+
name: 'My Brand',
|
|
201
|
+
csp_brand_reference: 'BRAND123',
|
|
202
|
+
});
|
|
203
|
+
const found = await client.registry.brands.get('brand-uuid');
|
|
204
|
+
|
|
205
|
+
// Campaigns under a brand (CSP/partner form needs the approved TCR campaign reference)
|
|
206
|
+
const campaigns = await client.registry.brands.listCampaigns('brand-uuid');
|
|
207
|
+
const campaign = await client.registry.brands.createCampaign('brand-uuid', {
|
|
208
|
+
name: 'Alerts',
|
|
209
|
+
brand_id: 'brand-uuid',
|
|
210
|
+
csp_campaign_reference: 'CAMP123',
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// Campaign management
|
|
214
|
+
const camp = await client.registry.campaigns.get('camp-uuid');
|
|
215
|
+
await client.registry.campaigns.update('camp-uuid', { name: 'Updated alerts' });
|
|
216
|
+
|
|
217
|
+
// Number assignments
|
|
218
|
+
const numbers = await client.registry.campaigns.listNumbers('camp-uuid');
|
|
219
|
+
const orders = await client.registry.campaigns.listOrders('camp-uuid');
|
|
220
|
+
const order = await client.registry.campaigns.createOrder('camp-uuid', { phone_numbers: ['pn-1'] });
|
|
221
|
+
const fetched = await client.registry.orders.get('order-uuid');
|
|
222
|
+
await client.registry.numbers.delete('number-assignment-uuid');
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Datasphere
|
|
226
|
+
|
|
227
|
+
`client.datasphere.documents` manages documents, runs semantic search and manages the chunks of each document:
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
// Documents
|
|
231
|
+
const docs = await client.datasphere.documents.list();
|
|
232
|
+
const doc = await client.datasphere.documents.create({
|
|
233
|
+
url: 'https://example.com/doc.pdf',
|
|
234
|
+
tags: ['support'],
|
|
235
|
+
});
|
|
236
|
+
const found = await client.datasphere.documents.get('doc-uuid');
|
|
237
|
+
await client.datasphere.documents.update('doc-uuid', { tags: ['support', 'billing'] });
|
|
238
|
+
await client.datasphere.documents.delete('doc-uuid');
|
|
239
|
+
|
|
240
|
+
// Semantic search (the body keys are platform snake_case)
|
|
241
|
+
const results = await client.datasphere.documents.search('How do I reset my password?', {
|
|
242
|
+
tags: ['support'],
|
|
243
|
+
count: 5,
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// Chunks
|
|
247
|
+
const chunks = await client.datasphere.documents.listChunks('doc-uuid');
|
|
248
|
+
const chunk = await client.datasphere.documents.getChunk('doc-uuid', 'chunk-uuid');
|
|
249
|
+
await client.datasphere.documents.deleteChunk('doc-uuid', 'chunk-uuid');
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Video
|
|
253
|
+
|
|
254
|
+
`client.video` manages rooms, room tokens, sessions, recordings, conferences and streams:
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
// Rooms
|
|
258
|
+
const rooms = await client.video.rooms.list();
|
|
259
|
+
const room = await client.video.rooms.create({ name: 'standup', max_members: 10 });
|
|
260
|
+
const found = await client.video.rooms.get('room-uuid');
|
|
261
|
+
await client.video.rooms.update('room-uuid', { max_members: 20 });
|
|
262
|
+
await client.video.rooms.delete('room-uuid');
|
|
263
|
+
await client.video.rooms.listStreams('room-uuid');
|
|
264
|
+
await client.video.rooms.createStream('room-uuid', 'rtmp://example.com/live');
|
|
265
|
+
|
|
266
|
+
// Room tokens (room_name positional, everything else in options)
|
|
267
|
+
const roomToken = await client.video.roomTokens.create('standup', { user_name: 'alice' });
|
|
268
|
+
|
|
269
|
+
// Room sessions
|
|
270
|
+
const sessions = await client.video.roomSessions.list({ room_name: 'standup' });
|
|
271
|
+
const session = await client.video.roomSessions.get('session-uuid');
|
|
272
|
+
const events = await client.video.roomSessions.listEvents('session-uuid');
|
|
273
|
+
const members = await client.video.roomSessions.listMembers('session-uuid');
|
|
274
|
+
const sessionRecordings = await client.video.roomSessions.listRecordings('session-uuid');
|
|
275
|
+
|
|
276
|
+
// Room recordings
|
|
277
|
+
const recs = await client.video.roomRecordings.list();
|
|
278
|
+
const rec = await client.video.roomRecordings.get('rec-uuid');
|
|
279
|
+
await client.video.roomRecordings.delete('rec-uuid');
|
|
280
|
+
const recEvents = await client.video.roomRecordings.listEvents('rec-uuid');
|
|
281
|
+
|
|
282
|
+
// Conferences
|
|
283
|
+
const confs = await client.video.conferences.list();
|
|
284
|
+
const conf = await client.video.conferences.create({ name: 'all-hands', display_name: 'All Hands', quality: '720p' });
|
|
285
|
+
const conference = await client.video.conferences.get('conf-uuid');
|
|
286
|
+
await client.video.conferences.update('conf-uuid', { display_name: 'All Hands', quality: '1080p' });
|
|
287
|
+
await client.video.conferences.delete('conf-uuid');
|
|
288
|
+
const confTokens = await client.video.conferences.listConferenceTokens('conf-uuid');
|
|
289
|
+
await client.video.conferences.listStreams('conf-uuid');
|
|
290
|
+
await client.video.conferences.createStream('conf-uuid', 'rtmp://example.com/live');
|
|
291
|
+
|
|
292
|
+
// Conference tokens
|
|
293
|
+
const confToken = await client.video.conferenceTokens.get('token-uuid');
|
|
294
|
+
await client.video.conferenceTokens.reset('token-uuid');
|
|
295
|
+
|
|
296
|
+
// Streams
|
|
297
|
+
const stream = await client.video.streams.get('stream-uuid');
|
|
298
|
+
await client.video.streams.update('stream-uuid', 'rtmp://example.com/new');
|
|
299
|
+
await client.video.streams.delete('stream-uuid');
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Logs
|
|
303
|
+
|
|
304
|
+
The log endpoints are read-only. This example reads each kind of log:
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
// Message logs
|
|
308
|
+
const messageLogs = await client.logs.messages.list({ include_deleted: true });
|
|
309
|
+
const messageLog = await client.logs.messages.get('log-uuid');
|
|
310
|
+
|
|
311
|
+
// Voice logs (with events)
|
|
312
|
+
const voiceLogs = await client.logs.voice.list();
|
|
313
|
+
const voiceLog = await client.logs.voice.get('log-uuid');
|
|
314
|
+
const voiceEvents = await client.logs.voice.listEvents('log-uuid');
|
|
315
|
+
|
|
316
|
+
// Fax logs
|
|
317
|
+
const faxLogs = await client.logs.fax.list();
|
|
318
|
+
const faxLog = await client.logs.fax.get('log-uuid');
|
|
319
|
+
|
|
320
|
+
// Conference logs
|
|
321
|
+
const conferenceLogs = await client.logs.conferences.list();
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Project Tokens
|
|
325
|
+
|
|
326
|
+
`client.project.tokens` creates, updates and deletes API tokens. `create` takes the token name and its permissions positionally:
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
const token = await client.project.tokens.create('ci-token', ['calling', 'messaging', 'numbers']);
|
|
330
|
+
await client.project.tokens.update('token-uuid', { name: 'renamed-token' });
|
|
331
|
+
await client.project.tokens.delete('token-uuid');
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Projects
|
|
335
|
+
|
|
336
|
+
`client.projects` manages projects and subprojects. The signing key is returned only by `create` and `rotateSigningKey`:
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
const projects = await client.projects.list();
|
|
340
|
+
const project = await client.projects.create({ name: 'Staging' });
|
|
341
|
+
await client.projects.update(project.id, { name: 'Staging EU' });
|
|
342
|
+
const rotated = await client.projects.rotateSigningKey(project.id);
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## PubSub Tokens
|
|
346
|
+
|
|
347
|
+
`client.pubsub.createToken` creates a PubSub token. The time to live (`ttl`) and the channel permissions are positional:
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
const token = await client.pubsub.createToken(
|
|
351
|
+
60,
|
|
352
|
+
{ updates: { read: true, write: false } },
|
|
353
|
+
{ member_id: 'user-123' },
|
|
354
|
+
);
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
## Chat Tokens
|
|
358
|
+
|
|
359
|
+
`client.chat.createToken` creates a Chat token with the same arguments:
|
|
360
|
+
|
|
361
|
+
```typescript
|
|
362
|
+
const token = await client.chat.createToken(
|
|
363
|
+
60,
|
|
364
|
+
{ support: { read: true, write: true } },
|
|
365
|
+
{ member_id: 'user-123' },
|
|
366
|
+
);
|
|
367
|
+
```
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Binding a phone number to a call handler
|
|
2
|
+
|
|
3
|
+
To route an inbound phone number to an SWML webhook, a cXML application, an AI agent or a call flow, you configure the phone number. You don't configure the Fabric resource. For the common handlers, you don't create the Fabric resource yourself. Read this page before you write code that creates webhook, agent or call flow resources by hand.
|
|
4
|
+
|
|
5
|
+
<!-- snippet-setup -->
|
|
6
|
+
```ts
|
|
7
|
+
export {}; // treat each example as a module so top-level `await` is allowed
|
|
8
|
+
// Shared context the fragments on this page assume (constructed on the Getting Started page).
|
|
9
|
+
declare const client: import('@signalwire/sdk').RestClient;
|
|
10
|
+
declare const pnId: string; // a phone-number SID
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## How binding works
|
|
14
|
+
|
|
15
|
+
A phone number has a `call_handler` field that selects what handles its inbound calls. Binding a number takes these steps:
|
|
16
|
+
|
|
17
|
+
1. You update the phone number (`PUT /api/relay/rest/phone_numbers/{id}`) with a `call_handler` value and that handler's companion field, such as a URL or an ID.
|
|
18
|
+
2. For the handlers that have one, the server creates the matching Fabric resource from the URL or ID you supplied.
|
|
19
|
+
|
|
20
|
+
You rarely need to create a Fabric webhook resource directly. A webhook resource that no phone number points at routes no calls.
|
|
21
|
+
|
|
22
|
+
## The `PhoneCallHandler` values
|
|
23
|
+
|
|
24
|
+
`PhoneCallHandler` holds the `call_handler` values. Import it from the top-level SDK entry point:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { PhoneCallHandler } from '@signalwire/sdk';
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The table lists each value, its companion field and the Fabric resource the server creates for it:
|
|
31
|
+
|
|
32
|
+
| `PhoneCallHandler` | `call_handler` wire value | Required companion field | Fabric resource created |
|
|
33
|
+
|---|---|---|---|
|
|
34
|
+
| `RELAY_SCRIPT` | `relay_script` | `call_relay_script_url` | `swml_webhook` |
|
|
35
|
+
| `LAML_WEBHOOKS` | `laml_webhooks` | `call_request_url` | `cxml_webhook` |
|
|
36
|
+
| `LAML_APPLICATION` | `laml_application` | `call_laml_application_id` | `cxml_application` |
|
|
37
|
+
| `AI_AGENT` | `ai_agent` | `call_ai_agent_id` | `ai_agent` |
|
|
38
|
+
| `CALL_FLOW` | `call_flow` | `call_flow_id` | `call_flow` |
|
|
39
|
+
| `RELAY_APPLICATION` | `relay_application` | `call_relay_application` | `relay_application` |
|
|
40
|
+
| `RELAY_TOPIC` | `relay_topic` | `call_relay_topic` | None (routes to a RELAY client) |
|
|
41
|
+
| `RELAY_CONTEXT` | `relay_context` | `call_relay_context` | None (legacy; use `RELAY_TOPIC`) |
|
|
42
|
+
| `RELAY_CONNECTOR` | `relay_connector` | Connector configuration | None (internal) |
|
|
43
|
+
| `VIDEO_ROOM` | `video_room` | `call_video_room_id` | None (routes to the Video API) |
|
|
44
|
+
| `DIALOGFLOW` | `dialogflow` | `call_dialogflow_agent_id` | None |
|
|
45
|
+
|
|
46
|
+
The `LAML_WEBHOOKS` value (`laml_webhooks`) produces a cXML (Twilio-compatible) handler, not an SWML webhook, even though its name says "webhooks". For SWML, use `RELAY_SCRIPT`.
|
|
47
|
+
|
|
48
|
+
The type is named `PhoneCallHandler`, not `CallHandler`, because the RELAY client already exports a `CallHandler` type for inbound-call callbacks.
|
|
49
|
+
|
|
50
|
+
A phone number response can include `calling_handler_resource_id`. The server sets it from the handler you chose, so don't set it in an update.
|
|
51
|
+
|
|
52
|
+
## Typed helpers on `phoneNumbers`
|
|
53
|
+
|
|
54
|
+
Each helper calls `phoneNumbers.update` with the right `call_handler` value and companion field. This example shows every helper:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
// SWML webhook: your backend returns SWML for each call
|
|
58
|
+
await client.phoneNumbers.setSwmlWebhook(pnId, 'https://example.com/swml');
|
|
59
|
+
|
|
60
|
+
// cXML (Twilio-compatible) webhook; fallback_url and status_callback_url are optional positionals
|
|
61
|
+
await client.phoneNumbers.setCxmlWebhook(
|
|
62
|
+
pnId,
|
|
63
|
+
'https://example.com/voice.xml',
|
|
64
|
+
'https://example.com/fallback.xml', // optional fallback_url
|
|
65
|
+
'https://example.com/status', // optional status_callback_url
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
// An existing cXML application, by ID
|
|
69
|
+
await client.phoneNumbers.setCxmlApplication(pnId, 'app-uuid');
|
|
70
|
+
|
|
71
|
+
// An AI agent, by ID (created with fabric.aiAgents)
|
|
72
|
+
await client.phoneNumbers.setAiAgent(pnId, 'agent-uuid');
|
|
73
|
+
|
|
74
|
+
// A call flow; the optional version is 'working_copy' or 'current_deployed'
|
|
75
|
+
await client.phoneNumbers.setCallFlow(pnId, 'flow-uuid', 'current_deployed');
|
|
76
|
+
|
|
77
|
+
// A RELAY application, by name
|
|
78
|
+
await client.phoneNumbers.setRelayApplication(pnId, 'my-relay-app');
|
|
79
|
+
|
|
80
|
+
// A RELAY topic; topic is positional, and a status callback URL is optional
|
|
81
|
+
await client.phoneNumbers.setRelayTopic(pnId, 'office');
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Each helper returns the updated phone number. Every helper also takes an optional `extra` object, merged into the request body, and a final `requestOptions` argument.
|
|
85
|
+
|
|
86
|
+
The wire-level form sets the same fields through `update()`. Use it when you need a combination the helpers don't cover:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { PhoneCallHandler } from '@signalwire/sdk';
|
|
90
|
+
|
|
91
|
+
await client.phoneNumbers.update(pnId, {
|
|
92
|
+
call_handler: PhoneCallHandler.RELAY_SCRIPT, // or the raw string 'relay_script'
|
|
93
|
+
call_relay_script_url: 'https://example.com/swml',
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Don't pre-create the webhook resource
|
|
98
|
+
|
|
99
|
+
This example shows the approach to avoid. It creates an SWML webhook resource and then tries to attach it with `assignPhoneRoute`:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
// Avoid: the resource isn't bound to any phone number
|
|
103
|
+
const webhook = await client.fabric.swmlWebhooks.create({
|
|
104
|
+
name: 'my-webhook',
|
|
105
|
+
primary_request_url: 'https://example.com/swml',
|
|
106
|
+
});
|
|
107
|
+
// assignPhoneRoute takes (resourceId, phone_route_id, handler), and a phone
|
|
108
|
+
// route ID isn't a phone number SID
|
|
109
|
+
await client.fabric.resources.assignPhoneRoute(webhook.id, 'phone-route-uuid', 'calling');
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The `fabric.swmlWebhooks.create` and `fabric.cxmlWebhooks.create` methods work, and the SDK doesn't warn about them. They don't bind a number, though. Call `phoneNumbers.setSwmlWebhook` (or `update`) instead, and the server creates the Fabric resource for you.
|
|
113
|
+
|
|
114
|
+
`client.fabric.resources.assignPhoneRoute(...)` posts to `/api/fabric/resources/{id}/phone_routes`. It isn't needed for the handlers in the [`PhoneCallHandler` table](#the-phonecallhandler-values).
|
|
115
|
+
|
|
116
|
+
For a runnable version of the recommended flow, see [rest-bind-phone-to-swml-webhook.ts](../examples/rest-bind-phone-to-swml-webhook.ts).
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST Example: 10DLC brand and campaign compliance registration.
|
|
3
|
+
*
|
|
4
|
+
* WARNING: This example interacts with the real 10DLC registration system.
|
|
5
|
+
* Brand and campaign registrations may have side effects and costs.
|
|
6
|
+
* Use with caution in production environments.
|
|
7
|
+
*
|
|
8
|
+
* Prerequisites:
|
|
9
|
+
* export SIGNALWIRE_PROJECT_ID=your-project-id
|
|
10
|
+
* export SIGNALWIRE_API_TOKEN=your-api-token
|
|
11
|
+
* export SIGNALWIRE_SPACE=your-space.signalwire.com
|
|
12
|
+
*
|
|
13
|
+
* Run:
|
|
14
|
+
* npx tsx rest/examples/rest-10dlc-registration.ts
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { RestClient, RestError } from '@signalwire/sdk';
|
|
18
|
+
|
|
19
|
+
const client = new RestClient();
|
|
20
|
+
|
|
21
|
+
async function main() {
|
|
22
|
+
// 1. Register a brand
|
|
23
|
+
console.log('Registering 10DLC brand...');
|
|
24
|
+
let brandId: string | null = null;
|
|
25
|
+
try {
|
|
26
|
+
const brand = await client.registry.brands.create({
|
|
27
|
+
name: 'Acme',
|
|
28
|
+
company_name: 'Acme Corp',
|
|
29
|
+
contact_email: 'compliance@acme.example.com',
|
|
30
|
+
contact_phone: '+15125550100',
|
|
31
|
+
ein: '12-3456789',
|
|
32
|
+
ein_issuing_country: 'US',
|
|
33
|
+
legal_entity_type: 'PRIVATE_PROFIT',
|
|
34
|
+
company_vertical: 'TECHNOLOGY',
|
|
35
|
+
company_website: 'https://acme.example.com',
|
|
36
|
+
company_address: '123 Main St, Austin, TX 78701',
|
|
37
|
+
});
|
|
38
|
+
brandId = brand.id;
|
|
39
|
+
console.log(` Registered brand: ${brandId}`);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
if (err instanceof RestError) {
|
|
42
|
+
console.log(` Brand registration failed (expected in demo): ${err.statusCode}`);
|
|
43
|
+
} else throw err;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 2. List brands
|
|
47
|
+
console.log('\nListing brands...');
|
|
48
|
+
const brands = await client.registry.brands.list();
|
|
49
|
+
for (const b of brands.data ?? []) {
|
|
50
|
+
console.log(` - ${b.id}: ${b.name ?? 'unnamed'}`);
|
|
51
|
+
}
|
|
52
|
+
if (!brandId && brands.data?.length) {
|
|
53
|
+
brandId = brands.data[0]!.id; // length checked truthy above
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 3. Get brand details
|
|
57
|
+
if (brandId) {
|
|
58
|
+
const detail = await client.registry.brands.get(brandId);
|
|
59
|
+
console.log(`\nBrand detail: ${detail.name ?? 'N/A'} (${detail.state ?? 'N/A'})`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 4. Create a campaign under the brand
|
|
63
|
+
let campaignId: string | null = null;
|
|
64
|
+
if (brandId) {
|
|
65
|
+
console.log('\nCreating campaign...');
|
|
66
|
+
try {
|
|
67
|
+
const campaign = await client.registry.brands.createCampaign(brandId, {
|
|
68
|
+
name: 'Acme Notifications',
|
|
69
|
+
brand_id: brandId,
|
|
70
|
+
sms_use_case: 'MIXED',
|
|
71
|
+
sub_use_cases: ['CUSTOMER_CARE', 'DELIVERY_NOTIFICATION'],
|
|
72
|
+
description: 'Customer notifications and support messages',
|
|
73
|
+
sample1: 'Your order #12345 has shipped.',
|
|
74
|
+
sample2: 'Reply STOP to unsubscribe from Acme alerts.',
|
|
75
|
+
message_flow: 'Customers opt in at checkout to receive order and support updates.',
|
|
76
|
+
opt_out_message: 'You have been unsubscribed from Acme alerts. Reply START to rejoin.',
|
|
77
|
+
help_message: 'Acme alerts: reply STOP to unsubscribe. Msg&data rates may apply.',
|
|
78
|
+
number_pooling_required: false,
|
|
79
|
+
direct_lending: false,
|
|
80
|
+
embedded_link: false,
|
|
81
|
+
embedded_phone: false,
|
|
82
|
+
age_gated_content: false,
|
|
83
|
+
lead_generation: false,
|
|
84
|
+
terms_and_conditions: true,
|
|
85
|
+
});
|
|
86
|
+
campaignId = campaign.id;
|
|
87
|
+
console.log(` Created campaign: ${campaignId}`);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
if (err instanceof RestError) {
|
|
90
|
+
console.log(` Campaign creation failed (expected in demo): ${err.statusCode}`);
|
|
91
|
+
} else throw err;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 5. List campaigns for the brand
|
|
96
|
+
if (brandId) {
|
|
97
|
+
console.log('\nListing brand campaigns...');
|
|
98
|
+
const campaigns = await client.registry.brands.listCampaigns(brandId);
|
|
99
|
+
for (const c of campaigns.data ?? []) {
|
|
100
|
+
console.log(` - ${c.id}: ${c.name ?? 'unknown'}`);
|
|
101
|
+
if (!campaignId) campaignId = c.id;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 6. Get and update campaign
|
|
106
|
+
if (campaignId) {
|
|
107
|
+
const campDetail = await client.registry.campaigns.get(campaignId);
|
|
108
|
+
console.log(`\nCampaign: ${campDetail.name ?? 'N/A'} (${campDetail.state ?? 'N/A'})`);
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
await client.registry.campaigns.update(campaignId, { name: 'Acme Notifications (updated)' });
|
|
112
|
+
console.log(' Campaign name updated');
|
|
113
|
+
} catch (err) {
|
|
114
|
+
if (err instanceof RestError) {
|
|
115
|
+
console.log(` Campaign update failed: ${err.statusCode}`);
|
|
116
|
+
} else throw err;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// 7. Create an order to assign numbers
|
|
121
|
+
let orderId: string | null = null;
|
|
122
|
+
if (campaignId) {
|
|
123
|
+
console.log('\nCreating number assignment order...');
|
|
124
|
+
try {
|
|
125
|
+
const order = await client.registry.campaigns.createOrder(campaignId, {
|
|
126
|
+
phone_numbers: ['+15125551234'],
|
|
127
|
+
});
|
|
128
|
+
orderId = order.id;
|
|
129
|
+
console.log(` Created order: ${orderId}`);
|
|
130
|
+
} catch (err) {
|
|
131
|
+
if (err instanceof RestError) {
|
|
132
|
+
console.log(` Order creation failed (expected in demo): ${err.statusCode}`);
|
|
133
|
+
} else throw err;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 8. Get order status
|
|
138
|
+
if (orderId) {
|
|
139
|
+
const orderDetail = await client.registry.orders.get(orderId);
|
|
140
|
+
console.log(` Order status: ${orderDetail.state ?? 'N/A'}`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 9. List campaign numbers and orders
|
|
144
|
+
if (campaignId) {
|
|
145
|
+
console.log('\nListing campaign numbers...');
|
|
146
|
+
const numbers = await client.registry.campaigns.listNumbers(campaignId);
|
|
147
|
+
for (const n of numbers.data ?? []) {
|
|
148
|
+
console.log(` - ${n.phone_number ?? n.id ?? 'unknown'}`);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const orders = await client.registry.campaigns.listOrders(campaignId);
|
|
152
|
+
for (const o of orders.data ?? []) {
|
|
153
|
+
console.log(` - Order ${o.id}: ${o.state ?? 'unknown'}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 10. Unassign a number (clean up)
|
|
158
|
+
if (campaignId) {
|
|
159
|
+
console.log('\nUnassigning numbers...');
|
|
160
|
+
const nums = await client.registry.campaigns.listNumbers(campaignId);
|
|
161
|
+
for (const n of nums.data ?? []) {
|
|
162
|
+
try {
|
|
163
|
+
await client.registry.numbers.delete(n.id);
|
|
164
|
+
console.log(` Unassigned number ${n.id}`);
|
|
165
|
+
} catch (err) {
|
|
166
|
+
if (err instanceof RestError) {
|
|
167
|
+
console.log(` Unassign failed: ${err.statusCode}`);
|
|
168
|
+
} else throw err;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
main().catch((err) => {
|
|
175
|
+
console.error('Error:', err.message);
|
|
176
|
+
process.exit(1);
|
|
177
|
+
});
|