@signalwire/sdk 2.0.5 → 3.6.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 +821 -0
- package/LICENSE +21 -0
- package/README.md +163 -68
- package/dist/AGENTS.md +13 -0
- package/dist/AgentBase.d.ts +510 -126
- package/dist/AgentBase.js +1581 -455
- 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 +186 -45
- package/dist/DataMap.js +210 -52
- package/dist/DataMap.js.map +1 -1
- package/dist/FunctionResult.d.ts +309 -83
- package/dist/FunctionResult.js +483 -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 +12 -1
- package/dist/POM/PromptObjectModel.js +25 -9
- package/dist/POM/PromptObjectModel.js.map +1 -1
- 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 +18 -0
- package/dist/PomBuilder.js +53 -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 +22 -1
- package/dist/PromptManager.js +28 -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 +169 -59
- package/dist/SWMLService.js +456 -129
- 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 +49 -9
- package/dist/SecurityUtils.js +153 -51
- package/dist/SecurityUtils.js.map +1 -1
- package/dist/SemanticGate.d.ts +183 -0
- package/dist/SemanticGate.js +533 -0
- package/dist/SemanticGate.js.map +1 -0
- 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 +139 -7
- package/dist/SwaigFunction.js +170 -22
- 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 +92 -33
- 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 -371
- 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 +920 -0
- package/dist/cli/tsdocs/topics.js.map +1 -0
- package/dist/index.d.ts +49 -68
- package/dist/index.js +45 -73
- 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 +44 -17
- package/dist/relay/RelayClient.js +175 -65
- 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 +73 -42
- 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 +5 -2
- package/dist/rest/callHandler.js +4 -1
- package/dist/rest/callHandler.js.map +1 -1
- package/dist/rest/index.d.ts +18 -77
- package/dist/rest/index.js +47 -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 -327
- package/dist/rest/namespaces/fabric.js +14 -439
- 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 +8 -196
- package/dist/rest/namespaces/phone-numbers.js +8 -230
- 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 +111 -21
- 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 +22 -11
- package/dist/skills/SkillRegistry.js +47 -17
- 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 +18 -6
- 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 +21 -22
- 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 +42 -4
- package/dist/skills/builtin/spider.js +277 -104
- 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 +38 -30
- 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 +294 -100
- 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 +14 -13
- 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 +59 -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 +3641 -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 +1207 -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 +1986 -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 +85 -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,815 @@
|
|
|
1
|
+
# Prefab Agents Guide
|
|
2
|
+
|
|
3
|
+
The SDK includes five prefab agents, each an `AgentBase` subclass for a common call flow. This guide lists each prefab's options, its tools, and what the tools do.
|
|
4
|
+
|
|
5
|
+
<!-- snippet-setup -->
|
|
6
|
+
```ts
|
|
7
|
+
export {}; // treat each example as a module (top-level await)
|
|
8
|
+
declare global {
|
|
9
|
+
const InfoGathererAgent: typeof import('@signalwire/sdk').InfoGathererAgent;
|
|
10
|
+
const SurveyAgent: typeof import('@signalwire/sdk').SurveyAgent;
|
|
11
|
+
const FAQBotAgent: typeof import('@signalwire/sdk').FAQBotAgent;
|
|
12
|
+
const ConciergeAgent: typeof import('@signalwire/sdk').ConciergeAgent;
|
|
13
|
+
const ReceptionistAgent: typeof import('@signalwire/sdk').ReceptionistAgent;
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Table of Contents
|
|
20
|
+
|
|
21
|
+
- [Overview](#overview)
|
|
22
|
+
- [InfoGathererAgent](#infogathereragent)
|
|
23
|
+
- [Configuration](#infogatherer-configuration)
|
|
24
|
+
- [Questions](#infogatherer-questions)
|
|
25
|
+
- [Tools](#infogatherer-tools)
|
|
26
|
+
- [Dynamic Mode](#dynamic-mode)
|
|
27
|
+
- [Example](#infogatherer-example)
|
|
28
|
+
- [SurveyAgent](#surveyagent)
|
|
29
|
+
- [Configuration](#survey-configuration)
|
|
30
|
+
- [Question Types](#survey-question-types)
|
|
31
|
+
- [Branching Logic](#survey-branching-logic)
|
|
32
|
+
- [Scoring](#survey-scoring)
|
|
33
|
+
- [Tools](#survey-tools)
|
|
34
|
+
- [Example](#survey-example)
|
|
35
|
+
- [FAQBotAgent](#faqbotagent)
|
|
36
|
+
- [Configuration](#faqbot-configuration)
|
|
37
|
+
- [Matching Engine](#faqbot-matching-engine)
|
|
38
|
+
- [Tools](#faqbot-tools)
|
|
39
|
+
- [Example](#faqbot-example)
|
|
40
|
+
- [ConciergeAgent](#conciergeagent)
|
|
41
|
+
- [Configuration](#concierge-configuration)
|
|
42
|
+
- [Tools](#concierge-tools)
|
|
43
|
+
- [Example](#concierge-example)
|
|
44
|
+
- [ReceptionistAgent](#receptionistagent)
|
|
45
|
+
- [Configuration](#receptionist-configuration)
|
|
46
|
+
- [Tools](#receptionist-tools)
|
|
47
|
+
- [Example](#receptionist-example)
|
|
48
|
+
- [Factory Functions](#factory-functions)
|
|
49
|
+
- [Subclassing Prefabs](#subclassing-prefabs)
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Overview
|
|
54
|
+
|
|
55
|
+
A prefab agent is an `AgentBase` subclass that configures itself from one options object. Each prefab:
|
|
56
|
+
|
|
57
|
+
- **Extends `AgentBase`**, so it has the same HTTP serving, SWML rendering, basic auth and proxy handling.
|
|
58
|
+
- **Builds its prompt in its constructor** with `promptAddSection()`, from your options: the question list, the FAQ entries, the departments and so on.
|
|
59
|
+
- **Sets AI parameters, hints and global data** suited to its call flow.
|
|
60
|
+
- **Registers its SWAIG tools** in a `defineTools()` override.
|
|
61
|
+
|
|
62
|
+
A tool's response is context for the model, not speech: the model reads it and decides what to say. Several tools return instructions for the model, such as the next question to ask.
|
|
63
|
+
|
|
64
|
+
The prefabs keep per-call state in one of two places. `InfoGathererAgent` keeps its question list and position in the call's `global_data`, and updates it with `set_global_data` actions in its tool responses. `SurveyAgent` and `ReceptionistAgent` keep theirs in memory in the agent process, keyed by the request's `call_id`. That state isn't shared between replicas and is lost on a restart. The agent removes a call's state when the call's summary arrives at `/post_prompt`, or once the call has been idle for an hour, and holds at most 10,000 calls, dropping the least recently used. If you override `onSummary()` on one of these agents, call `super.onSummary(summary, rawData)` so the state is removed when the call ends.
|
|
65
|
+
|
|
66
|
+
Every prefab takes `name`, `route` and `agentOptions`. `agentOptions` is passed to the `AgentBase` constructor after `name` and `route`, so a `route` or `name` in `agentOptions` wins over the top-level option. All five classes and their config types are exported from the package:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import {
|
|
70
|
+
InfoGathererAgent, SurveyAgent, FAQBotAgent,
|
|
71
|
+
ConciergeAgent, ReceptionistAgent,
|
|
72
|
+
} from '@signalwire/sdk';
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## InfoGathererAgent
|
|
78
|
+
|
|
79
|
+
An agent that asks the caller a list of questions, one at a time, and records each answer in the call's `global_data`. The questions are fixed at construction (static mode) or chosen for each call by a callback (dynamic mode).
|
|
80
|
+
|
|
81
|
+
**Source:** `src/prefabs/InfoGathererAgent.ts`
|
|
82
|
+
|
|
83
|
+
### InfoGatherer Configuration
|
|
84
|
+
|
|
85
|
+
The constructor accepts an `InfoGathererConfig` object:
|
|
86
|
+
|
|
87
|
+
| Property | Type | Required | Default | Description |
|
|
88
|
+
|---|---|---|---|---|
|
|
89
|
+
| `name` | `string` | No | `"info_gatherer"` | Agent name. |
|
|
90
|
+
| `route` | `string` | No | `"/info_gatherer"` | HTTP route for this agent. |
|
|
91
|
+
| `questions` | `InfoGathererQuestion[]` | No | none | Questions to ask (static mode). Omit it for dynamic mode. |
|
|
92
|
+
| `questionCallback` | `InfoGathererQuestionCallback` | No | none | Chooses the questions for each call (dynamic mode). The same as calling `setQuestionCallback()` after construction. Ignored when `questions` is set. |
|
|
93
|
+
| `agentOptions` | `Partial<AgentOptions>` | No | none | Other `AgentBase` options, such as `port` or `basicAuth`. |
|
|
94
|
+
|
|
95
|
+
The constructor throws if `questions` is an empty array, or a question lacks `key_name` or `question_text`. It sets the AI parameters `end_of_speech_timeout` to 800 and `speech_event_timeout` to 1000.
|
|
96
|
+
|
|
97
|
+
### InfoGatherer Questions
|
|
98
|
+
|
|
99
|
+
Each entry in the `questions` array is an `InfoGathererQuestion`:
|
|
100
|
+
|
|
101
|
+
| Property | Type | Required | Default | Description |
|
|
102
|
+
|---|---|---|---|---|
|
|
103
|
+
| `key_name` | `string` | Yes | none | Key the answer is stored under. |
|
|
104
|
+
| `question_text` | `string` | Yes | none | The question to ask the caller. |
|
|
105
|
+
| `confirm` | `boolean` | No | `false` | When `true`, the tool tells the model to have the caller confirm the answer before submitting it. |
|
|
106
|
+
|
|
107
|
+
In static mode, the agent's `global_data` holds `questions`, `question_index` (starting at 0) and `answers` (an empty list).
|
|
108
|
+
|
|
109
|
+
### InfoGatherer Tools
|
|
110
|
+
|
|
111
|
+
The agent registers two SWAIG tools.
|
|
112
|
+
|
|
113
|
+
#### `start_questions`
|
|
114
|
+
|
|
115
|
+
Reads the first question from the request's `global_data.questions` and returns an instruction for the model to ask it.
|
|
116
|
+
|
|
117
|
+
**Parameters:** None.
|
|
118
|
+
|
|
119
|
+
**Returns:** The instruction, including whether the caller must confirm the answer. It also sets `replace_in_history` to `Welcome! Let me ask you a few questions.`. If there are no questions left, it returns `I don't have any questions to ask.`.
|
|
120
|
+
|
|
121
|
+
#### `submit_answer`
|
|
122
|
+
|
|
123
|
+
Records the answer to the current question and moves to the next.
|
|
124
|
+
|
|
125
|
+
**Parameters:**
|
|
126
|
+
|
|
127
|
+
| Name | Type | Required | Description |
|
|
128
|
+
|---|---|---|---|
|
|
129
|
+
| `answer` | `string` | Not marked required | The caller's answer to the current question. |
|
|
130
|
+
|
|
131
|
+
**Behavior:**
|
|
132
|
+
- Adds `{ key_name, answer }` to `answers` and increases `question_index`, with a `set_global_data` action.
|
|
133
|
+
- If more questions remain, returns the instruction to ask the next one.
|
|
134
|
+
- After the last question, returns a message telling the model that all questions are answered.
|
|
135
|
+
- If every question was already answered, returns `All questions have already been answered.`.
|
|
136
|
+
|
|
137
|
+
### Dynamic Mode
|
|
138
|
+
|
|
139
|
+
Omit `questions` and register a callback that returns the question list for each call. The callback runs on every SWML request, before the SWML is rendered, and its list becomes that call's `global_data.questions`.
|
|
140
|
+
|
|
141
|
+
The callback's signature is `(queryParams, bodyParams, headers)`. `queryParams` holds the query parameters of the SWML request's URL, `bodyParams` the SWML request body, and `headers` the request's HTTP headers, with lower-case names. The SDK removes `Authorization`, `Cookie` and the other credential headers before the callback sees them. This callback chooses the questions from a query parameter, so a webhook URL ending in `?mode=support` gets the support questions:
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
const agent = new InfoGathererAgent({ name: 'dynamic-intake' });
|
|
145
|
+
agent.setQuestionCallback((queryParams, bodyParams, headers) => {
|
|
146
|
+
if (queryParams['mode'] === 'support') {
|
|
147
|
+
return [
|
|
148
|
+
{ key_name: 'name', question_text: 'What is your name?' },
|
|
149
|
+
{ key_name: 'issue', question_text: "What's the issue?" },
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
return [{ key_name: 'name', question_text: 'What is your name?' }];
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Without a callback, or when the callback throws or returns an invalid list, the agent uses two fallback questions. They are `name` ("What is your name?") and `message` ("How can I help you today?").
|
|
157
|
+
|
|
158
|
+
### InfoGatherer Example
|
|
159
|
+
|
|
160
|
+
This agent collects four answers for a patient intake line:
|
|
161
|
+
|
|
162
|
+
<!-- snippet: no-run starts a blocking HTTP server (serve/start/run on a fixed port); collides under the concurrent gate and cannot run standalone -->
|
|
163
|
+
```typescript
|
|
164
|
+
import { InfoGathererAgent } from '@signalwire/sdk';
|
|
165
|
+
|
|
166
|
+
const agent = new InfoGathererAgent({
|
|
167
|
+
name: 'PatientIntake',
|
|
168
|
+
questions: [
|
|
169
|
+
{ key_name: 'full_name', question_text: 'What is your full legal name?' },
|
|
170
|
+
{ key_name: 'date_of_birth', question_text: 'What is your date of birth?', confirm: true },
|
|
171
|
+
{ key_name: 'phone_number', question_text: 'What is a good callback number?', confirm: true },
|
|
172
|
+
{ key_name: 'insurance_provider', question_text: 'Who is your insurance provider?' },
|
|
173
|
+
],
|
|
174
|
+
agentOptions: {
|
|
175
|
+
port: 3001,
|
|
176
|
+
route: '/intake',
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
await agent.run();
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## SurveyAgent
|
|
186
|
+
|
|
187
|
+
An agent that runs a survey with typed questions, branching based on answers, and scoring.
|
|
188
|
+
|
|
189
|
+
**Source:** `src/prefabs/SurveyAgent.ts`
|
|
190
|
+
|
|
191
|
+
### Survey Configuration
|
|
192
|
+
|
|
193
|
+
The constructor accepts a `SurveyConfig` object:
|
|
194
|
+
|
|
195
|
+
| Property | Type | Required | Default | Description |
|
|
196
|
+
|---|---|---|---|---|
|
|
197
|
+
| `name` | `string` | No | `"survey"` | Agent name. |
|
|
198
|
+
| `route` | `string` | No | `"/survey"` | HTTP route for this agent. |
|
|
199
|
+
| `surveyName` | `string` | Yes | none | Survey name, used in the prompt, hints and global data. |
|
|
200
|
+
| `questions` | `SurveyQuestion[]` | Yes | none | Ordered list of survey questions. |
|
|
201
|
+
| `introduction` | `string` | No | `"Welcome to our ${surveyName}. We appreciate your participation."` | Opening message. It's the call's static greeting, which the caller can't interrupt, and the prompt tells the model to begin with it. |
|
|
202
|
+
| `conclusion` | `string` | No | `"Thank you for completing our survey. Your feedback is valuable to us."` | Closing message, in the prompt and in `answer_question`'s final response. |
|
|
203
|
+
| `brandName` | `string` | No | `"Our Company"` | Company name the prompt says the agent represents. |
|
|
204
|
+
| `maxRetries` | `number` | No | `2` | Number of retries for an invalid answer. It goes into the prompt and `global_data`; the SDK doesn't count retries. |
|
|
205
|
+
| `onComplete` | `(responses: Record<string, unknown>, score: number) => void \| Promise<void>` | No | none | Called when `answer_question` finishes the survey, with the answers and the total score. An error it throws is logged. |
|
|
206
|
+
| `agentOptions` | `Partial<AgentOptions>` | No | none | Other `AgentBase` options. |
|
|
207
|
+
|
|
208
|
+
Each `SurveyQuestion` has this shape:
|
|
209
|
+
|
|
210
|
+
| Property | Type | Required | Description |
|
|
211
|
+
|---|---|---|---|
|
|
212
|
+
| `id` | `string` | Yes | Unique question ID. An empty ID becomes `question_N`, from the question's position. |
|
|
213
|
+
| `text` | `string` | Yes | The question to ask the caller. |
|
|
214
|
+
| `type` | `'multiple_choice' \| 'open_ended' \| 'rating' \| 'yes_no'` | Yes | Question type; sets how an answer is validated. |
|
|
215
|
+
| `options` | `string[]` | For `multiple_choice` | Answer options. A `multiple_choice` question without options throws. |
|
|
216
|
+
| `scale` | `number` | No | For `rating` questions, the top of the 1 to `scale` range. Defaults to `5`. |
|
|
217
|
+
| `required` | `boolean` | No | Whether an answer is required. Defaults to `true`. |
|
|
218
|
+
| `nextQuestion` | `string \| Record<string, string>` | No | The question after this one (see [Branching Logic](#survey-branching-logic)). |
|
|
219
|
+
| `points` | `number \| Record<string, number>` | No | Points for an answer (see [Scoring](#survey-scoring)). |
|
|
220
|
+
|
|
221
|
+
The constructor throws on a question without `text` or with an unknown `type`. It adds the survey name, the brand name, rating numbers, options and `yes`/`no` as speech hints, and enables the `check_time` native function.
|
|
222
|
+
|
|
223
|
+
### Survey Question Types
|
|
224
|
+
|
|
225
|
+
Each type accepts these answers:
|
|
226
|
+
|
|
227
|
+
| Type | Valid answer | Notes |
|
|
228
|
+
|---|---|---|
|
|
229
|
+
| `multiple_choice` | One of the `options`, ignoring case and surrounding spaces. | The prompt tells the model to list the options. |
|
|
230
|
+
| `open_ended` | Any answer. An empty answer is invalid when the question is required. | Stored as given. |
|
|
231
|
+
| `rating` | A whole number from 1 to `scale`. | The prompt tells the model to explain the scale. |
|
|
232
|
+
| `yes_no` | `yes`, `y`, `no` or `n`, ignoring case. | Stored as `"yes"` or `"no"`. |
|
|
233
|
+
|
|
234
|
+
### Survey Branching Logic
|
|
235
|
+
|
|
236
|
+
`answer_question` uses the answered question's `nextQuestion` to pick the next question:
|
|
237
|
+
|
|
238
|
+
| Value | Behavior |
|
|
239
|
+
|---|---|
|
|
240
|
+
| omitted | The next question in array order. After the last question, the survey ends. |
|
|
241
|
+
| `string` | The question with this ID, whatever the answer. |
|
|
242
|
+
| `Record<string, string>` | The ID mapped to the answer, matching the stored answer (so `"yes"` or `"no"` for a `yes_no` question) and ignoring case. A `_default` key applies when no key matches. Without one, the next question in array order. |
|
|
243
|
+
|
|
244
|
+
If the chosen ID isn't a question in the survey, the survey ends.
|
|
245
|
+
|
|
246
|
+
### Survey Scoring
|
|
247
|
+
|
|
248
|
+
The `points` property sets the points an answer earns:
|
|
249
|
+
|
|
250
|
+
| Value | Behavior |
|
|
251
|
+
|---|---|
|
|
252
|
+
| omitted | No points. |
|
|
253
|
+
| `number` | These points for any valid answer. |
|
|
254
|
+
| `Record<string, number>` | The points mapped to the stored answer, ignoring case. An answer with no entry earns 0. |
|
|
255
|
+
|
|
256
|
+
`answer_question` adds the points to the call's total, which it passes to `onComplete`.
|
|
257
|
+
|
|
258
|
+
### Survey Tools
|
|
259
|
+
|
|
260
|
+
The agent registers these SWAIG tools:
|
|
261
|
+
|
|
262
|
+
#### `validate_response`
|
|
263
|
+
|
|
264
|
+
Checks a response against a question's type without recording it.
|
|
265
|
+
|
|
266
|
+
**Parameters:**
|
|
267
|
+
|
|
268
|
+
| Name | Type | Required | Description |
|
|
269
|
+
|---|---|---|---|
|
|
270
|
+
| `question_id` | `string` | Not marked required | The ID of the question to validate against. |
|
|
271
|
+
| `response` | `string` | Not marked required | The response to check. |
|
|
272
|
+
|
|
273
|
+
**Returns:** `Response to '<id>' is valid.`, the reason it's invalid, or an error for an unknown question ID.
|
|
274
|
+
|
|
275
|
+
#### `log_response`
|
|
276
|
+
|
|
277
|
+
Stores a response for a question in the call's in-memory state.
|
|
278
|
+
|
|
279
|
+
**Parameters:**
|
|
280
|
+
|
|
281
|
+
| Name | Type | Required | Description |
|
|
282
|
+
|---|---|---|---|
|
|
283
|
+
| `question_id` | `string` | Not marked required | The ID of the question. |
|
|
284
|
+
| `response` | `string` | Not marked required | The response to store. |
|
|
285
|
+
|
|
286
|
+
**Returns:** A message naming the question's text. It doesn't validate the response, add points, move to another question or call `onComplete`.
|
|
287
|
+
|
|
288
|
+
#### `answer_question`
|
|
289
|
+
|
|
290
|
+
Validates, stores and scores an answer, then moves to the next question.
|
|
291
|
+
|
|
292
|
+
**Parameters:**
|
|
293
|
+
|
|
294
|
+
| Name | Type | Required | Description |
|
|
295
|
+
|---|---|---|---|
|
|
296
|
+
| `question_id` | `string` | Yes | The ID of the question being answered. |
|
|
297
|
+
| `answer` | `string` | Yes | The caller's answer. |
|
|
298
|
+
|
|
299
|
+
**Behavior:**
|
|
300
|
+
- Returns the validation error if the answer isn't valid for the question's type.
|
|
301
|
+
- Stores the answer, normalizing `yes_no` answers to `"yes"` or `"no"`.
|
|
302
|
+
- Adds the answer's points to the total.
|
|
303
|
+
- Picks the next question with the branching logic.
|
|
304
|
+
- If there is no next question, marks the survey complete, calls `onComplete`, and returns the number of answers, the total score and the conclusion.
|
|
305
|
+
- Otherwise, returns the next question's ID and text, with its options, rating range or yes/no hint.
|
|
306
|
+
- After the survey is complete, returns `The survey has already been completed.`.
|
|
307
|
+
|
|
308
|
+
#### `get_current_question`
|
|
309
|
+
|
|
310
|
+
Returns the question the call is on.
|
|
311
|
+
|
|
312
|
+
**Parameters:** None.
|
|
313
|
+
|
|
314
|
+
**Returns:** The question's ID, type and text, with its options, rating range or yes/no hint.
|
|
315
|
+
|
|
316
|
+
#### `get_survey_progress`
|
|
317
|
+
|
|
318
|
+
Returns the call's progress through the survey.
|
|
319
|
+
|
|
320
|
+
**Parameters:** None.
|
|
321
|
+
|
|
322
|
+
**Returns:** The number of questions answered out of the total, the percentage, the current score, whether the survey is complete, and the answers so far.
|
|
323
|
+
|
|
324
|
+
### Survey Example
|
|
325
|
+
|
|
326
|
+
This survey branches on the recommendation question and scores two answers:
|
|
327
|
+
|
|
328
|
+
<!-- snippet: no-run starts a blocking HTTP server (serve/start/run on a fixed port); collides under the concurrent gate and cannot run standalone -->
|
|
329
|
+
```typescript
|
|
330
|
+
import { SurveyAgent } from '@signalwire/sdk';
|
|
331
|
+
|
|
332
|
+
const agent = new SurveyAgent({
|
|
333
|
+
name: 'CustomerSatisfaction',
|
|
334
|
+
surveyName: 'Customer Satisfaction Survey',
|
|
335
|
+
introduction: 'Hi, we would like your feedback about our service.',
|
|
336
|
+
conclusion: 'Thank you for your feedback.',
|
|
337
|
+
questions: [
|
|
338
|
+
{
|
|
339
|
+
id: 'overall',
|
|
340
|
+
text: 'On a scale of 1 to 10, how would you rate your overall experience?',
|
|
341
|
+
type: 'rating',
|
|
342
|
+
scale: 10,
|
|
343
|
+
points: { '9': 10, '10': 10, '7': 7, '8': 7 },
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
id: 'recommend',
|
|
347
|
+
text: 'Would you recommend us to a friend?',
|
|
348
|
+
type: 'yes_no',
|
|
349
|
+
points: { 'yes': 5, 'no': 0 },
|
|
350
|
+
nextQuestion: {
|
|
351
|
+
'yes': 'what_liked',
|
|
352
|
+
'no': 'what_improve',
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
id: 'what_liked',
|
|
357
|
+
text: 'What did you like the most about our service?',
|
|
358
|
+
type: 'open_ended',
|
|
359
|
+
nextQuestion: 'followup',
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
id: 'what_improve',
|
|
363
|
+
text: 'What could we improve?',
|
|
364
|
+
type: 'open_ended',
|
|
365
|
+
nextQuestion: 'followup',
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
id: 'followup',
|
|
369
|
+
text: 'How would you like us to follow up?',
|
|
370
|
+
type: 'multiple_choice',
|
|
371
|
+
options: ['Email', 'Phone call', 'No follow-up needed'],
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
onComplete: async (responses, score) => {
|
|
375
|
+
console.log('Survey complete. Score:', score);
|
|
376
|
+
console.log('Responses:', responses);
|
|
377
|
+
// Store results, send to analytics, etc.
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
await agent.run();
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
## FAQBotAgent
|
|
387
|
+
|
|
388
|
+
An agent that answers questions from a list of frequently asked questions. The prompt contains every question and answer, and a search tool tells the model which entries match the caller's question. It can transfer the caller to a live agent.
|
|
389
|
+
|
|
390
|
+
**Source:** `src/prefabs/FAQBotAgent.ts`
|
|
391
|
+
|
|
392
|
+
### FAQBot Configuration
|
|
393
|
+
|
|
394
|
+
The constructor accepts a `FAQBotConfig` object:
|
|
395
|
+
|
|
396
|
+
| Property | Type | Required | Default | Description |
|
|
397
|
+
|---|---|---|---|---|
|
|
398
|
+
| `name` | `string` | No | `"faq_bot"` | Agent name. |
|
|
399
|
+
| `route` | `string` | No | `"/faq"` | HTTP route for this agent. |
|
|
400
|
+
| `faqs` | `FAQEntry[]` | Yes | none | The FAQ entries. Each one with a question and an answer goes into the prompt. |
|
|
401
|
+
| `suggestRelated` | `boolean` | No | `true` | Add prompt instructions to suggest related questions. |
|
|
402
|
+
| `persona` | `string` | No | `"You are a helpful FAQ bot that provides accurate answers to common questions."` | Text of the prompt's Personality section. |
|
|
403
|
+
| `threshold` | `number` | No | `0.5` | Minimum match score, from 0 to 1, for `search_faqs` to return an entry. |
|
|
404
|
+
| `escalationMessage` | `string` | No | `"I'm sorry, I couldn't find an answer to your question. Let me transfer you to someone who can help."` | Start of the `escalate` tool's response. |
|
|
405
|
+
| `escalationNumber` | `string` | No | none | Phone number or SIP address `escalate` transfers to. Without it, the agent doesn't register `escalate`. |
|
|
406
|
+
| `agentOptions` | `Partial<AgentOptions>` | No | none | Other `AgentBase` options. |
|
|
407
|
+
|
|
408
|
+
Each `FAQEntry` has this shape:
|
|
409
|
+
|
|
410
|
+
| Property | Type | Required | Description |
|
|
411
|
+
|---|---|---|---|
|
|
412
|
+
| `question` | `string` | Yes | The question. |
|
|
413
|
+
| `answer` | `string` | Yes | The answer. |
|
|
414
|
+
| `keywords` | `string[]` | No | Words that raise the entry's match score when the query contains them. |
|
|
415
|
+
| `categories` | `string[]` | No | Categories, shown in the prompt and usable as a `search_faqs` filter. |
|
|
416
|
+
|
|
417
|
+
The agent adds the questions' words of four or more characters, the keywords and the categories as speech hints. Its `global_data` holds `faq_count` and `categories`.
|
|
418
|
+
|
|
419
|
+
### FAQBot Matching Engine
|
|
420
|
+
|
|
421
|
+
`search_faqs` scores each entry by the words it shares with the query.
|
|
422
|
+
|
|
423
|
+
**Tokenization:**
|
|
424
|
+
1. Text is lowercased.
|
|
425
|
+
2. Characters other than `a` to `z`, digits and white space become spaces.
|
|
426
|
+
3. Text is split on white space.
|
|
427
|
+
4. Words shorter than 2 characters are removed.
|
|
428
|
+
5. Common English stop words are removed ("the", "is", "to", "and", "or" and others).
|
|
429
|
+
|
|
430
|
+
**Scoring:**
|
|
431
|
+
- **Question overlap**: the number of query words found in the entry's question, divided by the smaller of the two word counts.
|
|
432
|
+
- **Keyword score**: the number of keywords found anywhere in the lowercased query, divided by the number of keywords.
|
|
433
|
+
- **Combined score**: with keywords, `0.6 * questionOverlap + 0.4 * keywordScore`. Without keywords, the question overlap alone.
|
|
434
|
+
|
|
435
|
+
Entries that score at least `threshold` match, best first.
|
|
436
|
+
|
|
437
|
+
### FAQBot Tools
|
|
438
|
+
|
|
439
|
+
#### `search_faqs`
|
|
440
|
+
|
|
441
|
+
Searches the FAQ entries for the caller's question.
|
|
442
|
+
|
|
443
|
+
**Parameters:**
|
|
444
|
+
|
|
445
|
+
| Name | Type | Required | Description |
|
|
446
|
+
|---|---|---|---|
|
|
447
|
+
| `query` | `string` | Not marked required | The search query. Without it, the tool returns `A query is required to search the FAQ.`. |
|
|
448
|
+
| `category` | `string` | No | Search only entries with this category, ignoring case. |
|
|
449
|
+
|
|
450
|
+
**Returns:** `Here are the most relevant FAQs:` and a numbered list of up to three matching questions, without their answers. The model finds the answers in its prompt. With no match, it returns `No matching FAQs found.`.
|
|
451
|
+
|
|
452
|
+
#### `escalate`
|
|
453
|
+
|
|
454
|
+
Transfers the caller. The agent registers it only when `escalationNumber` is set.
|
|
455
|
+
|
|
456
|
+
**Parameters:**
|
|
457
|
+
|
|
458
|
+
| Name | Type | Required | Description |
|
|
459
|
+
|---|---|---|---|
|
|
460
|
+
| `reason` | `string` | No | The reason for the transfer. Defaults to `"Caller needs assistance beyond FAQ"`. |
|
|
461
|
+
|
|
462
|
+
**Behavior:** Returns `escalationMessage` followed by the reason, with a `FunctionResult.connect()` action that transfers the call to `escalationNumber` permanently.
|
|
463
|
+
|
|
464
|
+
### FAQBot Example
|
|
465
|
+
|
|
466
|
+
This agent answers four questions and can transfer to a support line:
|
|
467
|
+
|
|
468
|
+
<!-- snippet: no-run starts a blocking HTTP server (serve/start/run on a fixed port); collides under the concurrent gate and cannot run standalone -->
|
|
469
|
+
```typescript
|
|
470
|
+
import { FAQBotAgent } from '@signalwire/sdk';
|
|
471
|
+
|
|
472
|
+
const agent = new FAQBotAgent({
|
|
473
|
+
name: 'HelpDesk',
|
|
474
|
+
threshold: 0.4,
|
|
475
|
+
escalationNumber: '+15559876543',
|
|
476
|
+
escalationMessage: 'I was not able to find an answer for that. Let me connect you with a support specialist.',
|
|
477
|
+
faqs: [
|
|
478
|
+
{
|
|
479
|
+
question: 'What are your business hours?',
|
|
480
|
+
answer: 'We are open Monday through Friday, 9 AM to 5 PM Eastern Time.',
|
|
481
|
+
keywords: ['hours', 'open', 'close', 'schedule', 'when'],
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
question: 'How do I reset my password?',
|
|
485
|
+
answer: 'Go to the login page, click "Forgot Password", and follow the email instructions.',
|
|
486
|
+
keywords: ['password', 'reset', 'forgot', 'login', 'locked'],
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
question: 'What is your return policy?',
|
|
490
|
+
answer: 'We offer a 30-day return policy for unused items in original packaging.',
|
|
491
|
+
keywords: ['return', 'refund', 'exchange', 'policy'],
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
question: 'How do I contact support?',
|
|
495
|
+
answer: 'You can reach our support team by calling this number, by email at support@example.com, or through live chat on our website.',
|
|
496
|
+
keywords: ['support', 'contact', 'help', 'email', 'chat'],
|
|
497
|
+
},
|
|
498
|
+
],
|
|
499
|
+
agentOptions: {
|
|
500
|
+
route: '/helpdesk',
|
|
501
|
+
},
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
await agent.run();
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
---
|
|
508
|
+
|
|
509
|
+
## ConciergeAgent
|
|
510
|
+
|
|
511
|
+
A concierge for a venue or business. Its prompt describes the venue's services, amenities and hours, and its tools answer availability and directions questions.
|
|
512
|
+
|
|
513
|
+
**Source:** `src/prefabs/ConciergeAgent.ts`
|
|
514
|
+
|
|
515
|
+
### Concierge Configuration
|
|
516
|
+
|
|
517
|
+
The constructor accepts a `ConciergeConfig` object:
|
|
518
|
+
|
|
519
|
+
| Property | Type | Required | Default | Description |
|
|
520
|
+
|---|---|---|---|---|
|
|
521
|
+
| `name` | `string` | No | `"concierge"` | Agent name. |
|
|
522
|
+
| `route` | `string` | No | `"/concierge"` | HTTP route for this agent. |
|
|
523
|
+
| `venueName` | `string` | Yes | none | Name of the venue or business. |
|
|
524
|
+
| `services` | `string[]` | Yes | none | Services offered. |
|
|
525
|
+
| `amenities` | `Record<string, Record<string, string>>` | Yes | none | Amenities, each a map of details such as `hours` and `location`. |
|
|
526
|
+
| `hoursOfOperation` | `Record<string, string>` | No | `{ default: '9 AM - 5 PM' }` | Opening hours by category. |
|
|
527
|
+
| `specialInstructions` | `string[]` | No | `[]` | Extra bullets for the prompt's Instructions section. |
|
|
528
|
+
| `welcomeMessage` | `string` | No | none | When set, the call's static greeting, which the caller can't interrupt. |
|
|
529
|
+
| `agentOptions` | `Partial<AgentOptions>` | No | none | Other `AgentBase` options. |
|
|
530
|
+
|
|
531
|
+
The venue name, the services and the amenity names become speech hints. The agent sets `local_tz` to `America/New_York` and enables the `check_time` native function.
|
|
532
|
+
|
|
533
|
+
### Concierge Tools
|
|
534
|
+
|
|
535
|
+
#### `check_availability`
|
|
536
|
+
|
|
537
|
+
Answers whether a service is available at a date and time.
|
|
538
|
+
|
|
539
|
+
**Parameters:**
|
|
540
|
+
|
|
541
|
+
| Name | Type | Required | Description |
|
|
542
|
+
|---|---|---|---|
|
|
543
|
+
| `service` | `string` | Not marked required | The service to check. |
|
|
544
|
+
| `date` | `string` | Not marked required | The date, in `YYYY-MM-DD` format. |
|
|
545
|
+
| `time` | `string` | Not marked required | The time, in 24-hour `HH:MM` format. |
|
|
546
|
+
|
|
547
|
+
**Returns:** For a service in `services` (ignoring case), a response that it's available at that date and time. The tool doesn't check a calendar or a booking system, so a listed service is always reported available. For any other service, a response listing the services offered. Override `checkAvailability()` in a subclass to look up real availability.
|
|
548
|
+
|
|
549
|
+
#### `get_directions`
|
|
550
|
+
|
|
551
|
+
Returns directions to an amenity.
|
|
552
|
+
|
|
553
|
+
**Parameters:**
|
|
554
|
+
|
|
555
|
+
| Name | Type | Required | Description |
|
|
556
|
+
|---|---|---|---|
|
|
557
|
+
| `location` | `string` | Not marked required | The amenity to get directions to. |
|
|
558
|
+
|
|
559
|
+
**Returns:** Directions built from the amenity's `location` detail. The lowercased `location` argument must equal the amenity's key exactly, so use lowercase keys in `amenities`. Otherwise, a response that suggests asking at the front desk.
|
|
560
|
+
|
|
561
|
+
### Concierge Example
|
|
562
|
+
|
|
563
|
+
This agent describes a hotel's services and two amenities:
|
|
564
|
+
|
|
565
|
+
<!-- snippet: no-run starts a blocking HTTP server (serve/start/run on a fixed port); collides under the concurrent gate and cannot run standalone -->
|
|
566
|
+
```typescript
|
|
567
|
+
import { ConciergeAgent } from '@signalwire/sdk';
|
|
568
|
+
|
|
569
|
+
const agent = new ConciergeAgent({
|
|
570
|
+
venueName: 'Grand Hotel',
|
|
571
|
+
services: ['room service', 'spa bookings', 'restaurant reservations'],
|
|
572
|
+
amenities: {
|
|
573
|
+
pool: { hours: '7 AM - 10 PM', location: '2nd Floor' },
|
|
574
|
+
gym: { hours: '24 hours', location: '3rd Floor' },
|
|
575
|
+
},
|
|
576
|
+
hoursOfOperation: { weekday: '9 AM - 9 PM', weekend: '10 AM - 6 PM' },
|
|
577
|
+
specialInstructions: ['Always mention the weekly wine tasting.'],
|
|
578
|
+
welcomeMessage: 'Welcome to the Grand Hotel. How may I assist you?',
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
await agent.run();
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
---
|
|
585
|
+
|
|
586
|
+
## ReceptionistAgent
|
|
587
|
+
|
|
588
|
+
A front-desk agent that greets callers, collects their name and reason for calling, and transfers them to a department. It can also check in visitors, a tool the Python SDK's prefab doesn't have.
|
|
589
|
+
|
|
590
|
+
**Source:** `src/prefabs/ReceptionistAgent.ts`
|
|
591
|
+
|
|
592
|
+
### Receptionist Configuration
|
|
593
|
+
|
|
594
|
+
The constructor accepts a `ReceptionistConfig` object:
|
|
595
|
+
|
|
596
|
+
| Property | Type | Required | Default | Description |
|
|
597
|
+
|---|---|---|---|---|
|
|
598
|
+
| `name` | `string` | No | `"receptionist"` | Agent name. |
|
|
599
|
+
| `route` | `string` | No | `"/receptionist"` | HTTP route for this agent. |
|
|
600
|
+
| `departments` | `ReceptionistDepartment[]` | Yes | none | Departments the agent can transfer callers to. The constructor throws if the list is empty or an entry lacks a field. |
|
|
601
|
+
| `greeting` | `string` | No | `"Thank you for calling. How can I help you today?"` | Greeting the prompt tells the model to begin with. |
|
|
602
|
+
| `voice` | `string` | No | `"rime.spore"` | Voice of the English (`en-US`) language the agent adds. |
|
|
603
|
+
| `companyName` | `string` | No | none | Company name, added to the greeting as `Welcome to <companyName>.` and as a speech hint. |
|
|
604
|
+
| `checkInEnabled` | `boolean` | No | `false` | Register the `check_in_visitor` tool. |
|
|
605
|
+
| `onVisitorCheckIn` | `(visitor: Record<string, string>) => void \| Promise<void>` | No | none | Called when `check_in_visitor` records a visitor. An error it throws is logged. |
|
|
606
|
+
| `agentOptions` | `Partial<AgentOptions>` | No | none | Other `AgentBase` options. |
|
|
607
|
+
|
|
608
|
+
Each `ReceptionistDepartment` has this shape:
|
|
609
|
+
|
|
610
|
+
| Property | Type | Required | Description |
|
|
611
|
+
|---|---|---|---|
|
|
612
|
+
| `name` | `string` | Yes | Department name, one of the `transfer_call` tool's allowed values. |
|
|
613
|
+
| `description` | `string` | Yes | What the department handles, listed in the prompt. |
|
|
614
|
+
| `number` | `string` | Yes | Phone number or SIP address to transfer to. |
|
|
615
|
+
|
|
616
|
+
The agent sets `end_of_speech_timeout` to 700, `speech_event_timeout` to 1000 and `transfer_summary` to `true`. Its `global_data` starts with `departments` and an empty `caller_info`.
|
|
617
|
+
|
|
618
|
+
### Receptionist Tools
|
|
619
|
+
|
|
620
|
+
#### `collect_caller_info`
|
|
621
|
+
|
|
622
|
+
Records the caller's name and reason for calling in `global_data.caller_info`, with a `set_global_data` action.
|
|
623
|
+
|
|
624
|
+
**Parameters:**
|
|
625
|
+
|
|
626
|
+
| Name | Type | Required | Description |
|
|
627
|
+
|---|---|---|---|
|
|
628
|
+
| `name` | `string` | Not marked required | The caller's name. |
|
|
629
|
+
| `reason` | `string` | Not marked required | The reason for the call. |
|
|
630
|
+
|
|
631
|
+
**Returns:** A response that repeats the name and reason.
|
|
632
|
+
|
|
633
|
+
#### `transfer_call`
|
|
634
|
+
|
|
635
|
+
Transfers the caller to a department.
|
|
636
|
+
|
|
637
|
+
**Parameters:**
|
|
638
|
+
|
|
639
|
+
| Name | Type | Required | Description |
|
|
640
|
+
|---|---|---|---|
|
|
641
|
+
| `department` | `string` (one of the department names) | Not marked required | The department to transfer to. |
|
|
642
|
+
|
|
643
|
+
**Behavior:**
|
|
644
|
+
- Reads `global_data.caller_info.name`, set by `collect_caller_info`, for the response.
|
|
645
|
+
- Sets `post_process`, which gives the model one more turn to respond before the transfer action runs.
|
|
646
|
+
- Adds a `connect(number, true)` action, a permanent transfer to the department's number.
|
|
647
|
+
- For an unknown department name, returns a response that it couldn't find the department, and doesn't transfer.
|
|
648
|
+
|
|
649
|
+
#### `check_in_visitor`
|
|
650
|
+
|
|
651
|
+
Registered only when `checkInEnabled` is `true`. Records a visitor in the call's in-memory state and calls `onVisitorCheckIn` with the record.
|
|
652
|
+
|
|
653
|
+
**Parameters:**
|
|
654
|
+
|
|
655
|
+
| Name | Type | Required | Description |
|
|
656
|
+
|---|---|---|---|
|
|
657
|
+
| `visitor_name` | `string` | Yes | Full name of the visitor. |
|
|
658
|
+
| `purpose` | `string` | Yes | Purpose of the visit. |
|
|
659
|
+
| `visiting` | `string` | Yes | The person or department the visitor is here to see. |
|
|
660
|
+
|
|
661
|
+
The record passed to `onVisitorCheckIn` has `visitor_name`, `purpose`, `visiting` and `checked_in_at`, an ISO 8601 time.
|
|
662
|
+
|
|
663
|
+
### Receptionist Example
|
|
664
|
+
|
|
665
|
+
This agent transfers callers to four departments and checks in visitors:
|
|
666
|
+
|
|
667
|
+
<!-- snippet: no-run starts a blocking HTTP server (serve/start/run on a fixed port); collides under the concurrent gate and cannot run standalone -->
|
|
668
|
+
```typescript
|
|
669
|
+
import { ReceptionistAgent } from '@signalwire/sdk';
|
|
670
|
+
|
|
671
|
+
const agent = new ReceptionistAgent({
|
|
672
|
+
companyName: 'Acme Corporation',
|
|
673
|
+
greeting: 'Thank you for calling Acme Corporation. How can I help you today?',
|
|
674
|
+
voice: 'rime.spore',
|
|
675
|
+
checkInEnabled: true,
|
|
676
|
+
departments: [
|
|
677
|
+
{
|
|
678
|
+
name: 'engineering',
|
|
679
|
+
description: 'Software development and technical teams',
|
|
680
|
+
number: '+15551001001',
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
name: 'hr',
|
|
684
|
+
description: 'Employee services, benefits, and recruiting',
|
|
685
|
+
number: '+15551001002',
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
name: 'marketing',
|
|
689
|
+
description: 'Brand, communications, and events',
|
|
690
|
+
number: '+15551001003',
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
name: 'executive',
|
|
694
|
+
description: 'CEO and executive leadership',
|
|
695
|
+
number: '+15551001004',
|
|
696
|
+
},
|
|
697
|
+
],
|
|
698
|
+
onVisitorCheckIn: async (visitor) => {
|
|
699
|
+
console.log('Visitor checked in:', visitor);
|
|
700
|
+
// Send a notification, update a visitor log, and so on
|
|
701
|
+
},
|
|
702
|
+
agentOptions: {
|
|
703
|
+
route: '/reception',
|
|
704
|
+
},
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
await agent.run();
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
---
|
|
711
|
+
|
|
712
|
+
## Factory Functions
|
|
713
|
+
|
|
714
|
+
Each prefab's source file also defines a factory function: `createInfoGathererAgent()`, `createSurveyAgent()`, `createFAQBotAgent()`, `createConciergeAgent()` and `createReceptionistAgent()`. Each takes the same config as its class and returns `new PrefabAgent(config)`.
|
|
715
|
+
|
|
716
|
+
The package's entry point (`@signalwire/sdk`) doesn't export these functions, and its `exports` map doesn't expose `src/prefabs/`, so code that installs the package can't import them. Use the class constructors, as the examples on this page do.
|
|
717
|
+
|
|
718
|
+
---
|
|
719
|
+
|
|
720
|
+
## Subclassing Prefabs
|
|
721
|
+
|
|
722
|
+
You can subclass a prefab to add prompt content or tools.
|
|
723
|
+
|
|
724
|
+
### Adding `PROMPT_SECTIONS`
|
|
725
|
+
|
|
726
|
+
The prefabs don't declare `static PROMPT_SECTIONS`; they build their prompts in their constructors. A subclass can declare `PROMPT_SECTIONS`, which the `AgentBase` constructor adds before the prefab adds its own sections. The prefab's sections stay, so use this to add content, not to replace the prefab's instructions:
|
|
727
|
+
|
|
728
|
+
```typescript
|
|
729
|
+
import { InfoGathererAgent } from '@signalwire/sdk';
|
|
730
|
+
import type { InfoGathererConfig } from '@signalwire/sdk';
|
|
731
|
+
|
|
732
|
+
class BilingualInfoGatherer extends InfoGathererAgent {
|
|
733
|
+
static override PROMPT_SECTIONS = [
|
|
734
|
+
{
|
|
735
|
+
title: 'Language',
|
|
736
|
+
body: 'You speak Spanish and English. Always respond in the same language the caller uses.',
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
title: 'Rules',
|
|
740
|
+
bullets: [
|
|
741
|
+
'Ask one question at a time, in the order provided by start_questions.',
|
|
742
|
+
'Use submit_answer to record each response and advance to the next question.',
|
|
743
|
+
'If the caller needs to try again, ask in their language.',
|
|
744
|
+
],
|
|
745
|
+
},
|
|
746
|
+
];
|
|
747
|
+
|
|
748
|
+
constructor(config: InfoGathererConfig) {
|
|
749
|
+
super(config);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
### Overriding `defineTools()`
|
|
755
|
+
|
|
756
|
+
Override `defineTools()` to add tools, and call `super.defineTools()` first to keep the prefab's own:
|
|
757
|
+
|
|
758
|
+
```typescript
|
|
759
|
+
import { FAQBotAgent, FunctionResult } from '@signalwire/sdk';
|
|
760
|
+
|
|
761
|
+
class FAQBotWithFeedback extends FAQBotAgent {
|
|
762
|
+
protected override defineTools(): void {
|
|
763
|
+
// Register all the default tools first
|
|
764
|
+
super.defineTools();
|
|
765
|
+
|
|
766
|
+
// Add a custom feedback tool
|
|
767
|
+
this.defineTool({
|
|
768
|
+
name: 'submit_feedback',
|
|
769
|
+
description: 'Allow the caller to submit feedback about the FAQ answers.',
|
|
770
|
+
parameters: {
|
|
771
|
+
type: 'object',
|
|
772
|
+
properties: {
|
|
773
|
+
rating: {
|
|
774
|
+
type: 'string',
|
|
775
|
+
description: 'How helpful was the answer: good, okay, or poor.',
|
|
776
|
+
},
|
|
777
|
+
comment: {
|
|
778
|
+
type: 'string',
|
|
779
|
+
description: 'Optional comment from the caller.',
|
|
780
|
+
},
|
|
781
|
+
},
|
|
782
|
+
required: ['rating'],
|
|
783
|
+
},
|
|
784
|
+
handler: (args: Record<string, unknown>) => {
|
|
785
|
+
const rating = args['rating'] as string;
|
|
786
|
+
const comment = args['comment'] as string | undefined;
|
|
787
|
+
console.log(`FAQ Feedback: ${rating}${comment ? ' - ' + comment : ''}`);
|
|
788
|
+
return new FunctionResult('The feedback was recorded.');
|
|
789
|
+
},
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
The prefab constructors call `ensureToolsDefined()` themselves, so the override runs during construction, before the subclass's own field initializers. Don't read subclass fields in it.
|
|
796
|
+
|
|
797
|
+
### Adding Dynamic Prompt Sections
|
|
798
|
+
|
|
799
|
+
Call `this.promptAddSection()` in the subclass constructor to add sections after the prefab's own:
|
|
800
|
+
|
|
801
|
+
```typescript
|
|
802
|
+
import { ConciergeAgent } from '@signalwire/sdk';
|
|
803
|
+
import type { ConciergeConfig } from '@signalwire/sdk';
|
|
804
|
+
|
|
805
|
+
class HolidayConcierge extends ConciergeAgent {
|
|
806
|
+
constructor(config: ConciergeConfig) {
|
|
807
|
+
super(config);
|
|
808
|
+
|
|
809
|
+
// Add a holiday schedule section to the prompt
|
|
810
|
+
this.promptAddSection('Holiday Schedule', {
|
|
811
|
+
body: 'The office is closed on December 25th and January 1st. All departments reopen on January 2nd.',
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
```
|