From 58a8bbd5212216f9506317ca632fbdf1c8978e1c Mon Sep 17 00:00:00 2001 From: Devon White Date: Fri, 3 Apr 2026 15:20:18 -0400 Subject: [PATCH] Add PHP SDK reference documentation - Add 800 PHP SDK reference pages, guide updates, and navigation - Align PHP SDK docs with public API: add 94 missing method pages, remove invalid ones - Fix broken links in index pages - Fix orphaned Card closing tags to pass fern check validation Co-Authored-By: Claude --- .../guides/build-ai-agents/adding-skills.mdx | 62 +- .../guides/build-ai-agents/agent-base.mdx | 68 +- .../guides/build-ai-agents/ai-parameters.mdx | 30 +- .../guides/build-ai-agents/architecture.mdx | 68 +- .../guides/build-ai-agents/builtin-skills.mdx | 30 +- .../guides/build-ai-agents/call-flow.mdx | 94 +- .../guides/build-ai-agents/call-recording.mdx | 44 +- .../guides/build-ai-agents/call-transfer.mdx | 158 +- .../guides/build-ai-agents/concierge.mdx | 36 +- .../build-ai-agents/contexts-workflows.mdx | 88 +- .../guides/build-ai-agents/custom-skills.mdx | 96 +- .../pages/guides/build-ai-agents/datamap.mdx | 130 +- .../build-ai-agents/defining-functions.mdx | 130 +- .../pages/guides/build-ai-agents/faq-bot.mdx | 46 +- .../pages/guides/build-ai-agents/hints.mdx | 48 +- .../guides/build-ai-agents/info-gatherer.mdx | 46 +- .../guides/build-ai-agents/lifecycle.mdx | 46 +- .../guides/build-ai-agents/mcp-gateway.mdx | 6 +- .../guides/build-ai-agents/multi-agent.mdx | 60 +- .../build-ai-agents/native-functions.mdx | 20 +- .../guides/build-ai-agents/parameters.mdx | 16 +- .../guides/build-ai-agents/prompts-pom.mdx | 22 +- .../guides/build-ai-agents/receptionist.mdx | 44 +- .../build-ai-agents/results-actions.mdx | 146 +- .../build-ai-agents/search-knowledge.mdx | 10 +- .../pages/guides/build-ai-agents/security.mdx | 36 +- .../guides/build-ai-agents/skill-config.mdx | 16 +- .../build-ai-agents/state-management.mdx | 144 +- .../build-ai-agents/static-vs-dynamic.mdx | 48 +- .../pages/guides/build-ai-agents/survey.mdx | 46 +- .../pages/guides/build-ai-agents/swaig.mdx | 120 +- .../pages/guides/build-ai-agents/swml.mdx | 32 +- .../build-ai-agents/understanding-skills.mdx | 136 +- .../guides/build-ai-agents/voice-language.mdx | 30 +- .../sdks/pages/guides/deploy/cgi-mode.mdx | 32 +- .../pages/guides/deploy/docker-kubernetes.mdx | 50 +- .../pages/guides/deploy/local-development.mdx | 4 +- .../sdks/pages/guides/deploy/overview.mdx | 30 +- .../sdks/pages/guides/deploy/production.mdx | 54 +- .../sdks/pages/guides/deploy/serverless.mdx | 38 +- .../getting-started/dev-environment.mdx | 40 +- .../guides/getting-started/installation.mdx | 44 +- .../pages/guides/getting-started/overview.mdx | 28 +- .../guides/getting-started/quickstart.mdx | 248 +-- .../make-and-receive-calls/overview.mdx | 62 +- .../manage-resources/mapping-numbers.mdx | 4 +- .../guides/manage-resources/overview.mdx | 72 +- .../guides/manage-resources/phone-numbers.mdx | 6 +- .../pages/guides/manage-resources/testing.mdx | 42 +- .../manage-resources/troubleshooting.mdx | 6 +- .../sdks/pages/reference/core/overview.mdx | 43 +- .../php/agents/agent-base/add-answer-verb.mdx | 35 + .../agent-base/add-function-include.mdx | 56 + .../php/agents/agent-base/add-hint.mdx | 36 + .../php/agents/agent-base/add-hints.mdx | 34 + .../agents/agent-base/add-internal-filler.mdx | 50 + .../php/agents/agent-base/add-language.mdx | 115 ++ .../agents/agent-base/add-pattern-hint.mdx | 54 + .../agents/agent-base/add-post-ai-verb.mdx | 43 + .../agent-base/add-post-answer-verb.mdx | 42 + .../agents/agent-base/add-pre-answer-verb.mdx | 54 + .../agents/agent-base/add-pronunciation.mdx | 45 + .../php/agents/agent-base/add-skill.mdx | 69 + .../agent-base/add-swaig-query-params.mdx | 72 + .../php/agents/agent-base/build-ai-verb.mdx | 32 + .../agents/agent-base/clear-post-ai-verbs.mdx | 29 + .../agent-base/clear-post-answer-verbs.mdx | 31 + .../agent-base/clear-pre-answer-verbs.mdx | 31 + .../agent-base/clear-swaig-query-params.mdx | 47 + .../agents/agent-base/clone-for-request.mdx | 29 + .../php/agents/agent-base/contexts.mdx | 29 + .../php/agents/agent-base/define-contexts.mdx | 92 + .../php/agents/agent-base/define-tool.mdx | 119 ++ .../php/agents/agent-base/define-tools.mdx | 31 + .../agents/agent-base/enable-debug-events.mdx | 42 + .../agents/agent-base/enable-sip-routing.mdx | 43 + .../agent-base/get-basic-auth-credentials.mdx | 60 + .../php/agents/agent-base/get-full-url.mdx | 43 + .../php/agents/agent-base/get-name.mdx | 28 + .../php/agents/agent-base/get-prompt.mdx | 31 + .../php/agents/agent-base/has-skill.mdx | 32 + .../reference/php/agents/agent-base/index.mdx | 573 +++++++ .../php/agents/agent-base/list-skills.mdx | 26 + .../agent-base/manual-set-proxy-url.mdx | 42 + .../php/agents/agent-base/on-debug-event.mdx | 57 + .../agents/agent-base/on-function-call.mdx | 43 + .../php/agents/agent-base/on-summary.mdx | 73 + .../agents/agent-base/prompt-add-section.mdx | 67 + .../agent-base/prompt-add-subsection.mdx | 51 + .../agent-base/prompt-add-to-section.mdx | 51 + .../agents/agent-base/prompt-has-section.mdx | 67 + .../agent-base/register-sip-username.mdx | 37 + .../agent-base/register-swaig-function.mdx | 59 + .../php/agents/agent-base/remove-skill.mdx | 35 + .../php/agents/agent-base/render-swml.mdx | 40 + .../reference/php/agents/agent-base/run.mdx | 100 ++ .../reference/php/agents/agent-base/serve.mdx | 54 + .../set-dynamic-config-callback.mdx | 57 + .../agent-base/set-function-includes.mdx | 56 + .../php/agents/agent-base/set-global-data.mdx | 46 + .../agent-base/set-internal-fillers.mdx | 46 + .../php/agents/agent-base/set-languages.mdx | 40 + .../agent-base/set-native-functions.mdx | 31 + .../php/agents/agent-base/set-param.mdx | 38 + .../php/agents/agent-base/set-params.mdx | 136 ++ .../agent-base/set-post-prompt-llm-params.mdx | 38 + .../agents/agent-base/set-post-prompt-url.mdx | 37 + .../php/agents/agent-base/set-post-prompt.mdx | 46 + .../agent-base/set-prompt-llm-params.mdx | 62 + .../php/agents/agent-base/set-prompt-text.mdx | 51 + .../agents/agent-base/set-pronunciations.mdx | 39 + .../agents/agent-base/set-web-hook-url.mdx | 43 + .../agents/agent-base/update-global-data.mdx | 50 + .../php/agents/agent-server/get-agent.mdx | 45 + .../php/agents/agent-server/get-agents.mdx | 36 + .../php/agents/agent-server/get-host.mdx | 29 + .../php/agents/agent-server/get-port.mdx | 29 + .../agent-server/get-sip-username-mapping.mdx | 29 + .../agents/agent-server/handle-request.mdx | 50 + .../php/agents/agent-server/index.mdx | 116 ++ .../agent-server/is-sip-routing-enabled.mdx | 29 + .../agent-server/register-sip-username.mdx | 38 + .../php/agents/agent-server/register.mdx | 54 + .../reference/php/agents/agent-server/run.mdx | 105 ++ .../php/agents/agent-server/serve-static.mdx | 38 + .../php/agents/agent-server/serve.mdx | 29 + .../agents/agent-server/setup-sip-routing.mdx | 29 + .../php/agents/agent-server/unregister.mdx | 41 + .../php/agents/bedrock-agent/index.mdx | 162 ++ .../pages/reference/php/agents/cli/index.mdx | 104 ++ .../auth-handler/flask-decorator.mdx | 51 + .../auth-handler/get-auth-info.mdx | 35 + .../auth-handler/get-fastapi-dependency.mdx | 53 + .../configuration/auth-handler/index.mdx | 83 + .../auth-handler/verify-api-key.mdx | 35 + .../auth-handler/verify-basic-auth.mdx | 40 + .../auth-handler/verify-bearer-token.mdx | 46 + .../config-loader/find-config-file.mdx | 49 + .../config-loader/get-config-file.mdx | 31 + .../config-loader/get-config.mdx | 27 + .../config-loader/get-section.mdx | 34 + .../configuration/config-loader/get.mdx | 42 + .../config-loader/has-config.mdx | 29 + .../configuration/config-loader/index.mdx | 82 + .../config-loader/merge-with-env.mdx | 36 + .../config-loader/substitute-vars.mdx | 56 + .../php/agents/configuration/index.mdx | 126 ++ .../security-config/get-basic-auth.mdx | 34 + .../security-config/get-cors-config.mdx | 32 + .../security-config/get-security-headers.mdx | 39 + .../get-ssl-context-kwargs.mdx | 31 + .../security-config/get-url-scheme.mdx | 26 + .../configuration/security-config/index.mdx | 141 ++ .../security-config/load-from-env.mdx | 30 + .../security-config/log-config.mdx | 31 + .../security-config/should-allow-host.mdx | 32 + .../security-config/validate-ssl-config.mdx | 32 + .../agents/context-builder/add-context.mdx | 68 + .../context-builder/context/add-bullets.mdx | 47 + .../context/add-enter-filler.mdx | 47 + .../context/add-exit-filler.mdx | 47 + .../context-builder/context/add-section.mdx | 43 + .../context-builder/context/add-step.mdx | 93 ++ .../context/add-system-bullets.mdx | 48 + .../context/add-system-section.mdx | 45 + .../context-builder/context/get-step.mdx | 43 + .../agents/context-builder/context/index.mdx | 167 ++ .../context-builder/context/move-step.mdx | 44 + .../context-builder/context/remove-step.mdx | 41 + .../context/set-consolidate.mdx | 42 + .../context/set-enter-fillers.mdx | 44 + .../context/set-exit-fillers.mdx | 44 + .../context/set-full-reset.mdx | 42 + .../context-builder/context/set-isolated.mdx | 42 + .../context/set-post-prompt.mdx | 40 + .../context-builder/context/set-prompt.mdx | 39 + .../context/set-system-prompt.mdx | 39 + .../context/set-user-prompt.mdx | 39 + .../context/set-valid-contexts.mdx | 44 + .../context/set-valid-steps.mdx | 41 + .../agents/context-builder/get-context.mdx | 43 + .../php/agents/context-builder/index.mdx | 151 ++ .../context-builder/step/add-bullets.mdx | 47 + .../step/add-gather-question.mdx | 90 + .../context-builder/step/add-section.mdx | 43 + .../context-builder/step/clear-sections.mdx | 35 + .../php/agents/context-builder/step/index.mdx | 133 ++ .../agents/context-builder/step/set-end.mdx | 40 + .../context-builder/step/set-functions.mdx | 43 + .../context-builder/step/set-gather-info.mdx | 71 + .../step/set-reset-consolidate.mdx | 43 + .../step/set-reset-full-reset.mdx | 47 + .../step/set-reset-system-prompt.mdx | 45 + .../step/set-reset-user-prompt.mdx | 45 + .../step/set-skip-to-next-step.mdx | 41 + .../step/set-skip-user-turn.mdx | 41 + .../step/set-step-criteria.mdx | 50 + .../agents/context-builder/step/set-text.mdx | 44 + .../step/set-valid-contexts.mdx | 45 + .../context-builder/step/set-valid-steps.mdx | 43 + .../php/agents/context-builder/validate.mdx | 48 + .../reference/php/agents/data-map/body.mdx | 76 + .../data-map/create-expression-tool.mdx | 48 + .../data-map/create-simple-api-tool.mdx | 64 + .../php/agents/data-map/description.mdx | 31 + .../php/agents/data-map/error-keys.mdx | 63 + .../php/agents/data-map/expression.mdx | 69 + .../php/agents/data-map/fallback-output.mdx | 31 + .../reference/php/agents/data-map/foreach.mdx | 78 + .../php/agents/data-map/global-error-keys.mdx | 31 + .../reference/php/agents/data-map/index.mdx | 219 +++ .../reference/php/agents/data-map/output.mdx | 76 + .../php/agents/data-map/parameter.mdx | 62 + .../reference/php/agents/data-map/params.mdx | 31 + .../reference/php/agents/data-map/purpose.mdx | 63 + .../php/agents/data-map/to-swaig-function.mdx | 49 + .../agents/data-map/webhook-expressions.mdx | 57 + .../reference/php/agents/data-map/webhook.mdx | 94 ++ .../php/agents/function-result/add-action.mdx | 56 + .../agents/function-result/add-actions.mdx | 50 + .../function-result/add-dynamic-hints.mdx | 85 + .../function-result/clear-dynamic-hints.mdx | 41 + .../php/agents/function-result/connect.mdx | 116 ++ .../function-result/create-payment-action.mdx | 66 + .../create-payment-parameter.mdx | 66 + .../function-result/create-payment-prompt.mdx | 75 + .../function-result/enable-extensive-data.mdx | 46 + .../enable-functions-on-timeout.mdx | 46 + .../agents/function-result/execute-rpc.mdx | 67 + .../agents/function-result/execute-swml.mdx | 75 + .../php/agents/function-result/hangup.mdx | 44 + .../php/agents/function-result/hold.mdx | 45 + .../php/agents/function-result/index.mdx | 390 +++++ .../function-result/join-conference.mdx | 184 ++ .../php/agents/function-result/join-room.mdx | 45 + .../php/agents/function-result/pay.mdx | 138 ++ .../function-result/play-background-file.mdx | 52 + .../agents/function-result/record-call.mdx | 137 ++ .../function-result/remove-global-data.mdx | 44 + .../function-result/remove-metadata.mdx | 44 + .../function-result/replace-in-history.mdx | 82 + .../agents/function-result/rpc-ai-message.mdx | 58 + .../agents/function-result/rpc-ai-unhold.mdx | 48 + .../php/agents/function-result/rpc-dial.mdx | 68 + .../php/agents/function-result/say.mdx | 46 + .../php/agents/function-result/send-sms.mdx | 105 ++ .../set-end-of-speech-timeout.mdx | 47 + .../agents/function-result/set-metadata.mdx | 50 + .../function-result/set-post-process.mdx | 48 + .../agents/function-result/set-response.mdx | 50 + .../set-speech-event-timeout.mdx | 49 + .../function-result/simulate-user-input.mdx | 46 + .../php/agents/function-result/sip-refer.mdx | 55 + .../function-result/stop-background-file.mdx | 38 + .../function-result/stop-record-call.mdx | 45 + .../php/agents/function-result/stop-tap.mdx | 45 + .../php/agents/function-result/stop.mdx | 40 + .../agents/function-result/switch-context.mdx | 99 ++ .../function-result/swml-change-context.mdx | 48 + .../function-result/swml-change-step.mdx | 49 + .../agents/function-result/swml-transfer.mdx | 66 + .../function-result/swml-user-event.mdx | 52 + .../php/agents/function-result/tap.mdx | 80 + .../php/agents/function-result/to-array.mdx | 29 + .../php/agents/function-result/to-json.mdx | 29 + .../function-result/toggle-functions.mdx | 52 + .../function-result/update-global-data.mdx | 51 + .../function-result/update-settings.mdx | 59 + .../agents/function-result/wait-for-user.mdx | 82 + .../pages/reference/php/agents/helpers.mdx | 328 ++++ .../agents/livewire/agent-server/index.mdx | 58 + .../livewire/agent-server/rtc-session.mdx | 82 + .../livewire/agent-session/generate-reply.mdx | 47 + .../agents/livewire/agent-session/index.mdx | 67 + .../livewire/agent-session/interrupt.mdx | 47 + .../php/agents/livewire/agent-session/say.mdx | 47 + .../agents/livewire/agent-session/start.mdx | 68 + .../livewire/agent-session/update-agent.mdx | 65 + .../php/agents/livewire/agent/index.mdx | 76 + .../php/agents/livewire/agent/on-enter.mdx | 54 + .../php/agents/livewire/agent/on-exit.mdx | 50 + .../livewire/agent/on-user-turn-completed.mdx | 57 + .../agents/livewire/agent/pipeline-nodes.mdx | 96 ++ .../livewire/agent/update-instructions.mdx | 57 + .../agents/livewire/agent/update-tools.mdx | 55 + .../reference/php/agents/livewire/index.mdx | 150 ++ .../php/agents/mcp-gateway/index.mdx | 63 + .../agents/mcp-gateway/mcp-gateway/index.mdx | 93 ++ .../agents/mcp-gateway/mcp-gateway/run.mdx | 36 + .../mcp-gateway/mcp-gateway/shutdown.mdx | 44 + .../mcp-gateway/mcp-manager/create-client.mdx | 45 + .../mcp-manager/get-service-tools.mdx | 41 + .../agents/mcp-gateway/mcp-manager/index.mdx | 122 ++ .../mcp-gateway/mcp-manager/shutdown.mdx | 42 + .../mcp-manager/validate-services.mdx | 45 + .../session-manager/close-session.mdx | 38 + .../session-manager/create-session.mdx | 65 + .../session-manager/get-session.mdx | 40 + .../mcp-gateway/session-manager/index.mdx | 115 ++ .../session-manager/list-sessions.mdx | 34 + .../mcp-gateway/session-manager/shutdown.mdx | 34 + .../pages/reference/php/agents/overview.mdx | 202 +++ .../php/agents/pom-builder/add-section.mdx | 83 + .../php/agents/pom-builder/has-section.mdx | 55 + .../php/agents/pom-builder/index.mdx | 141 ++ .../php/agents/pom-builder/render.mdx | 50 + .../php/agents/pom-builder/to-json.mdx | 28 + .../pages/reference/php/agents/prefabs.mdx | 601 +++++++ .../document-processor/create-chunks.mdx | 58 + .../search/document-processor/index.mdx | 64 + .../build-index-from-sources.mdx | 63 + .../search/index-builder/build-index.mdx | 58 + .../php/agents/search/index-builder/index.mdx | 68 + .../search/index-builder/validate-index.mdx | 44 + .../reference/php/agents/search/index.mdx | 106 ++ .../agents/search/migrator/get-index-info.mdx | 40 + .../php/agents/search/migrator/index.mdx | 40 + .../migrator/migrate-pgvector-to-sqlite.mdx | 57 + .../migrator/migrate-sqlite-to-pgvector.mdx | 59 + .../agents/search/search-engine/get-stats.mdx | 42 + .../php/agents/search/search-engine/index.mdx | 58 + .../agents/search/search-engine/search.mdx | 83 + .../agents/search/search-service/index.mdx | 74 + .../search/search-service/search-direct.mdx | 62 + .../agents/search/search-service/start.mdx | 47 + .../php/agents/search/search-service/stop.mdx | 38 + .../php/agents/skill-base/cleanup.mdx | 46 + .../php/agents/skill-base/define-tool.mdx | 67 + .../php/agents/skill-base/get-description.mdx | 33 + .../php/agents/skill-base/get-global-data.mdx | 46 + .../php/agents/skill-base/get-hints.mdx | 45 + .../agents/skill-base/get-instance-key.mdx | 59 + .../php/agents/skill-base/get-name.mdx | 33 + .../skill-base/get-parameter-schema.mdx | 87 + .../agents/skill-base/get-prompt-sections.mdx | 70 + .../skill-base/get-required-env-vars.mdx | 33 + .../php/agents/skill-base/get-version.mdx | 33 + .../reference/php/agents/skill-base/index.mdx | 243 +++ .../php/agents/skill-base/register-tools.mdx | 63 + .../reference/php/agents/skill-base/setup.mdx | 53 + .../supports-multiple-instances.mdx | 33 + .../agents/skill-base/validate-env-vars.mdx | 33 + .../php/agents/skill-base/validate.mdx | 55 + .../pages/reference/php/agents/skills.mdx | 1075 ++++++++++++ .../php/agents/swaig-function/execute.mdx | 66 + .../php/agents/swaig-function/index.mdx | 206 +++ .../php/agents/swml-builder/add-raw-verb.mdx | 38 + .../php/agents/swml-builder/add-section.mdx | 43 + .../swml-builder/add-verb-to-section.mdx | 43 + .../php/agents/swml-builder/add-verb.mdx | 38 + .../reference/php/agents/swml-builder/ai.mdx | 90 + .../php/agents/swml-builder/answer.mdx | 44 + .../php/agents/swml-builder/clear-section.mdx | 31 + .../php/agents/swml-builder/get-verbs.mdx | 32 + .../php/agents/swml-builder/get-version.mdx | 29 + .../php/agents/swml-builder/hangup.mdx | 40 + .../php/agents/swml-builder/has-section.mdx | 31 + .../php/agents/swml-builder/index.mdx | 232 +++ .../php/agents/swml-builder/play.mdx | 93 ++ .../php/agents/swml-builder/render-pretty.mdx | 29 + .../php/agents/swml-builder/render.mdx | 28 + .../php/agents/swml-builder/reset.mdx | 34 + .../reference/php/agents/swml-builder/say.mdx | 61 + .../php/agents/swml-builder/to-array.mdx | 29 + .../php/agents/swml-service/add-section.mdx | 38 + .../swml-service/add-verb-to-section.mdx | 52 + .../php/agents/swml-service/add-verb.mdx | 53 + .../swml-service/extract-sip-username.mdx | 31 + .../get-basic-auth-credentials.mdx | 46 + .../php/agents/swml-service/get-document.mdx | 42 + .../php/agents/swml-service/get-full-url.mdx | 32 + .../php/agents/swml-service/get-host.mdx | 29 + .../php/agents/swml-service/get-name.mdx | 29 + .../php/agents/swml-service/get-port.mdx | 29 + .../swml-service/get-proxy-url-base.mdx | 32 + .../php/agents/swml-service/get-route.mdx | 29 + .../agents/swml-service/handle-request.mdx | 50 + .../php/agents/swml-service/index.mdx | 204 +++ .../swml-service/manual-set-proxy-url.mdx | 48 + .../register-routing-callback.mdx | 108 ++ .../php/agents/swml-service/render-pretty.mdx | 29 + .../php/agents/swml-service/render-swml.mdx | 40 + .../php/agents/swml-service/render.mdx | 29 + .../reference/php/agents/swml-service/run.mdx | 29 + .../php/agents/swml-service/serve.mdx | 67 + .../php/agents/swml-service/stop.mdx | 26 + .../php/agents/web-service/index.mdx | 80 + .../reference/php/agents/web-service/stop.mdx | 30 + .../php/relay/actions/ai-action/index.mdx | 65 + .../php/relay/actions/ai-action/stop.mdx | 43 + .../relay/actions/collect-action/index.mdx | 78 + .../collect-action/start-input-timers.mdx | 49 + .../php/relay/actions/collect-action/stop.mdx | 43 + .../relay/actions/collect-action/volume.mdx | 49 + .../php/relay/actions/detect-action/index.mdx | 67 + .../php/relay/actions/detect-action/stop.mdx | 42 + .../php/relay/actions/fax-action/index.mdx | 63 + .../php/relay/actions/fax-action/stop.mdx | 43 + .../reference/php/relay/actions/index.mdx | 173 ++ .../php/relay/actions/pay-action/index.mdx | 61 + .../php/relay/actions/pay-action/stop.mdx | 44 + .../php/relay/actions/play-action/index.mdx | 80 + .../php/relay/actions/play-action/pause.mdx | 44 + .../php/relay/actions/play-action/resume.mdx | 44 + .../php/relay/actions/play-action/stop.mdx | 40 + .../php/relay/actions/play-action/volume.mdx | 52 + .../php/relay/actions/record-action/index.mdx | 71 + .../php/relay/actions/record-action/pause.mdx | 49 + .../relay/actions/record-action/resume.mdx | 44 + .../php/relay/actions/record-action/stop.mdx | 40 + .../standalone-collect-action/index.mdx | 66 + .../start-input-timers.mdx | 47 + .../standalone-collect-action/stop.mdx | 44 + .../php/relay/actions/stream-action/index.mdx | 59 + .../php/relay/actions/stream-action/stop.mdx | 43 + .../php/relay/actions/tap-action/index.mdx | 59 + .../php/relay/actions/tap-action/stop.mdx | 43 + .../relay/actions/transcribe-action/index.mdx | 56 + .../relay/actions/transcribe-action/stop.mdx | 40 + .../reference/php/relay/call/ai-hold.mdx | 68 + .../reference/php/relay/call/ai-message.mdx | 82 + .../reference/php/relay/call/ai-unhold.mdx | 59 + .../pages/reference/php/relay/call/ai.mdx | 154 ++ .../php/relay/call/amazon-bedrock.mdx | 72 + .../pages/reference/php/relay/call/answer.mdx | 52 + .../reference/php/relay/call/bind-digit.mdx | 86 + .../php/relay/call/clear-digit-bindings.mdx | 55 + .../reference/php/relay/call/collect.mdx | 131 ++ .../reference/php/relay/call/connect.mdx | 94 ++ .../reference/php/relay/call/denoise-stop.mdx | 49 + .../reference/php/relay/call/denoise.mdx | 59 + .../pages/reference/php/relay/call/detect.mdx | 102 ++ .../reference/php/relay/call/disconnect.mdx | 58 + .../pages/reference/php/relay/call/echo.mdx | 63 + .../pages/reference/php/relay/call/hangup.mdx | 50 + .../pages/reference/php/relay/call/hold.mdx | 64 + .../pages/reference/php/relay/call/index.mdx | 280 ++++ .../php/relay/call/join-conference.mdx | 158 ++ .../reference/php/relay/call/join-room.mdx | 58 + .../php/relay/call/leave-conference.mdx | 48 + .../reference/php/relay/call/leave-room.mdx | 47 + .../php/relay/call/live-transcribe.mdx | 79 + .../php/relay/call/live-translate.mdx | 74 + .../pages/reference/php/relay/call/on.mdx | 69 + .../pages/reference/php/relay/call/pass.mdx | 53 + .../pages/reference/php/relay/call/pay.mdx | 159 ++ .../php/relay/call/play-and-collect.mdx | 140 ++ .../pages/reference/php/relay/call/play.mdx | 155 ++ .../reference/php/relay/call/queue-enter.mdx | 69 + .../reference/php/relay/call/queue-leave.mdx | 72 + .../reference/php/relay/call/receive-fax.mdx | 67 + .../pages/reference/php/relay/call/record.mdx | 120 ++ .../pages/reference/php/relay/call/refer.mdx | 76 + .../reference/php/relay/call/send-digits.mdx | 58 + .../reference/php/relay/call/send-fax.mdx | 80 + .../pages/reference/php/relay/call/stream.mdx | 111 ++ .../pages/reference/php/relay/call/tap.mdx | 104 ++ .../reference/php/relay/call/transcribe.mdx | 83 + .../reference/php/relay/call/transfer.mdx | 51 + .../pages/reference/php/relay/call/unhold.mdx | 59 + .../reference/php/relay/call/user-event.mdx | 54 + .../reference/php/relay/client/connect.mdx | 95 ++ .../pages/reference/php/relay/client/dial.mdx | 179 ++ .../reference/php/relay/client/disconnect.mdx | 64 + .../reference/php/relay/client/execute.mdx | 77 + .../reference/php/relay/client/index.mdx | 215 +++ .../reference/php/relay/client/receive.mdx | 91 + .../pages/reference/php/relay/client/run.mdx | 62 + .../php/relay/client/send-message.mdx | 164 ++ .../reference/php/relay/client/unreceive.mdx | 59 + .../pages/reference/php/relay/constants.mdx | 278 +++ .../sdks/pages/reference/php/relay/events.mdx | 1483 +++++++++++++++++ .../reference/php/relay/message/index.mdx | 220 +++ .../pages/reference/php/relay/message/on.mdx | 60 + .../reference/php/relay/message/wait.mdx | 67 + .../pages/reference/php/relay/overview.mdx | 152 ++ .../pages/reference/php/relay/relay-error.mdx | 59 + .../reference/php/rest/addresses/create.mdx | 67 + .../reference/php/rest/addresses/delete.mdx | 35 + .../reference/php/rest/addresses/get.mdx | 36 + .../reference/php/rest/addresses/index.mdx | 53 + .../reference/php/rest/addresses/list.mdx | 38 + .../reference/php/rest/calling/ai-hold.mdx | 37 + .../reference/php/rest/calling/ai-message.mdx | 51 + .../reference/php/rest/calling/ai-stop.mdx | 42 + .../reference/php/rest/calling/ai-unhold.mdx | 43 + .../calling/collect-start-input-timers.mdx | 60 + .../php/rest/calling/collect-stop.mdx | 41 + .../reference/php/rest/calling/collect.mdx | 109 ++ .../php/rest/calling/denoise-stop.mdx | 35 + .../reference/php/rest/calling/denoise.mdx | 36 + .../php/rest/calling/detect-stop.mdx | 41 + .../reference/php/rest/calling/detect.mdx | 101 ++ .../pages/reference/php/rest/calling/dial.mdx | 51 + .../reference/php/rest/calling/disconnect.mdx | 36 + .../pages/reference/php/rest/calling/end.mdx | 43 + .../php/rest/calling/get-base-path.mdx | 35 + .../reference/php/rest/calling/get-client.mdx | 35 + .../php/rest/calling/get-project-id.mdx | 35 + .../reference/php/rest/calling/index.mdx | 253 +++ .../php/rest/calling/live-transcribe.mdx | 44 + .../php/rest/calling/live-translate.mdx | 48 + .../reference/php/rest/calling/play-pause.mdx | 41 + .../php/rest/calling/play-resume.mdx | 41 + .../reference/php/rest/calling/play-stop.mdx | 41 + .../php/rest/calling/play-volume.mdx | 45 + .../pages/reference/php/rest/calling/play.mdx | 110 ++ .../php/rest/calling/receive-fax-stop.mdx | 46 + .../php/rest/calling/record-pause.mdx | 43 + .../php/rest/calling/record-resume.mdx | 41 + .../php/rest/calling/record-stop.mdx | 42 + .../reference/php/rest/calling/record.mdx | 59 + .../reference/php/rest/calling/refer.mdx | 52 + .../php/rest/calling/send-fax-stop.mdx | 46 + .../php/rest/calling/stream-stop.mdx | 41 + .../reference/php/rest/calling/stream.mdx | 60 + .../reference/php/rest/calling/tap-stop.mdx | 41 + .../pages/reference/php/rest/calling/tap.mdx | 56 + .../php/rest/calling/transcribe-stop.mdx | 41 + .../reference/php/rest/calling/transcribe.mdx | 44 + .../reference/php/rest/calling/transfer.mdx | 44 + .../php/rest/calling/update-call.mdx | 38 + .../reference/php/rest/calling/update.mdx | 41 + .../reference/php/rest/calling/user-event.mdx | 50 + .../sdks/pages/reference/php/rest/chat.mdx | 72 + .../reference/php/rest/client/addresses.mdx | 33 + .../reference/php/rest/client/calling.mdx | 33 + .../pages/reference/php/rest/client/chat.mdx | 33 + .../reference/php/rest/client/compat.mdx | 33 + .../reference/php/rest/client/datasphere.mdx | 33 + .../reference/php/rest/client/fabric.mdx | 33 + .../php/rest/client/get-base-url.mdx | 33 + .../reference/php/rest/client/get-http.mdx | 33 + .../php/rest/client/get-project-id.mdx | 33 + .../reference/php/rest/client/get-space.mdx | 33 + .../reference/php/rest/client/get-token.mdx | 33 + .../php/rest/client/imported-numbers.mdx | 33 + .../pages/reference/php/rest/client/index.mdx | 279 ++++ .../pages/reference/php/rest/client/logs.mdx | 33 + .../reference/php/rest/client/lookup.mdx | 33 + .../pages/reference/php/rest/client/mfa.mdx | 33 + .../php/rest/client/number-groups.mdx | 33 + .../php/rest/client/phone-numbers.mdx | 33 + .../reference/php/rest/client/project.mdx | 33 + .../reference/php/rest/client/pubsub.mdx | 33 + .../reference/php/rest/client/queues.mdx | 33 + .../reference/php/rest/client/recordings.mdx | 33 + .../reference/php/rest/client/registry.mdx | 33 + .../reference/php/rest/client/short-codes.mdx | 33 + .../reference/php/rest/client/sip-profile.mdx | 33 + .../php/rest/client/verified-callers.mdx | 33 + .../pages/reference/php/rest/client/video.mdx | 33 + .../php/rest/compat/accounts/create.mdx | 35 + .../php/rest/compat/accounts/get.mdx | 35 + .../php/rest/compat/accounts/index.mdx | 49 + .../php/rest/compat/accounts/list.mdx | 29 + .../php/rest/compat/accounts/update.mdx | 47 + .../php/rest/compat/applications/create.mdx | 59 + .../php/rest/compat/applications/delete.mdx | 35 + .../php/rest/compat/applications/get.mdx | 35 + .../php/rest/compat/applications/index.mdx | 53 + .../php/rest/compat/applications/list.mdx | 39 + .../php/rest/compat/applications/update.mdx | 54 + .../php/rest/compat/calls/create.mdx | 61 + .../php/rest/compat/calls/delete.mdx | 35 + .../reference/php/rest/compat/calls/get.mdx | 35 + .../reference/php/rest/compat/calls/index.mdx | 81 + .../reference/php/rest/compat/calls/list.mdx | 56 + .../php/rest/compat/calls/start-recording.mdx | 46 + .../php/rest/compat/calls/start-stream.mdx | 39 + .../php/rest/compat/calls/stop-stream.mdx | 39 + .../rest/compat/calls/update-recording.mdx | 47 + .../php/rest/compat/calls/update.mdx | 43 + .../compat/conferences/delete-recording.mdx | 39 + .../compat/conferences/get-participant.mdx | 39 + .../rest/compat/conferences/get-recording.mdx | 39 + .../php/rest/compat/conferences/get.mdx | 35 + .../php/rest/compat/conferences/index.mdx | 103 ++ .../compat/conferences/list-participants.mdx | 43 + .../compat/conferences/list-recordings.mdx | 35 + .../php/rest/compat/conferences/list.mdx | 47 + .../compat/conferences/remove-participant.mdx | 39 + .../rest/compat/conferences/start-stream.mdx | 42 + .../rest/compat/conferences/stop-stream.mdx | 39 + .../compat/conferences/update-participant.mdx | 47 + .../compat/conferences/update-recording.mdx | 47 + .../php/rest/compat/conferences/update.mdx | 43 + .../php/rest/compat/faxes/create.mdx | 51 + .../php/rest/compat/faxes/delete-media.mdx | 39 + .../php/rest/compat/faxes/delete.mdx | 35 + .../php/rest/compat/faxes/get-media.mdx | 39 + .../reference/php/rest/compat/faxes/get.mdx | 35 + .../reference/php/rest/compat/faxes/index.mdx | 73 + .../php/rest/compat/faxes/list-media.mdx | 35 + .../reference/php/rest/compat/faxes/list.mdx | 29 + .../php/rest/compat/faxes/update.mdx | 35 + .../pages/reference/php/rest/compat/index.mdx | 126 ++ .../php/rest/compat/laml-bins/create.mdx | 45 + .../php/rest/compat/laml-bins/delete.mdx | 35 + .../php/rest/compat/laml-bins/get.mdx | 35 + .../php/rest/compat/laml-bins/index.mdx | 53 + .../php/rest/compat/laml-bins/list.mdx | 39 + .../php/rest/compat/laml-bins/update.mdx | 49 + .../php/rest/compat/messages/create.mdx | 64 + .../php/rest/compat/messages/delete-media.mdx | 39 + .../php/rest/compat/messages/delete.mdx | 35 + .../php/rest/compat/messages/get-media.mdx | 39 + .../php/rest/compat/messages/get.mdx | 35 + .../php/rest/compat/messages/index.mdx | 71 + .../php/rest/compat/messages/list-media.mdx | 35 + .../php/rest/compat/messages/list.mdx | 43 + .../php/rest/compat/messages/update.mdx | 39 + .../php/rest/compat/phone-numbers/delete.mdx | 35 + .../php/rest/compat/phone-numbers/get.mdx | 35 + .../compat/phone-numbers/import-number.mdx | 41 + .../php/rest/compat/phone-numbers/index.mdx | 81 + .../list-available-countries.mdx | 33 + .../php/rest/compat/phone-numbers/list.mdx | 43 + .../rest/compat/phone-numbers/purchase.mdx | 54 + .../compat/phone-numbers/search-local.mdx | 51 + .../compat/phone-numbers/search-toll-free.mdx | 43 + .../php/rest/compat/phone-numbers/update.mdx | 54 + .../php/rest/compat/queues/create.mdx | 42 + .../php/rest/compat/queues/delete.mdx | 35 + .../php/rest/compat/queues/dequeue-member.mdx | 50 + .../php/rest/compat/queues/get-member.mdx | 39 + .../reference/php/rest/compat/queues/get.mdx | 35 + .../php/rest/compat/queues/index.mdx | 72 + .../php/rest/compat/queues/list-members.mdx | 39 + .../reference/php/rest/compat/queues/list.mdx | 39 + .../php/rest/compat/queues/update.mdx | 43 + .../php/rest/compat/recordings/delete.mdx | 35 + .../php/rest/compat/recordings/get.mdx | 35 + .../php/rest/compat/recordings/index.mdx | 44 + .../php/rest/compat/recordings/list.mdx | 43 + .../php/rest/compat/tokens/create.mdx | 35 + .../php/rest/compat/tokens/delete.mdx | 35 + .../php/rest/compat/tokens/index.mdx | 44 + .../php/rest/compat/tokens/update.mdx | 39 + .../php/rest/compat/transcriptions/delete.mdx | 35 + .../php/rest/compat/transcriptions/get.mdx | 35 + .../php/rest/compat/transcriptions/index.mdx | 44 + .../php/rest/compat/transcriptions/list.mdx | 35 + .../reference/php/rest/datasphere/create.mdx | 49 + .../reference/php/rest/datasphere/delete.mdx | 35 + .../reference/php/rest/datasphere/get.mdx | 36 + .../reference/php/rest/datasphere/index.mdx | 57 + .../reference/php/rest/datasphere/list.mdx | 38 + .../reference/php/rest/datasphere/update.mdx | 43 + .../reference/php/rest/fabric/addresses.mdx | 70 + .../reference/php/rest/fabric/ai-agents.mdx | 35 + .../php/rest/fabric/ai-agents/create.mdx | 40 + .../php/rest/fabric/ai-agents/delete.mdx | 36 + .../php/rest/fabric/ai-agents/get.mdx | 36 + .../php/rest/fabric/ai-agents/index.mdx | 56 + .../rest/fabric/ai-agents/list-addresses.mdx | 38 + .../php/rest/fabric/ai-agents/list.mdx | 42 + .../php/rest/fabric/ai-agents/update.mdx | 38 + .../reference/php/rest/fabric/call-flows.mdx | 35 + .../php/rest/fabric/call-flows/create.mdx | 40 + .../php/rest/fabric/call-flows/delete.mdx | 36 + .../rest/fabric/call-flows/deploy-version.mdx | 40 + .../php/rest/fabric/call-flows/get.mdx | 36 + .../php/rest/fabric/call-flows/index.mdx | 65 + .../rest/fabric/call-flows/list-addresses.mdx | 38 + .../rest/fabric/call-flows/list-versions.mdx | 46 + .../php/rest/fabric/call-flows/list.mdx | 42 + .../php/rest/fabric/call-flows/update.mdx | 38 + .../reference/php/rest/fabric/call-queues.mdx | 35 + .../php/rest/fabric/conference-rooms.mdx | 35 + .../rest/fabric/conference-rooms/create.mdx | 40 + .../rest/fabric/conference-rooms/delete.mdx | 36 + .../php/rest/fabric/conference-rooms/get.mdx | 36 + .../rest/fabric/conference-rooms/index.mdx | 56 + .../conference-rooms/list-addresses.mdx | 38 + .../php/rest/fabric/conference-rooms/list.mdx | 42 + .../rest/fabric/conference-rooms/update.mdx | 38 + .../php/rest/fabric/conversations.mdx | 35 + .../rest/fabric/cxml-applications/delete.mdx | 36 + .../php/rest/fabric/cxml-applications/get.mdx | 36 + .../rest/fabric/cxml-applications/index.mdx | 53 + .../cxml-applications/list-addresses.mdx | 38 + .../rest/fabric/cxml-applications/list.mdx | 42 + .../rest/fabric/cxml-applications/update.mdx | 40 + .../php/rest/fabric/cxml-scripts/create.mdx | 40 + .../php/rest/fabric/cxml-scripts/delete.mdx | 36 + .../php/rest/fabric/cxml-scripts/get.mdx | 36 + .../php/rest/fabric/cxml-scripts/index.mdx | 56 + .../fabric/cxml-scripts/list-addresses.mdx | 38 + .../php/rest/fabric/cxml-scripts/list.mdx | 42 + .../php/rest/fabric/cxml-scripts/update.mdx | 38 + .../php/rest/fabric/cxml-webhooks/create.mdx | 40 + .../php/rest/fabric/cxml-webhooks/delete.mdx | 36 + .../php/rest/fabric/cxml-webhooks/get.mdx | 36 + .../php/rest/fabric/cxml-webhooks/index.mdx | 56 + .../fabric/cxml-webhooks/list-addresses.mdx | 38 + .../php/rest/fabric/cxml-webhooks/list.mdx | 42 + .../php/rest/fabric/cxml-webhooks/update.mdx | 38 + .../reference/php/rest/fabric/dial-plans.mdx | 35 + .../php/rest/fabric/freeclimb-apps.mdx | 35 + .../fabric/freeswitch-connectors/create.mdx | 40 + .../fabric/freeswitch-connectors/delete.mdx | 36 + .../rest/fabric/freeswitch-connectors/get.mdx | 36 + .../fabric/freeswitch-connectors/index.mdx | 56 + .../freeswitch-connectors/list-addresses.mdx | 38 + .../fabric/freeswitch-connectors/list.mdx | 42 + .../fabric/freeswitch-connectors/update.mdx | 38 + .../reference/php/rest/fabric/get-client.mdx | 35 + .../pages/reference/php/rest/fabric/index.mdx | 176 ++ .../php/rest/fabric/phone-numbers.mdx | 35 + .../rest/fabric/relay-applications/create.mdx | 40 + .../rest/fabric/relay-applications/delete.mdx | 36 + .../rest/fabric/relay-applications/get.mdx | 36 + .../rest/fabric/relay-applications/index.mdx | 56 + .../relay-applications/list-addresses.mdx | 38 + .../rest/fabric/relay-applications/list.mdx | 42 + .../rest/fabric/relay-applications/update.mdx | 38 + .../resources/assign-domain-application.mdx | 40 + .../fabric/resources/assign-phone-route.mdx | 40 + .../php/rest/fabric/resources/delete.mdx | 36 + .../php/rest/fabric/resources/get.mdx | 36 + .../php/rest/fabric/resources/index.mdx | 58 + .../rest/fabric/resources/list-addresses.mdx | 38 + .../php/rest/fabric/resources/list.mdx | 42 + .../php/rest/fabric/sip-endpoints.mdx | 35 + .../php/rest/fabric/sip-endpoints/create.mdx | 40 + .../php/rest/fabric/sip-endpoints/delete.mdx | 36 + .../php/rest/fabric/sip-endpoints/get.mdx | 36 + .../php/rest/fabric/sip-endpoints/index.mdx | 63 + .../fabric/sip-endpoints/list-addresses.mdx | 38 + .../php/rest/fabric/sip-endpoints/list.mdx | 42 + .../php/rest/fabric/sip-endpoints/update.mdx | 38 + .../php/rest/fabric/sip-gateways/create.mdx | 40 + .../php/rest/fabric/sip-gateways/delete.mdx | 36 + .../php/rest/fabric/sip-gateways/get.mdx | 36 + .../php/rest/fabric/sip-gateways/index.mdx | 56 + .../fabric/sip-gateways/list-addresses.mdx | 38 + .../php/rest/fabric/sip-gateways/list.mdx | 42 + .../php/rest/fabric/sip-gateways/update.mdx | 38 + .../php/rest/fabric/sip-profiles.mdx | 35 + .../reference/php/rest/fabric/subscribers.mdx | 35 + .../subscribers/create-sip-endpoint.mdx | 40 + .../php/rest/fabric/subscribers/create.mdx | 40 + .../subscribers/delete-sip-endpoint.mdx | 40 + .../php/rest/fabric/subscribers/delete.mdx | 36 + .../fabric/subscribers/get-sip-endpoint.mdx | 40 + .../php/rest/fabric/subscribers/get.mdx | 36 + .../php/rest/fabric/subscribers/index.mdx | 77 + .../fabric/subscribers/list-addresses.mdx | 38 + .../fabric/subscribers/list-sip-endpoints.mdx | 46 + .../php/rest/fabric/subscribers/list.mdx | 42 + .../subscribers/update-sip-endpoint.mdx | 44 + .../php/rest/fabric/subscribers/update.mdx | 38 + .../php/rest/fabric/swml-scripts.mdx | 35 + .../php/rest/fabric/swml-scripts/create.mdx | 40 + .../php/rest/fabric/swml-scripts/delete.mdx | 36 + .../php/rest/fabric/swml-scripts/get.mdx | 36 + .../php/rest/fabric/swml-scripts/index.mdx | 56 + .../fabric/swml-scripts/list-addresses.mdx | 38 + .../php/rest/fabric/swml-scripts/list.mdx | 42 + .../php/rest/fabric/swml-scripts/update.mdx | 38 + .../php/rest/fabric/swml-webhooks/create.mdx | 40 + .../php/rest/fabric/swml-webhooks/delete.mdx | 36 + .../php/rest/fabric/swml-webhooks/get.mdx | 36 + .../php/rest/fabric/swml-webhooks/index.mdx | 56 + .../fabric/swml-webhooks/list-addresses.mdx | 38 + .../php/rest/fabric/swml-webhooks/list.mdx | 42 + .../php/rest/fabric/swml-webhooks/update.mdx | 38 + .../rest/fabric/tokens/create-embed-token.mdx | 34 + .../rest/fabric/tokens/create-guest-token.mdx | 34 + .../fabric/tokens/create-invite-token.mdx | 34 + .../fabric/tokens/create-subscriber-token.mdx | 38 + .../php/rest/fabric/tokens/index.mdx | 52 + .../tokens/refresh-subscriber-token.mdx | 38 + .../reference/php/rest/imported-numbers.mdx | 65 + .../pages/reference/php/rest/logs/index.mdx | 40 + .../reference/php/rest/logs/voice/get.mdx | 36 + .../reference/php/rest/logs/voice/index.mdx | 48 + .../php/rest/logs/voice/list-events.mdx | 43 + .../reference/php/rest/logs/voice/list.mdx | 38 + .../sdks/pages/reference/php/rest/lookup.mdx | 63 + .../pages/reference/php/rest/mfa/index.mdx | 34 + .../php/rest/number-groups/create.mdx | 40 + .../php/rest/number-groups/delete.mdx | 35 + .../reference/php/rest/number-groups/get.mdx | 36 + .../php/rest/number-groups/index.mdx | 57 + .../reference/php/rest/number-groups/list.mdx | 38 + .../php/rest/number-groups/update.mdx | 40 + .../pages/reference/php/rest/overview.mdx | 153 ++ .../php/rest/phone-numbers/create.mdx | 43 + .../php/rest/phone-numbers/delete.mdx | 35 + .../reference/php/rest/phone-numbers/get.mdx | 36 + .../php/rest/phone-numbers/index.mdx | 56 + .../reference/php/rest/phone-numbers/list.mdx | 40 + .../php/rest/phone-numbers/update.mdx | 39 + .../reference/php/rest/project/create.mdx | 39 + .../reference/php/rest/project/delete.mdx | 37 + .../reference/php/rest/project/index.mdx | 46 + .../reference/php/rest/project/update.mdx | 41 + .../sdks/pages/reference/php/rest/pubsub.mdx | 73 + .../reference/php/rest/queues/create.mdx | 40 + .../reference/php/rest/queues/delete.mdx | 36 + .../pages/reference/php/rest/queues/get.mdx | 36 + .../pages/reference/php/rest/queues/index.mdx | 56 + .../pages/reference/php/rest/queues/list.mdx | 38 + .../reference/php/rest/queues/update.mdx | 40 + .../reference/php/rest/recordings/delete.mdx | 35 + .../reference/php/rest/recordings/get.mdx | 36 + .../reference/php/rest/recordings/index.mdx | 49 + .../reference/php/rest/recordings/list.mdx | 38 + .../rest/registry/brands/create-campaign.mdx | 56 + .../php/rest/registry/brands/create.mdx | 51 + .../php/rest/registry/brands/get.mdx | 36 + .../php/rest/registry/brands/index.mdx | 56 + .../rest/registry/brands/list-campaigns.mdx | 42 + .../php/rest/registry/brands/list.mdx | 38 + .../rest/registry/campaigns/create-order.mdx | 47 + .../php/rest/registry/campaigns/get.mdx | 36 + .../php/rest/registry/campaigns/index.mdx | 54 + .../rest/registry/campaigns/list-numbers.mdx | 42 + .../rest/registry/campaigns/list-orders.mdx | 42 + .../php/rest/registry/campaigns/update.mdx | 43 + .../reference/php/rest/registry/index.mdx | 49 + .../reference/php/rest/short-codes/get.mdx | 36 + .../reference/php/rest/short-codes/index.mdx | 49 + .../reference/php/rest/short-codes/list.mdx | 38 + .../reference/php/rest/short-codes/update.mdx | 42 + .../pages/reference/php/rest/sip-profile.mdx | 88 + .../php/rest/verified-callers/create.mdx | 41 + .../php/rest/verified-callers/delete.mdx | 36 + .../php/rest/verified-callers/get.mdx | 36 + .../php/rest/verified-callers/index.mdx | 56 + .../php/rest/verified-callers/list.mdx | 38 + .../php/rest/verified-callers/update.mdx | 40 + .../php/rest/video/conference-tokens/get.mdx | 35 + .../rest/video/conference-tokens/index.mdx | 26 + .../rest/video/conference-tokens/reset.mdx | 35 + .../rest/video/conferences/create-stream.mdx | 45 + .../php/rest/video/conferences/create.mdx | 37 + .../php/rest/video/conferences/delete.mdx | 35 + .../php/rest/video/conferences/get.mdx | 35 + .../php/rest/video/conferences/index.mdx | 65 + .../conferences/list-conference-tokens.mdx | 37 + .../rest/video/conferences/list-streams.mdx | 37 + .../php/rest/video/conferences/list.mdx | 37 + .../php/rest/video/conferences/update.mdx | 43 + .../pages/reference/php/rest/video/index.mdx | 63 + .../php/rest/video/room-recordings/delete.mdx | 35 + .../php/rest/video/room-recordings/get.mdx | 35 + .../php/rest/video/room-recordings/index.mdx | 49 + .../video/room-recordings/list-events.mdx | 38 + .../php/rest/video/room-recordings/list.mdx | 37 + .../php/rest/video/room-sessions/get.mdx | 35 + .../php/rest/video/room-sessions/index.mdx | 53 + .../rest/video/room-sessions/list-events.mdx | 38 + .../rest/video/room-sessions/list-members.mdx | 37 + .../video/room-sessions/list-recordings.mdx | 37 + .../php/rest/video/room-sessions/list.mdx | 37 + .../php/rest/video/room-tokens/create.mdx | 63 + .../php/rest/video/room-tokens/index.mdx | 22 + .../php/rest/video/rooms/create-stream.mdx | 45 + .../reference/php/rest/video/rooms/create.mdx | 41 + .../reference/php/rest/video/rooms/delete.mdx | 35 + .../reference/php/rest/video/rooms/get.mdx | 35 + .../reference/php/rest/video/rooms/index.mdx | 61 + .../php/rest/video/rooms/list-streams.mdx | 37 + .../reference/php/rest/video/rooms/list.mdx | 37 + .../reference/php/rest/video/rooms/update.mdx | 43 + .../php/rest/video/streams/delete.mdx | 35 + .../reference/php/rest/video/streams/get.mdx | 36 + .../php/rest/video/streams/index.mdx | 45 + .../php/rest/video/streams/update.mdx | 46 + .../agent-base/auto-map-sip-usernames.mdx | 56 - .../agents/agent-base/define-contexts.mdx | 20 +- .../python/agents/agent-base/define-tools.mdx | 63 - .../agents/agent-base/enable-debug-routes.mdx | 31 - .../python/agents/agent-base/index.mdx | 20 - .../agents/agent-base/on-function-call.mdx | 69 - .../agents/agent-base/on-swml-request.mdx | 78 - .../agent-base/register-swaig-function.mdx | 9 +- .../pages/reference/python/agents/helpers.mdx | 2 +- .../python/agents/livewire/plugins.mdx | 4 +- .../python/agents/swml-builder/index.mdx | 5 +- .../reference/python/relay/client/index.mdx | 3 +- .../reference/python/relay/relay-error.mdx | 2 +- .../pages/reference/python/rest/mfa/index.mdx | 2 +- fern/products/sdks/sdks.yml | 16 + 887 files changed, 49662 insertions(+), 1827 deletions(-) create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/add-answer-verb.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/add-function-include.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/add-hint.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/add-hints.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/add-internal-filler.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/add-language.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/add-pattern-hint.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/add-post-ai-verb.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/add-post-answer-verb.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/add-pre-answer-verb.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/add-pronunciation.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/add-skill.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/add-swaig-query-params.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/build-ai-verb.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/clear-post-ai-verbs.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/clear-post-answer-verbs.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/clear-pre-answer-verbs.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/clear-swaig-query-params.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/clone-for-request.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/contexts.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/define-contexts.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/define-tool.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/define-tools.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/enable-debug-events.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/enable-sip-routing.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/get-basic-auth-credentials.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/get-full-url.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/get-name.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/get-prompt.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/has-skill.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/list-skills.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/manual-set-proxy-url.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/on-debug-event.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/on-function-call.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/on-summary.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/prompt-add-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/prompt-add-subsection.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/prompt-add-to-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/prompt-has-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/register-sip-username.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/register-swaig-function.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/remove-skill.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/render-swml.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/run.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/serve.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-dynamic-config-callback.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-function-includes.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-global-data.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-internal-fillers.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-languages.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-native-functions.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-param.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-params.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-post-prompt-llm-params.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-post-prompt-url.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-post-prompt.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-prompt-llm-params.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-prompt-text.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-pronunciations.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/set-web-hook-url.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-base/update-global-data.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/get-agent.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/get-agents.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/get-host.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/get-port.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/get-sip-username-mapping.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/handle-request.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/is-sip-routing-enabled.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/register-sip-username.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/register.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/run.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/serve-static.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/serve.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/setup-sip-routing.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/agent-server/unregister.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/bedrock-agent/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/cli/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/flask-decorator.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/get-auth-info.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/get-fastapi-dependency.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/verify-api-key.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/verify-basic-auth.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/verify-bearer-token.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/config-loader/find-config-file.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get-config-file.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get-config.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/config-loader/has-config.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/config-loader/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/config-loader/merge-with-env.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/config-loader/substitute-vars.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-basic-auth.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-cors-config.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-security-headers.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-ssl-context-kwargs.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-url-scheme.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/security-config/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/security-config/load-from-env.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/security-config/log-config.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/security-config/should-allow-host.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/configuration/security-config/validate-ssl-config.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/add-context.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/add-bullets.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/add-enter-filler.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/add-exit-filler.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/add-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/add-step.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/add-system-bullets.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/add-system-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/get-step.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/move-step.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/remove-step.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/set-consolidate.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/set-enter-fillers.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/set-exit-fillers.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/set-full-reset.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/set-isolated.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/set-post-prompt.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/set-prompt.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/set-system-prompt.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/set-user-prompt.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/set-valid-contexts.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/context/set-valid-steps.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/get-context.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/add-bullets.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/add-gather-question.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/add-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/clear-sections.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/set-end.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/set-functions.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/set-gather-info.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-consolidate.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-full-reset.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-system-prompt.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-user-prompt.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/set-skip-to-next-step.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/set-skip-user-turn.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/set-step-criteria.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/set-text.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/set-valid-contexts.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/step/set-valid-steps.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/context-builder/validate.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/body.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/create-expression-tool.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/create-simple-api-tool.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/description.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/error-keys.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/expression.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/fallback-output.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/foreach.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/global-error-keys.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/output.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/parameter.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/params.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/purpose.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/to-swaig-function.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/webhook-expressions.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/data-map/webhook.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/add-action.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/add-actions.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/add-dynamic-hints.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/clear-dynamic-hints.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/connect.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/create-payment-action.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/create-payment-parameter.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/create-payment-prompt.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/enable-extensive-data.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/enable-functions-on-timeout.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/execute-rpc.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/execute-swml.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/hangup.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/hold.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/join-conference.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/join-room.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/pay.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/play-background-file.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/record-call.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/remove-global-data.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/remove-metadata.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/replace-in-history.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/rpc-ai-message.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/rpc-ai-unhold.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/rpc-dial.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/say.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/send-sms.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/set-end-of-speech-timeout.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/set-metadata.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/set-post-process.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/set-response.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/set-speech-event-timeout.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/simulate-user-input.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/sip-refer.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/stop-background-file.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/stop-record-call.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/stop-tap.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/switch-context.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/swml-change-context.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/swml-change-step.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/swml-transfer.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/swml-user-event.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/tap.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/to-array.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/to-json.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/toggle-functions.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/update-global-data.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/update-settings.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/function-result/wait-for-user.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/helpers.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent-server/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent-server/rtc-session.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent-session/generate-reply.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent-session/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent-session/interrupt.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent-session/say.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent-session/start.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent-session/update-agent.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent/on-enter.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent/on-exit.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent/on-user-turn-completed.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent/pipeline-nodes.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent/update-instructions.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/agent/update-tools.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/livewire/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-gateway/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-gateway/run.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-gateway/shutdown.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/create-client.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/get-service-tools.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/shutdown.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/validate-services.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/close-session.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/create-session.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/get-session.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/list-sessions.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/shutdown.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/overview.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/pom-builder/add-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/pom-builder/has-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/pom-builder/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/pom-builder/render.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/pom-builder/to-json.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/prefabs.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/document-processor/create-chunks.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/document-processor/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/index-builder/build-index-from-sources.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/index-builder/build-index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/index-builder/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/index-builder/validate-index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/migrator/get-index-info.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/migrator/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/migrator/migrate-pgvector-to-sqlite.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/migrator/migrate-sqlite-to-pgvector.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/search-engine/get-stats.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/search-engine/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/search-engine/search.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/search-service/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/search-service/search-direct.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/search-service/start.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/search/search-service/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/cleanup.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/define-tool.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/get-description.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/get-global-data.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/get-hints.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/get-instance-key.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/get-name.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/get-parameter-schema.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/get-prompt-sections.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/get-required-env-vars.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/get-version.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/register-tools.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/setup.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/supports-multiple-instances.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/validate-env-vars.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skill-base/validate.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/skills.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swaig-function/execute.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swaig-function/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/add-raw-verb.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/add-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/add-verb-to-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/add-verb.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/ai.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/answer.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/clear-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/get-verbs.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/get-version.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/hangup.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/has-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/play.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/render-pretty.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/render.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/reset.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/say.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-builder/to-array.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/add-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/add-verb-to-section.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/add-verb.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/extract-sip-username.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/get-basic-auth-credentials.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/get-document.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/get-full-url.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/get-host.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/get-name.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/get-port.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/get-proxy-url-base.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/get-route.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/handle-request.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/manual-set-proxy-url.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/register-routing-callback.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/render-pretty.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/render-swml.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/render.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/run.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/serve.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/swml-service/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/web-service/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/agents/web-service/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/ai-action/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/ai-action/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/collect-action/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/collect-action/start-input-timers.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/collect-action/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/collect-action/volume.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/detect-action/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/detect-action/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/fax-action/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/fax-action/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/pay-action/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/pay-action/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/play-action/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/play-action/pause.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/play-action/resume.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/play-action/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/play-action/volume.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/record-action/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/record-action/pause.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/record-action/resume.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/record-action/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/standalone-collect-action/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/standalone-collect-action/start-input-timers.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/standalone-collect-action/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/stream-action/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/stream-action/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/tap-action/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/tap-action/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/transcribe-action/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/actions/transcribe-action/stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/ai-hold.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/ai-message.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/ai-unhold.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/ai.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/amazon-bedrock.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/answer.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/bind-digit.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/clear-digit-bindings.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/collect.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/connect.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/denoise-stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/denoise.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/detect.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/disconnect.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/echo.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/hangup.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/hold.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/join-conference.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/join-room.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/leave-conference.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/leave-room.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/live-transcribe.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/live-translate.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/on.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/pass.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/pay.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/play-and-collect.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/play.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/queue-enter.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/queue-leave.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/receive-fax.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/record.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/refer.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/send-digits.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/send-fax.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/stream.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/tap.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/transcribe.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/transfer.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/unhold.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/call/user-event.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/client/connect.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/client/dial.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/client/disconnect.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/client/execute.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/client/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/client/receive.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/client/run.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/client/send-message.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/client/unreceive.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/constants.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/events.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/message/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/message/on.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/message/wait.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/overview.mdx create mode 100644 fern/products/sdks/pages/reference/php/relay/relay-error.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/addresses/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/addresses/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/addresses/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/addresses/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/addresses/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/ai-hold.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/ai-message.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/ai-stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/ai-unhold.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/collect-start-input-timers.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/collect-stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/collect.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/denoise-stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/denoise.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/detect-stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/detect.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/dial.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/disconnect.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/end.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/get-base-path.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/get-client.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/get-project-id.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/live-transcribe.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/live-translate.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/play-pause.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/play-resume.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/play-stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/play-volume.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/play.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/receive-fax-stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/record-pause.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/record-resume.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/record-stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/record.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/refer.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/send-fax-stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/stream-stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/stream.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/tap-stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/tap.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/transcribe-stop.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/transcribe.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/transfer.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/update-call.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/calling/user-event.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/chat.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/calling.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/chat.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/compat.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/datasphere.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/fabric.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/get-base-url.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/get-http.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/get-project-id.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/get-space.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/get-token.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/imported-numbers.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/logs.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/lookup.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/mfa.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/number-groups.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/phone-numbers.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/project.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/pubsub.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/queues.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/recordings.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/registry.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/short-codes.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/sip-profile.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/verified-callers.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/client/video.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/accounts/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/accounts/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/accounts/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/accounts/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/accounts/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/applications/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/applications/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/applications/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/applications/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/applications/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/applications/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/calls/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/calls/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/calls/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/calls/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/calls/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/calls/start-recording.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/calls/start-stream.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/calls/stop-stream.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/calls/update-recording.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/calls/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/conferences/delete-recording.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/conferences/get-participant.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/conferences/get-recording.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/conferences/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/conferences/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/conferences/list-participants.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/conferences/list-recordings.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/conferences/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/conferences/remove-participant.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/conferences/start-stream.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/conferences/stop-stream.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/conferences/update-participant.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/conferences/update-recording.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/conferences/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/faxes/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/faxes/delete-media.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/faxes/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/faxes/get-media.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/faxes/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/faxes/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/faxes/list-media.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/faxes/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/faxes/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/laml-bins/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/laml-bins/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/laml-bins/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/laml-bins/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/laml-bins/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/laml-bins/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/messages/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/messages/delete-media.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/messages/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/messages/get-media.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/messages/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/messages/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/messages/list-media.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/messages/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/messages/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/import-number.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/list-available-countries.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/purchase.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/search-local.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/search-toll-free.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/queues/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/queues/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/queues/dequeue-member.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/queues/get-member.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/queues/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/queues/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/queues/list-members.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/queues/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/queues/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/recordings/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/recordings/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/recordings/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/recordings/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/tokens/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/tokens/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/tokens/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/tokens/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/transcriptions/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/transcriptions/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/transcriptions/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/compat/transcriptions/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/datasphere/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/datasphere/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/datasphere/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/datasphere/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/datasphere/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/datasphere/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/ai-agents.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/list-addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/call-flows.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/call-flows/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/call-flows/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/call-flows/deploy-version.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/call-flows/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/call-flows/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/call-flows/list-addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/call-flows/list-versions.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/call-flows/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/call-flows/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/call-queues.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/list-addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/conversations.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/list-addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/list-addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/list-addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/dial-plans.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/freeclimb-apps.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/list-addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/get-client.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/phone-numbers.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/list-addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/resources/assign-domain-application.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/resources/assign-phone-route.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/resources/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/resources/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/resources/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/resources/list-addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/resources/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/list-addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/list-addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/sip-profiles.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/subscribers.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/subscribers/create-sip-endpoint.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/subscribers/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/subscribers/delete-sip-endpoint.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/subscribers/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/subscribers/get-sip-endpoint.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/subscribers/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/subscribers/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/subscribers/list-addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/subscribers/list-sip-endpoints.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/subscribers/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/subscribers/update-sip-endpoint.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/subscribers/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/list-addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/list-addresses.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-embed-token.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-guest-token.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-invite-token.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-subscriber-token.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/tokens/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/fabric/tokens/refresh-subscriber-token.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/imported-numbers.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/logs/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/logs/voice/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/logs/voice/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/logs/voice/list-events.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/logs/voice/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/lookup.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/mfa/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/number-groups/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/number-groups/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/number-groups/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/number-groups/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/number-groups/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/number-groups/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/overview.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/phone-numbers/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/phone-numbers/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/phone-numbers/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/phone-numbers/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/phone-numbers/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/phone-numbers/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/project/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/project/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/project/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/project/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/pubsub.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/queues/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/queues/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/queues/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/queues/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/queues/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/queues/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/recordings/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/recordings/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/recordings/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/recordings/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/registry/brands/create-campaign.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/registry/brands/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/registry/brands/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/registry/brands/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/registry/brands/list-campaigns.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/registry/brands/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/registry/campaigns/create-order.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/registry/campaigns/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/registry/campaigns/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/registry/campaigns/list-numbers.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/registry/campaigns/list-orders.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/registry/campaigns/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/registry/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/short-codes/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/short-codes/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/short-codes/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/short-codes/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/sip-profile.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/verified-callers/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/verified-callers/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/verified-callers/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/verified-callers/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/verified-callers/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/verified-callers/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/conference-tokens/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/conference-tokens/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/conference-tokens/reset.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/conferences/create-stream.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/conferences/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/conferences/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/conferences/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/conferences/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/conferences/list-conference-tokens.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/conferences/list-streams.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/conferences/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/conferences/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/room-recordings/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/room-recordings/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/room-recordings/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/room-recordings/list-events.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/room-recordings/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/room-sessions/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/room-sessions/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/room-sessions/list-events.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/room-sessions/list-members.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/room-sessions/list-recordings.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/room-sessions/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/room-tokens/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/room-tokens/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/rooms/create-stream.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/rooms/create.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/rooms/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/rooms/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/rooms/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/rooms/list-streams.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/rooms/list.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/rooms/update.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/streams/delete.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/streams/get.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/streams/index.mdx create mode 100644 fern/products/sdks/pages/reference/php/rest/video/streams/update.mdx delete mode 100644 fern/products/sdks/pages/reference/python/agents/agent-base/auto-map-sip-usernames.mdx delete mode 100644 fern/products/sdks/pages/reference/python/agents/agent-base/define-tools.mdx delete mode 100644 fern/products/sdks/pages/reference/python/agents/agent-base/enable-debug-routes.mdx delete mode 100644 fern/products/sdks/pages/reference/python/agents/agent-base/on-function-call.mdx delete mode 100644 fern/products/sdks/pages/reference/python/agents/agent-base/on-swml-request.mdx diff --git a/fern/products/sdks/pages/guides/build-ai-agents/adding-skills.mdx b/fern/products/sdks/pages/guides/build-ai-agents/adding-skills.mdx index e2a80b2aa..3d7c110d6 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/adding-skills.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/adding-skills.mdx @@ -21,12 +21,12 @@ Add a skill with no configuration: | Java | `agent.addSkill("datetime", Map.of())` | | Perl | `$agent->add_skill('datetime')` | | C++ | `agent.add_skill("datetime")` | -| PHP | `$agent->addSkill('datetime')` | | C# | `agent.AddSkill("datetime")` | */} +| PHP | `$agent->addSkill('datetime')` | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -51,12 +51,12 @@ Pass parameters as a dictionary (or map/hash depending on language): | Java | `agent.addSkill("web_search", Map.of("api_key", "KEY", "num_results", 5))` | | Perl | `$agent->add_skill('web_search', { api_key => 'KEY', num_results => 5 })` | | C++ | `agent.add_skill("web_search", {{"api_key", "KEY"}, {"num_results", "5"}})` | -| PHP | `$agent->addSkill('web_search', ['api_key' => 'KEY', 'num_results' => 5])` | | C# | `agent.AddSkill("web_search", new Dictionary { ["api_key"] = "KEY", ["num_results"] = 5 })` | */} +| PHP | `$agent->addSkill('web_search', ['api_key' => 'KEY', 'num_results' => 5])` | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -85,12 +85,12 @@ class MyAgent(AgentBase): | Java | `agent.addSkill("datetime", Map.of()).addSkill("math", Map.of())` | | Perl | `$agent->add_skill('datetime')->add_skill('math')->add_skill('joke')` | | C++ | `agent.add_skill("datetime").add_skill("math").add_skill("joke")` | -| PHP | `$agent->addSkill('datetime')->addSkill('math')->addSkill('joke')` | | C# | `agent.AddSkill("datetime").AddSkill("math").AddSkill("joke")` | */} +| PHP | `$agent->addSkill('datetime')->addSkill('math')->addSkill('joke')` | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -109,7 +109,7 @@ class MyAgent(AgentBase): Add as many skills as needed: ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class AssistantAgent(AgentBase): def __init__(self): @@ -170,12 +170,12 @@ Some skills support multiple instances. Give each instance a unique `tool_name`: | Java | `agent.addSkill("web_search", Map.of("tool_name", "search_news", ...))` | | Perl | `$agent->add_skill('web_search', { tool_name => 'search_news', ... })` | | C++ | `agent.add_skill("web_search", {{"tool_name", "search_news"}, ...})` | -| PHP | `$agent->addSkill('web_search', ['tool_name' => 'search_news', ...])` | | C# | `agent.AddSkill("web_search", new Dictionary { ["tool_name"] = "search_news", ... })` | */} +| PHP | `$agent->addSkill('web_search', ['tool_name' => 'search_news', ...])` | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MultiSearchAgent(AgentBase): def __init__(self): @@ -261,7 +261,7 @@ self.add_skill("web_search", { ```python #!/usr/bin/env python3 ## full_featured_agent.py - Agent with multiple configured skills -from signalwire import AgentBase +from signalwire_agents import AgentBase class FullFeaturedAgent(AgentBase): def __init__(self): @@ -336,7 +336,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::AgentBase.new(name: 'full-featured') agent.add_language('English', 'en-US', 'rime.spore') @@ -419,26 +419,6 @@ int main() { } ``` - -```php -use SignalWire\Agent\AgentBase; - -$agent = new AgentBase(name: 'full-featured'); -$agent->addLanguage('English', 'en-US', 'rime.spore'); - -// Simple skills (no config needed) -$agent->addSkill('datetime'); -$agent->addSkill('math'); - -$agent->promptAddSection('Role', 'You are a versatile assistant named Alex.'); -$agent->promptAddSection('Capabilities', [ - 'body' => 'You can help with:', - 'bullets' => ['Current date and time', 'Math calculations'], -]); - -$agent->run(); -``` - ```csharp using SignalWire.Agent; @@ -462,6 +442,26 @@ agent.Run(); ``` */} + +```php +use SignalWire\Agent\AgentBase; + +$agent = new AgentBase(name: 'full-featured'); +$agent->addLanguage('English', 'en-US', 'rime.spore'); + +// Simple skills (no config needed) +$agent->addSkill('datetime'); +$agent->addSkill('math'); + +$agent->promptAddSection('Role', 'You are a versatile assistant named Alex.'); +$agent->promptAddSection('Capabilities', [ + 'body' => 'You can help with:', + 'bullets' => ['Current date and time', 'Math calculations'], +]); + +$agent->run(); +``` + Skills like `web_search` and `joke` require additional configuration or API keys. See the [Built-in Skills][built-in-skills] section for details on each skill's requirements. diff --git a/fern/products/sdks/pages/guides/build-ai-agents/agent-base.mdx b/fern/products/sdks/pages/guides/build-ai-agents/agent-base.mdx index 4ac9bb0b7..1e1b67984 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/agent-base.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/agent-base.mdx @@ -48,7 +48,7 @@ Here's what a production agent looks like across all supported languages: ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class CustomerSupportAgent(AgentBase): """Production customer support agent.""" @@ -119,7 +119,7 @@ class CustomerSupportAgent(AgentBase): def check_order(self, args, raw_data): order_number = args.get("order_number") - return FunctionResult( + return SwaigFunctionResult( f"Order {order_number}: Shipped on Monday, arriving Thursday" ) @@ -131,7 +131,7 @@ if __name__ == "__main__": {/* ```typescript -import { AgentBase, FunctionResult } from 'signalwire-agents'; +import { AgentBase, SwaigFunctionResult } from 'signalwire-agents'; const agent = new AgentBase({ name: "customer-support", @@ -143,7 +143,7 @@ agent.setParams({ end_of_speech_timeout: 500, attention_timeout: 15000, inactivi agent.promptAddSection('Role', 'You are Alex, a friendly customer support agent for Acme Inc.'); agent.promptAddSection('Guidelines', { body: 'Follow these guidelines:', bullets: ['Be helpful and professional', 'Ask clarifying questions when needed', 'Keep responses concise for voice', 'Offer to transfer if you cannot help'] }); agent.addHints(['Acme', 'account number', 'order status', 'refund', 'billing', 'representative']); -agent.defineTool({ name: 'check_order', description: 'Look up an order by order number', parameters: { type: 'object', properties: { order_number: { type: 'string', description: 'The order number to look up' } }, required: ['order_number'] }, handler: async (args) => new FunctionResult(`Order ${args.order_number}: Shipped on Monday, arriving Thursday`) }); +agent.defineTool({ name: 'check_order', description: 'Look up an order by order number', parameters: { type: 'object', properties: { order_number: { type: 'string', description: 'The order number to look up' } }, required: ['order_number'] }, handler: async (args) => new SwaigFunctionResult(`Order ${args.order_number}: Shipped on Monday, arriving Thursday`) }); agent.addSkill('datetime'); agent.setPostPrompt('Summarize: issue type, resolution, customer satisfaction'); agent.run({ host: '0.0.0.0', port: 3000 }); @@ -177,7 +177,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' class CustomerSupportAgent < AgentBase def initialize super(name: "customer-support", route: "/support") @@ -253,23 +253,6 @@ int main() { } ``` - -```php -addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); -$agent->setParams(['end_of_speech_timeout' => 500, 'attention_timeout' => 15000, 'inactivity_timeout' => 30000]); -$agent->promptAddSection('Role', 'You are Alex, a friendly customer support agent for Acme Inc.'); -$agent->promptAddSection('Guidelines', body: 'Follow these guidelines:', bullets: ['Be helpful and professional', 'Ask clarifying questions when needed', 'Keep responses concise for voice', 'Offer to transfer if you cannot help']); -$agent->addHints('Acme', 'account number', 'order status', 'refund', 'billing', 'representative'); -$agent->defineTool('check_order', 'Look up an order by order number', ['type' => 'object', 'properties' => ['order_number' => ['type' => 'string', 'description' => 'The order number to look up']], 'required' => ['order_number']], function ($args, $raw) { return new FunctionResult("Order {$args['order_number']}: Shipped on Monday, arriving Thursday"); }); -$agent->addSkill('datetime'); -$agent->setPostPrompt('Summarize: issue type, resolution, customer satisfaction'); -$agent->run('0.0.0.0', 3000); -``` - ```csharp using SignalWire.Agent; @@ -287,6 +270,23 @@ agent.Run(); ``` */} + +```php +addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); +$agent->setParams(['end_of_speech_timeout' => 500, 'attention_timeout' => 15000, 'inactivity_timeout' => 30000]); +$agent->promptAddSection('Role', 'You are Alex, a friendly customer support agent for Acme Inc.'); +$agent->promptAddSection('Guidelines', body: 'Follow these guidelines:', bullets: ['Be helpful and professional', 'Ask clarifying questions when needed', 'Keep responses concise for voice', 'Offer to transfer if you cannot help']); +$agent->addHints('Acme', 'account number', 'order status', 'refund', 'billing', 'representative'); +$agent->defineTool('check_order', 'Look up an order by order number', ['type' => 'object', 'properties' => ['order_number' => ['type' => 'string', 'description' => 'The order number to look up']], 'required' => ['order_number']], function ($args, $raw) { return new SwaigFunctionResult("Order {$args['order_number']}: Shipped on Monday, arriving Thursday"); }); +$agent->addSkill('datetime'); +$agent->setPostPrompt('Summarize: issue type, resolution, customer satisfaction'); +$agent->run('0.0.0.0', 3000); +``` + ## Chapter Contents @@ -331,12 +331,12 @@ Quick agents for simple use cases: | Java | `AgentBase agent = AgentBase.builder().name("simple-agent").build()` | | Perl | `my $agent = AgentBase->new(name => "simple-agent")` | | C++ | `agent::AgentBase agent("simple-agent")` | -| PHP | `$agent = new AgentBase(name: 'simple-agent')` | | C# | `var agent = new AgentBase(new AgentOptions { Name = "simple-agent" })` | */} +| PHP | `$agent = new AgentBase(name: 'simple-agent')` | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase agent = AgentBase(name="simple-agent") agent.add_language("English", "en-US", "rime.spore") @@ -349,7 +349,7 @@ agent.run() Multiple agents on one server: ```python -from signalwire import AgentServer +from signalwire_agents import AgentServer server = AgentServer() server.register(SupportAgent(), "/support") @@ -393,14 +393,14 @@ The constructor accepts the agent name plus optional configuration: | Java | `AgentBase.builder().name("my-agent").route("/").port(3000).build()` | | Perl | `AgentBase->new(name => "my-agent", route => "/", port => 3000)` | | C++ | `agent::AgentBase agent("my-agent"); agent.set_route("/"); agent.set_port(3000);` | -| PHP | `new AgentBase(name: 'my-agent', route: '/', port: 3000)` | | C# | `new AgentBase(new AgentOptions { Name = "my-agent", Route = "/", Port = 3000 })` | */} +| PHP | `new AgentBase(name: 'my-agent', route: '/', port: 3000)` | Full Python constructor with all options: ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase agent = AgentBase( # Required @@ -459,7 +459,7 @@ agent = AgentBase( ### Method 1: Class-Based (Recommended) ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class MyAgent(AgentBase): def __init__(self): @@ -472,7 +472,7 @@ class MyAgent(AgentBase): self.define_tool(name="greet", description="Greet the user", parameters={}, handler=self.greet) def greet(self, args, raw_data): - return FunctionResult("Hello! How can I help you today?") + return SwaigFunctionResult("Hello! How can I help you today?") if __name__ == "__main__": agent = MyAgent() @@ -482,7 +482,7 @@ if __name__ == "__main__": ### Method 2: Instance-Based ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase agent = AgentBase(name="quick-agent") agent.add_language("English", "en-US", "rime.spore") @@ -493,7 +493,7 @@ agent.run() ### Method 3: Declarative (PROMPT_SECTIONS) ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class DeclarativeAgent(AgentBase): PROMPT_SECTIONS = { @@ -531,12 +531,12 @@ class DeclarativeAgent(AgentBase): | Post-prompt | `set_post_prompt(text)` | {/* -| Method | Ruby | Java | Perl | C++ | PHP | C# | |--------|------|------|------|-----|-----|-----| | Add language | `add_language(name:, code:, voice:)` | `addLanguage(name, code, voice)` | `$a->add_language(...)` | `add_language({...})` | `$a->addLanguage(name:, code:, voice:)` | `agent.AddLanguage(name, code, voice)` | | Add prompt | `prompt_add_section(title, body, bullets:)` | `promptAddSection(title, body, List.of(...))` | `$a->prompt_add_section(...)` | `prompt_add_section(title, body, {...})` | `$a->promptAddSection(title, body, bullets:)` | `agent.PromptAddSection(title, body, bullets)` | | Set params | `set_params(hash)` | `setParams(Map.of(...))` | `$a->set_params({...})` | `set_params({...})` | `$a->setParams([...])` | `agent.SetParams(new Dictionary{...})` | */} +| Method | Ruby | Java | Perl | C++ | PHP | C# | ```python # Voice and Language @@ -622,7 +622,7 @@ AgentBase respects these environment variables: Run multiple agents on one server: ```python -from signalwire import AgentServer +from signalwire_agents import AgentServer class SupportAgent(AgentBase): def __init__(self): @@ -674,5 +674,5 @@ class WellOrganizedAgent(AgentBase): self.add_skill("datetime") def get_help(self, args, raw_data): - return FunctionResult("I can help you with...") + return SwaigFunctionResult("I can help you with...") ``` diff --git a/fern/products/sdks/pages/guides/build-ai-agents/ai-parameters.mdx b/fern/products/sdks/pages/guides/build-ai-agents/ai-parameters.mdx index 01ef46f8f..b6525c45e 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/ai-parameters.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/ai-parameters.mdx @@ -28,12 +28,12 @@ The `set_params` method accepts a dictionary/map/object of parameter names and v | Java | `agent.setParams(Map.of("end_of_speech_timeout", 600, "temperature", 0.5))` | | Perl | `$agent->set_params({ end_of_speech_timeout => 600, temperature => 0.5 })` | | C++ | `agent.set_params({{"end_of_speech_timeout", 600}, {"temperature", 0.5}})` | -| PHP | `$agent->setParams(['end_of_speech_timeout' => 600, 'temperature' => 0.5])` | | C# | `agent.SetParams(new Dictionary { ["end_of_speech_timeout"] = 600, ["temperature"] = 0.5 })` | */} +| PHP | `$agent->setParams(['end_of_speech_timeout' => 600, 'temperature' => 0.5])` | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -187,7 +187,7 @@ self.set_params({ ```python #!/usr/bin/env python3 ## configured_agent.py - Agent with AI parameters configured -from signalwire import AgentBase +from signalwire_agents import AgentBase class ConfiguredAgent(AgentBase): def __init__(self): @@ -241,7 +241,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = AgentBase.new(name: "configured-agent") agent.add_language(name: 'English', code: 'en-US', voice: 'rime.spore') agent.set_params({ end_of_speech_timeout: 600, attention_timeout: 15000, inactivity_timeout: 45000 }) @@ -286,17 +286,6 @@ int main() { } ``` - -```php -addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); -$agent->setParams(['end_of_speech_timeout' => 600, 'attention_timeout' => 15000, 'inactivity_timeout' => 45000]); -$agent->promptAddSection('Role', 'You are a helpful customer service agent.'); -$agent->run('0.0.0.0', 3000); -``` - ```csharp using SignalWire.Agent; @@ -308,6 +297,17 @@ agent.Run(); ``` */} + +```php +addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); +$agent->setParams(['end_of_speech_timeout' => 600, 'attention_timeout' => 15000, 'inactivity_timeout' => 45000]); +$agent->promptAddSection('Role', 'You are a helpful customer service agent.'); +$agent->run('0.0.0.0', 3000); +``` + ### More Parameters diff --git a/fern/products/sdks/pages/guides/build-ai-agents/architecture.mdx b/fern/products/sdks/pages/guides/build-ai-agents/architecture.mdx index b36d5e93a..a43e31710 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/architecture.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/architecture.mdx @@ -93,9 +93,9 @@ Handles basic HTTP authentication for webhook endpoints. | Java | `AgentBase.builder().name("my-agent").authUser("user").authPassword("pass").build()` | | Perl | `AgentBase->new(name => 'my-agent')` -- credentials from env or auto-generated | | C++ | `agent.set_auth("user", "pass")` | -| PHP | `new AgentBase(name: 'my-agent')` -- credentials from env or auto-generated | | C# | `new AgentBase(new AgentOptions { Name = "my-agent" })` -- credentials from env or auto-generated | */} +| PHP | `new AgentBase(name: 'my-agent')` -- credentials from env or auto-generated | **Key methods:** @@ -153,9 +153,9 @@ Manages AI system prompts using POM (Prompt Object Model). | Java | `agent.promptAddSection("Role", "You are helpful.", List.of(...))` | | Perl | `$agent->prompt_add_section('Role', 'You are helpful.', bullets => [...])` | | C++ | `agent.prompt_add_section("Role", "You are helpful.", {...})` | -| PHP | `$agent->promptAddSection('Role', 'You are helpful.', bullets: [...])` | | C# | `agent.PromptAddSection("Role", "You are helpful.", bullets: new[] {...})` | */} +| PHP | `$agent->promptAddSection('Role', 'You are helpful.', bullets: [...])` | **Key features:** @@ -177,9 +177,9 @@ Handles registration and execution of SWAIG functions. | Java | `agent.defineTool("get_balance", "...", schema, (args, raw) -> result)` | | Perl | `$agent->define_tool(name => 'get_balance', description => '...', parameters => {...}, handler => sub {...})` | | C++ | `agent.define_tool("get_balance", "...", schema, [](const json& args, const json& raw) { ... })` | -| PHP | `$agent->defineTool('get_balance', '...', $schema, function(array $args, array $rawData): FunctionResult { ... })` | | C# | `agent.DefineTool(name: "get_balance", description: "...", parameters: schema, handler: (args, raw) => ...)` | */} +| PHP | `$agent->defineTool('get_balance', '...', $schema, function(array $args, array $rawData): FunctionResult { ... })` | **Key features:** @@ -201,9 +201,9 @@ Loads and manages reusable skill plugins. | Java | `agent.addSkill("datetime", Map.of())` | | Perl | `$agent->add_skill('datetime')` | | C++ | `agent.add_skill("datetime")` | -| PHP | `$agent->addSkill('datetime')` | | C# | `agent.AddSkill("datetime")` | */} +| PHP | `$agent->addSkill('datetime')` | **Key features:** @@ -225,9 +225,9 @@ Configures the AI's voice, language, and behavior parameters. | Java | `agent.addLanguage("English", "en-US", "rime.spore")` | | Perl | `$agent->add_language(name => 'English', code => 'en-US', voice => 'rime.spore')` | | C++ | `agent.add_language({"English", "en-US", "rime.spore"})` | -| PHP | `$agent->addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore')` | | C# | `agent.AddLanguage(name: "English", code: "en-US", voice: "rime.spore")` | */} +| PHP | `$agent->addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore')` | **Key features:** @@ -319,7 +319,7 @@ When you create an agent, you get all functionality automatically: ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class CustomerServiceAgent(AgentBase): def __init__(self): @@ -337,7 +337,7 @@ class CustomerServiceAgent(AgentBase): def lookup_order(self, args, raw_data): order_id = args.get("order_id") - return FunctionResult(f"Order {order_id}: Shipped, arrives tomorrow") + return SwaigFunctionResult(f"Order {order_id}: Shipped, arrives tomorrow") if __name__ == "__main__": agent = CustomerServiceAgent() @@ -347,7 +347,7 @@ if __name__ == "__main__": {/* ```typescript -import { AgentBase, FunctionResult } from 'signalwire-agents'; +import { AgentBase, SwaigFunctionResult } from 'signalwire-agents'; const agent = new AgentBase({ name: 'customer-service' }); agent.addLanguage({ name: 'English', code: 'en-US', voice: 'rime.spore' }); @@ -359,7 +359,7 @@ agent.defineTool({ description: 'Look up an order by ID', parameters: { order_id: { type: 'string', description: 'Order ID' } }, handler: (args) => { - const result = new FunctionResult(`Order ${args.order_id}: Shipped, arrives tomorrow`); + const result = new SwaigFunctionResult(`Order ${args.order_id}: Shipped, arrives tomorrow`); return result; }, }); @@ -400,7 +400,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::AgentBase.new(name: 'customer-service') agent.add_language(name: 'English', code: 'en-US', voice: 'rime.spore') @@ -494,30 +494,6 @@ int main() { } ``` - -```php -addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); -$agent->setParams(['end_of_speech_timeout' => 500]); -$agent->promptAddSection('Role', 'You are a helpful agent.'); - -$agent->defineTool('lookup_order', 'Look up an order by ID', - ['type' => 'object', 'properties' => [ - 'order_id' => ['type' => 'string', 'description' => 'Order ID'], - ]], - function (array $args, array $rawData): FunctionResult { - return new FunctionResult("Order {$args['order_id']}: Shipped, arrives tomorrow"); - } -); - -$agent->addSkill('datetime'); -$agent->run(); -``` - ```csharp using SignalWire.Agent; @@ -552,6 +528,30 @@ agent.Run(); ``` */} + +```php +addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); +$agent->setParams(['end_of_speech_timeout' => 500]); +$agent->promptAddSection('Role', 'You are a helpful agent.'); + +$agent->defineTool('lookup_order', 'Look up an order by ID', + ['type' => 'object', 'properties' => [ + 'order_id' => ['type' => 'string', 'description' => 'Order ID'], + ]], + function (array $args, array $rawData): FunctionResult { + return new FunctionResult("Order {$args['order_id']}: Shipped, arrives tomorrow"); + } +); + +$agent->addSkill('datetime'); +$agent->run(); +``` + ## Benefits of This Architecture diff --git a/fern/products/sdks/pages/guides/build-ai-agents/builtin-skills.mdx b/fern/products/sdks/pages/guides/build-ai-agents/builtin-skills.mdx index e96f4c353..687b2a5e6 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/builtin-skills.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/builtin-skills.mdx @@ -71,11 +71,11 @@ Get current date and time information with timezone support. This is one of the | Java | `agent.addSkill("datetime", Map.of("default_timezone", "America/New_York"))` | | Perl | `$agent->add_skill('datetime', { default_timezone => 'America/New_York' })` | | C++ | `agent.add_skill("datetime", {{"default_timezone", "America/New_York"}})` | -| PHP | `$agent->addSkill('datetime', ['default_timezone' => 'America/New_York'])` | */} +| PHP | `$agent->addSkill('datetime', ['default_timezone' => 'America/New_York'])` | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class TimeAgent(AgentBase): def __init__(self): @@ -130,7 +130,7 @@ Perform mathematical calculations safely. The skill uses a secure expression eva - Can't solve equations or do symbolic math ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class CalculatorAgent(AgentBase): def __init__(self): @@ -180,7 +180,7 @@ Search the web using Google Custom Search API. Results are filtered for quality **Multi-instance support:** Yes - add multiple instances for different search engines (news, docs, etc.) ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class SearchAgent(AgentBase): def __init__(self): @@ -218,7 +218,7 @@ Search Wikipedia for information. A free, no-API-key alternative to web search f | `tool_name` | string | Custom function name | "search_wikipedia" | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class WikiAgent(AgentBase): def __init__(self): @@ -260,7 +260,7 @@ Get current weather information for locations worldwide. Commonly used for small | `tool_description` | string | Custom description | "Get weather" | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class WeatherAgent(AgentBase): def __init__(self): @@ -295,7 +295,7 @@ Tell jokes to lighten the mood or entertain callers. Uses a curated joke databas | `tool_name` | string | Custom function name | "tell_joke" | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class FunAgent(AgentBase): def __init__(self): @@ -334,7 +334,7 @@ Play audio files in the background during calls. Audio plays while conversation **Supported formats:** MP3, WAV, OGG ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MusicAgent(AgentBase): def __init__(self): @@ -359,7 +359,7 @@ Transfer calls to another SWML endpoint. **Requirements:** None ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class TransferAgent(AgentBase): def __init__(self): @@ -383,7 +383,7 @@ Search SignalWire DataSphere documents. **Requirements:** DataSphere API credentials ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class KnowledgeAgent(AgentBase): def __init__(self): @@ -408,7 +408,7 @@ Local vector search using .swsearch index files. **Requirements:** Search extras installed (`pip install "signalwire[search]"`) ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class LocalSearchAgent(AgentBase): def __init__(self): @@ -455,7 +455,7 @@ Connect to MCP (Model Context Protocol) servers via the MCP Gateway service. Thi 4. Session automatically closes when call ends ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MCPAgent(AgentBase): def __init__(self): @@ -498,7 +498,7 @@ Validate addresses and compute driving routes using Google Maps. Supports geocod | `route_tool_name` | string | Custom name for route computation function | "compute_route" | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class DeliveryAgent(AgentBase): def __init__(self): @@ -536,7 +536,7 @@ Gather answers to a configurable list of questions. This is the skill version of **Multi-instance support:** Yes - use the `prefix` parameter to run multiple question sets on a single agent. With `prefix="intake"`, tools become `intake_start_questions` and `intake_submit_answer`, and state is stored under `skill:intake` in global_data. ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MultiFormAgent(AgentBase): def __init__(self): @@ -578,7 +578,7 @@ Load Claude Code-style SKILL.md files as agent tools. Each SKILL.md file in the | `tool_prefix` | string | Prefix for generated function names | "claude_" | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class ClaudeSkillsAgent(AgentBase): def __init__(self): diff --git a/fern/products/sdks/pages/guides/build-ai-agents/call-flow.mdx b/fern/products/sdks/pages/guides/build-ai-agents/call-flow.mdx index 85457ed22..dd1c014ee 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/call-flow.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/call-flow.mdx @@ -41,9 +41,9 @@ The verb insertion methods are available in all languages: | Java | `addPreAnswerVerb(verb, params)` | `addPostAnswerVerb(verb, params)` | `addPostAiVerb(verb, params)` | | Perl | `$a->add_pre_answer_verb(verb, params)` | `$a->add_post_answer_verb(verb, params)` | `$a->add_post_ai_verb(verb, params)` | | C++ | `add_pre_answer_verb(verb, params)` | `add_post_answer_verb(verb, params)` | `add_post_ai_verb(verb, params)` | -| PHP | `$a->addPreAnswerVerb(verb, params)` | `$a->addPostAnswerVerb(verb, params)` | `$a->addPostAiVerb(verb, params)` | | C# | `agent.AddPreAnswerVerb(verb, params)` | `agent.AddPostAnswerVerb(verb, params)` | `agent.AddPostAiVerb(verb, params)` | */} +| PHP | `$a->addPreAnswerVerb(verb, params)` | `$a->addPostAnswerVerb(verb, params)` | `$a->addPostAiVerb(verb, params)` | ### Pre-Answer Verbs @@ -56,7 +56,7 @@ Pre-answer verbs run while the call is still ringing. Use them for: ```python #!/usr/bin/env python3 -from signalwire import AgentBase +from signalwire_agents import AgentBase class RingbackAgent(AgentBase): @@ -108,7 +108,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = AgentBase.new(name: "ringback", port: 3000) agent.add_pre_answer_verb('play', { urls: ['ring:us'], auto_answer: false }) agent.add_language(name: 'English', code: 'en-US', voice: 'rime.spore') @@ -152,17 +152,6 @@ int main() { } ``` - -```php -addPreAnswerVerb('play', ['urls' => ['ring:us'], 'auto_answer' => false]); -$agent->addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); -$agent->promptAddSection('Role', 'You are a helpful assistant.'); -$agent->run('0.0.0.0', 3000); -``` - ```csharp using SignalWire.Agent; @@ -174,6 +163,17 @@ agent.Run(); ``` */} + +```php +addPreAnswerVerb('play', ['urls' => ['ring:us'], 'auto_answer' => false]); +$agent->addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); +$agent->promptAddSection('Role', 'You are a helpful assistant.'); +$agent->run('0.0.0.0', 3000); +``` + **Generated SWML:** @@ -227,7 +227,7 @@ Post-answer verbs run after the call is connected but before the AI speaks: ```python #!/usr/bin/env python3 -from signalwire import AgentBase +from signalwire_agents import AgentBase class WelcomeAgent(AgentBase): @@ -287,7 +287,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = AgentBase.new(name: "welcome", port: 3000) agent.add_post_answer_verb('play', { url: 'say:Thank you for calling Acme Corporation. ' \ 'Your call may be recorded for quality assurance.' }) agent.add_post_answer_verb('sleep', { time: 500 }) @@ -335,18 +335,6 @@ int main() { } ``` - -```php -addPostAnswerVerb('play', ['url' => 'say:Thank you for calling Acme Corporation. ' . 'Your call may be recorded for quality assurance.']); -$agent->addPostAnswerVerb('sleep', ['time' => 500]); -$agent->addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); -$agent->promptAddSection('Role', 'You are a customer service representative. ' . 'The caller has just heard the welcome message.'); -$agent->run('0.0.0.0', 3000); -``` - ```csharp using SignalWire.Agent; @@ -359,6 +347,18 @@ agent.Run(); ``` */} + +```php +addPostAnswerVerb('play', ['url' => 'say:Thank you for calling Acme Corporation. ' . 'Your call may be recorded for quality assurance.']); +$agent->addPostAnswerVerb('sleep', ['time' => 500]); +$agent->addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); +$agent->promptAddSection('Role', 'You are a customer service representative. ' . 'The caller has just heard the welcome message.'); +$agent->run('0.0.0.0', 3000); +``` + **Generated SWML:** @@ -391,7 +391,7 @@ Post-AI verbs run after the AI conversation ends: ```python #!/usr/bin/env python3 -from signalwire import AgentBase +from signalwire_agents import AgentBase class SurveyAgent(AgentBase): @@ -434,7 +434,7 @@ Here's an agent with all three insertion points: ```python #!/usr/bin/env python3 -from signalwire import AgentBase +from signalwire_agents import AgentBase class CallFlowAgent(AgentBase): @@ -516,7 +516,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = AgentBase.new(name: "call-flow", port: 3000) agent.add_pre_answer_verb('play', { urls: ['ring:us'], auto_answer: false }) agent.add_post_answer_verb('play', { url: 'say:Welcome to Acme Corporation.' }) @@ -580,22 +580,6 @@ int main() { } ``` - -```php -addPreAnswerVerb('play', ['urls' => ['ring:us'], 'auto_answer' => false]); -$agent->addPostAnswerVerb('play', ['url' => 'say:Welcome to Acme Corporation.']); -$agent->addPostAnswerVerb('play', ['url' => 'say:This call may be recorded for quality assurance.']); -$agent->addPostAnswerVerb('sleep', ['time' => 500]); -$agent->addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); -$agent->promptAddSection('Role', 'You are a friendly customer service representative. ' . 'The caller has just heard the welcome message.'); -$agent->setParams(['end_of_speech_timeout' => 1000, 'attention_timeout' => 10000]); -$agent->addPostAiVerb('hangup', []); -$agent->run('0.0.0.0', 3000); -``` - ```csharp using SignalWire.Agent; @@ -612,6 +596,22 @@ agent.Run(); ``` */} + +```php +addPreAnswerVerb('play', ['urls' => ['ring:us'], 'auto_answer' => false]); +$agent->addPostAnswerVerb('play', ['url' => 'say:Welcome to Acme Corporation.']); +$agent->addPostAnswerVerb('play', ['url' => 'say:This call may be recorded for quality assurance.']); +$agent->addPostAnswerVerb('sleep', ['time' => 500]); +$agent->addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); +$agent->promptAddSection('Role', 'You are a friendly customer service representative. ' . 'The caller has just heard the welcome message.'); +$agent->setParams(['end_of_speech_timeout' => 1000, 'attention_timeout' => 10000]); +$agent->addPostAiVerb('hangup', []); +$agent->run('0.0.0.0', 3000); +``` + **Generated SWML:** diff --git a/fern/products/sdks/pages/guides/build-ai-agents/call-recording.mdx b/fern/products/sdks/pages/guides/build-ai-agents/call-recording.mdx index a63993dfc..514d1ee13 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/call-recording.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/call-recording.mdx @@ -1,6 +1,6 @@ --- title: "Call Recording" -description: Record calls using record_call() and stop_record_call() methods on FunctionResult with support for stereo/mono, multiple formats, and webhook notifications. +description: Record calls using record_call() and stop_record_call() methods on SwaigFunctionResult with support for stereo/mono, multiple formats, and webhook notifications. slug: /guides/call-recording max-toc-depth: 3 --- @@ -48,14 +48,14 @@ Recording methods across all languages: | Java | `result.recordCall("main", true, "wav")` | `result.stopRecordCall("main")` | | Perl | `$result->record_call(control_id => 'main', stereo => 1, format => 'wav')` | `$result->stop_record_call(control_id => 'main')` | | C++ | `result.record_call("main", true, "wav")` | `result.stop_record_call("main")` | -| PHP | `$agent->recordCall(format: 'wav', stereo: true)` | `$result->stopRecordCall(controlId: 'main')` | */} +| PHP | `$agent->recordCall(format: 'wav', stereo: true)` | `$result->stopRecordCall(controlId: 'main')` | ### Basic Recording ```python -from signalwire import AgentBase -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.function_result import SwaigFunctionResult class RecordingAgent(AgentBase): def __init__(self): @@ -77,7 +77,7 @@ class RecordingAgent(AgentBase): def start_recording(self, args, raw_data): return ( - FunctionResult("Recording has started.") + SwaigFunctionResult("Recording has started.") .record_call( control_id="main_recording", stereo=True, @@ -124,7 +124,7 @@ Records caller and agent on separate channels (left and right): ```python def start_stereo_recording(self, args, raw_data): return ( - FunctionResult("Recording in stereo mode") + SwaigFunctionResult("Recording in stereo mode") .record_call( control_id="stereo_rec", stereo=True, # Caller on left, agent on right @@ -154,7 +154,7 @@ Records both parties mixed into a single channel: ```python def start_mono_recording(self, args, raw_data): return ( - FunctionResult("Recording in mono mode") + SwaigFunctionResult("Recording in mono mode") .record_call( control_id="mono_rec", stereo=False, # Mixed audio (default) @@ -176,21 +176,21 @@ def start_mono_recording(self, args, raw_data): ## Record only what the AI/agent speaks def record_agent_only(self, args, raw_data): return ( - FunctionResult("Recording agent audio") + SwaigFunctionResult("Recording agent audio") .record_call(direction="speak") ) ## Record only what the caller says def record_caller_only(self, args, raw_data): return ( - FunctionResult("Recording caller audio") + SwaigFunctionResult("Recording caller audio") .record_call(direction="listen") ) ## Record both sides (default) def record_both(self, args, raw_data): return ( - FunctionResult("Recording full conversation") + SwaigFunctionResult("Recording full conversation") .record_call(direction="both") ) ``` @@ -202,7 +202,7 @@ Receive notifications when recording completes: ```python def start_recording_with_callback(self, args, raw_data): return ( - FunctionResult("Recording started") + SwaigFunctionResult("Recording started") .record_call( control_id="webhook_rec", status_url="https://example.com/recording-complete" @@ -219,7 +219,7 @@ Configure automatic stop conditions: ```python def start_auto_stop_recording(self, args, raw_data): return ( - FunctionResult("Recording with auto-stop") + SwaigFunctionResult("Recording with auto-stop") .record_call( max_length=300.0, # Stop after 5 minutes end_silence_timeout=5.0, # Stop after 5 seconds of silence @@ -233,8 +233,8 @@ def start_auto_stop_recording(self, args, raw_data): Stop a recording by control_id: ```python -from signalwire import AgentBase -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.function_result import SwaigFunctionResult class ControlledRecordingAgent(AgentBase): def __init__(self): @@ -265,13 +265,13 @@ class ControlledRecordingAgent(AgentBase): def start_recording(self, args, raw_data): return ( - FunctionResult("Recording has started") + SwaigFunctionResult("Recording has started") .record_call(control_id="main") ) def stop_recording(self, args, raw_data): return ( - FunctionResult("Recording has stopped") + SwaigFunctionResult("Recording has stopped") .stop_record_call(control_id="main") ) @@ -287,7 +287,7 @@ Alert the caller that recording is starting: ```python def start_recording_with_beep(self, args, raw_data): return ( - FunctionResult("This call will be recorded") + SwaigFunctionResult("This call will be recorded") .record_call( beep=True, # Plays a beep before recording starts format="mp3" @@ -300,8 +300,8 @@ def start_recording_with_beep(self, args, raw_data): ```python #!/usr/bin/env python3 ## compliance_agent.py - Agent with recording compliance features -from signalwire import AgentBase -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.function_result import SwaigFunctionResult class ComplianceAgent(AgentBase): """Agent with full recording compliance features""" @@ -354,7 +354,7 @@ class ComplianceAgent(AgentBase): call_id = raw_data.get("call_id", "unknown") return ( - FunctionResult("Recording has begun. Thank you for your consent.") + SwaigFunctionResult("Recording has begun. Thank you for your consent.") .record_call( control_id=f"compliance_{call_id}", stereo=True, @@ -369,7 +369,7 @@ class ComplianceAgent(AgentBase): call_id = raw_data.get("call_id", "unknown") return ( - FunctionResult( + SwaigFunctionResult( "Recording paused. You may now provide sensitive information." ) .stop_record_call(control_id=f"compliance_{call_id}") @@ -380,7 +380,7 @@ class ComplianceAgent(AgentBase): call_id = raw_data.get("call_id", "unknown") return ( - FunctionResult("Recording resumed.") + SwaigFunctionResult("Recording resumed.") .record_call( control_id=f"compliance_{call_id}", stereo=True, diff --git a/fern/products/sdks/pages/guides/build-ai-agents/call-transfer.mdx b/fern/products/sdks/pages/guides/build-ai-agents/call-transfer.mdx index edd168617..f7e88bd11 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/call-transfer.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/call-transfer.mdx @@ -31,9 +31,9 @@ Transfer methods across all languages: | Java | `result.connect("+15551234567", true)` | `result.swmlTransfer("https://...", true)` | | Perl | `$result->connect('+15551234567', final => 1)` | `$result->swml_transfer(dest => 'https://...', final => 1)` | | C++ | `result.connect("+15551234567", true)` | `result.swml_transfer("https://...", true)` | -| PHP | `(new FunctionResult('Transferring...'))->connect('+15551234567')` | `$result->swmlTransfer(dest: 'https://...', final: true)` | | C# | `result.Connect("+15551234567", final: true)` | `result.SwmlTransfer("https://...", final: true)` | */} +| PHP | `(new SwaigFunctionResult('Transferring...'))->connect('+15551234567')` | `$result->swmlTransfer(dest: 'https://...', final: true)` | **Use `connect()` when:** @@ -70,8 +70,8 @@ Transfer methods across all languages: ### Basic Phone Transfer ```python -from signalwire import AgentBase -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.function_result import SwaigFunctionResult class TransferAgent(AgentBase): def __init__(self): @@ -92,7 +92,7 @@ class TransferAgent(AgentBase): def transfer_to_sales(self, args, raw_data): return ( - FunctionResult("Transferring you to sales now.") + SwaigFunctionResult("Transferring you to sales now.") .connect("+15551234567", final=True) ) @@ -112,8 +112,8 @@ if __name__ == "__main__": ### Permanent vs Temporary Transfer ```python -from signalwire import AgentBase -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.function_result import SwaigFunctionResult class SmartTransferAgent(AgentBase): def __init__(self): @@ -157,14 +157,14 @@ class SmartTransferAgent(AgentBase): def transfer_permanent(self, args, raw_data): number = args.get("number") return ( - FunctionResult(f"Transferring you now. Goodbye!") + SwaigFunctionResult(f"Transferring you now. Goodbye!") .connect(number, final=True) ) def transfer_temporary(self, args, raw_data): number = args.get("number") return ( - FunctionResult("Connecting you briefly. I'll be here when you're done.") + SwaigFunctionResult("Connecting you briefly. I'll be here when you're done.") .connect(number, final=False) ) @@ -180,7 +180,7 @@ Transfer to SIP endpoints: ```python def transfer_to_sip(self, args, raw_data): return ( - FunctionResult("Connecting to internal support") + SwaigFunctionResult("Connecting to internal support") .connect("sip:support@company.com", final=True) ) ``` @@ -190,7 +190,7 @@ def transfer_to_sip(self, args, raw_data): ```python def transfer_with_custom_callerid(self, args, raw_data): return ( - FunctionResult("Connecting you now") + SwaigFunctionResult("Connecting you now") .connect( "+15551234567", final=True, @@ -204,8 +204,8 @@ def transfer_with_custom_callerid(self, args, raw_data): Transfer to another SWML endpoint (another agent): ```python -from signalwire import AgentBase -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.function_result import SwaigFunctionResult class MultiAgentTransfer(AgentBase): def __init__(self): @@ -223,7 +223,7 @@ class MultiAgentTransfer(AgentBase): def transfer_to_billing(self, args, raw_data): return ( - FunctionResult( + SwaigFunctionResult( "I'm transferring you to our billing specialist.", post_process=True # Speak message before transfer ) @@ -249,8 +249,8 @@ if __name__ == "__main__": ```python -from signalwire import AgentBase -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.function_result import SwaigFunctionResult class ReceptionistAgent(AgentBase): """Receptionist that routes calls to departments""" @@ -297,7 +297,7 @@ class ReceptionistAgent(AgentBase): dept = args.get("department", "").lower() if dept not in self.DEPARTMENTS: - return FunctionResult( + return SwaigFunctionResult( f"I don't recognize the department '{dept}'. " "Available departments are: Sales, Support, Billing, and HR." ) @@ -306,7 +306,7 @@ class ReceptionistAgent(AgentBase): dept_name = dept.upper() if dept == "hr" else dept.capitalize() return ( - FunctionResult(f"Transferring you to {dept_name} now. Have a great day!") + SwaigFunctionResult(f"Transferring you to {dept_name} now. Have a great day!") .connect(number, final=True) ) @@ -318,7 +318,7 @@ if __name__ == "__main__": {/* ```typescript -import { AgentBase, FunctionResult } from 'signalwire-agents'; +import { AgentBase, SwaigFunctionResult } from 'signalwire-agents'; const DEPARTMENTS: Record = { sales: '+15551111111', @@ -344,9 +344,9 @@ agent.defineTool({ handler: (args) => { const dept = (args.department as string).toLowerCase(); if (!(dept in DEPARTMENTS)) { - return new FunctionResult(`I don't recognize '${dept}'.`); + return new SwaigFunctionResult(`I don't recognize '${dept}'.`); } - return new FunctionResult(`Transferring you to ${dept} now.`) + return new SwaigFunctionResult(`Transferring you to ${dept} now.`) .connect(DEPARTMENTS[dept], { final: true }); }, }); @@ -372,13 +372,13 @@ func main() { a.DefineTool("transfer_to_department", "Transfer caller to a department", agents.Params("department", "string", "Department name"), - func(args map[string]any, rawData map[string]any) *agents.FunctionResult { + func(args map[string]any, rawData map[string]any) *agents.SwaigFunctionResult { dept := args["department"].(string) number, ok := departments[dept] if !ok { - return agents.NewFunctionResult("Unknown department.") + return agents.NewSwaigFunctionResult("Unknown department.") } - return agents.NewFunctionResult("Transferring you now."). + return agents.NewSwaigFunctionResult("Transferring you now."). Connect(number, true) }) @@ -388,7 +388,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' DEPARTMENTS = { 'sales' => '+15551111111', 'support' => '+15552222222', 'billing' => '+15553333333', 'hr' => '+15554444444' } @@ -405,9 +405,9 @@ agent.define_tool( dept = args['department'].downcase number = DEPARTMENTS[dept] unless number - next FunctionResult.new("Unknown department '#{dept}'.") + next SwaigFunctionResult.new("Unknown department '#{dept}'.") end - FunctionResult.new("Transferring you to #{dept} now.") + SwaigFunctionResult.new("Transferring you to #{dept} now.") .connect(number, final: true) end @@ -417,7 +417,7 @@ agent.run ```java import com.signalwire.agents.AgentBase; -import com.signalwire.agents.FunctionResult; +import com.signalwire.agents.SwaigFunctionResult; public class ReceptionistAgent { static final Map DEPARTMENTS = Map.of( @@ -434,8 +434,8 @@ public class ReceptionistAgent { (fnArgs, rawData) -> { String dept = ((String) fnArgs.get("department")).toLowerCase(); String number = DEPARTMENTS.get(dept); - if (number == null) return new FunctionResult("Unknown department."); - return new FunctionResult("Transferring you now.") + if (number == null) return new SwaigFunctionResult("Unknown department."); + return new SwaigFunctionResult("Transferring you now.") .connect(number, true); }); @@ -463,8 +463,8 @@ $agent->define_tool( my ($args, $raw_data) = @_; my $dept = lc $args->{department}; my $number = $departments{$dept} or - return SignalWire::Agents::FunctionResult->new("Unknown department."); - return SignalWire::Agents::FunctionResult + return SignalWire::Agents::SwaigFunctionResult->new("Unknown department."); + return SignalWire::Agents::SwaigFunctionResult ->new("Transferring you now.") ->connect($number, final => 1); }, @@ -493,8 +493,8 @@ int main() { auto dept = args["department"].get(); auto it = departments.find(dept); if (it == departments.end()) - return FunctionResult("Unknown department."); - return FunctionResult("Transferring you now.") + return SwaigFunctionResult("Unknown department."); + return SwaigFunctionResult("Transferring you now.") .connect(it->second, true); }); @@ -502,41 +502,6 @@ int main() { } ``` - -```php - '+15551111111', - 'support' => '+15552222222', - 'billing' => '+15553333333', - 'hr' => '+15554444444', -]; - -$agent = new AgentBase(name: 'receptionist-agent'); -$agent->addLanguage('English', 'en-US', 'rime.spore'); -$agent->promptAddSection('Role', 'You are the company receptionist.'); - -$agent->defineTool('transfer_to_department', 'Transfer caller to a specific department', [ - 'type' => 'object', - 'properties' => [ - 'department' => ['type' => 'string', 'enum' => ['sales', 'support', 'billing', 'hr']], - ], - 'required' => ['department'], -], function ($args, $rawData) use ($departments) { - $dept = strtolower($args['department']); - if (!isset($departments[$dept])) { - return new FunctionResult("I don't recognize '{$dept}'."); - } - return (new FunctionResult("Transferring you to {$dept} now.")) - ->connect($departments[$dept]); -}); - -$agent->run(); -``` - ```csharp using SignalWire.Agent; @@ -581,6 +546,41 @@ agent.Run(); ``` */} + +```php + '+15551111111', + 'support' => '+15552222222', + 'billing' => '+15553333333', + 'hr' => '+15554444444', +]; + +$agent = new AgentBase(name: 'receptionist-agent'); +$agent->addLanguage('English', 'en-US', 'rime.spore'); +$agent->promptAddSection('Role', 'You are the company receptionist.'); + +$agent->defineTool('transfer_to_department', 'Transfer caller to a specific department', [ + 'type' => 'object', + 'properties' => [ + 'department' => ['type' => 'string', 'enum' => ['sales', 'support', 'billing', 'hr']], + ], + 'required' => ['department'], +], function ($args, $rawData) use ($departments) { + $dept = strtolower($args['department']); + if (!isset($departments[$dept])) { + return new SwaigFunctionResult("I don't recognize '{$dept}'."); + } + return (new SwaigFunctionResult("Transferring you to {$dept} now.")) + ->connect($departments[$dept]); +}); + +$agent->run(); +``` + ### Sending SMS During Transfer @@ -591,7 +591,7 @@ def transfer_with_sms(self, args, raw_data): caller_number = raw_data.get("caller_id_number") return ( - FunctionResult("I'm transferring you and sending a confirmation text.") + SwaigFunctionResult("I'm transferring you and sending a confirmation text.") .send_sms( to_number=caller_number, from_number="+15559876543", @@ -608,7 +608,7 @@ Use `post_process=True` to have the AI speak before executing the transfer: ```python def announced_transfer(self, args, raw_data): return ( - FunctionResult( + SwaigFunctionResult( "Please hold while I transfer you to our specialist. " "This should only take a moment.", post_process=True # AI speaks this before transfer executes @@ -628,7 +628,7 @@ The caller is connected to the destination without any preparation. The destinat ```python def cold_transfer(self, args, raw_data): return ( - FunctionResult("Transferring you to support now.") + SwaigFunctionResult("Transferring you to support now.") .connect("+15551234567", final=True) ) ``` @@ -654,7 +654,7 @@ def warm_transfer_with_context(self, args, raw_data): call_summary = "Caller needs help with billing dispute" return ( - FunctionResult( + SwaigFunctionResult( "I'm transferring you to our billing specialist. " "I'll let them know about your situation.", post_process=True @@ -691,13 +691,13 @@ def transfer_to_department(self, args, raw_data): } if dept not in DEPARTMENTS: - return FunctionResult( + return SwaigFunctionResult( f"I don't have a number for '{dept}'. " "I can transfer you to Sales or Support." ) return ( - FunctionResult(f"Transferring to {dept}.") + SwaigFunctionResult(f"Transferring to {dept}.") .connect(DEPARTMENTS[dept], final=True) ) ``` @@ -709,7 +709,7 @@ For temporary transfers (`final=False`), you can handle what happens when the tr ```python def consultation_transfer(self, args, raw_data): return ( - FunctionResult( + SwaigFunctionResult( "Let me connect you with a specialist briefly." ) .connect( @@ -729,7 +729,7 @@ def escalate_to_human(self, args, raw_data): self.log.info(f"Escalating call: {reason}") return ( - FunctionResult( + SwaigFunctionResult( "I understand you'd like to speak with a person. " "Let me transfer you to one of our team members.", post_process=True @@ -754,7 +754,7 @@ def route_to_queue(self, args, raw_data): queue_number = QUEUES.get(issue_type, QUEUES["general"]) return ( - FunctionResult(f"Routing you to our {issue_type} team.") + SwaigFunctionResult(f"Routing you to our {issue_type} team.") .connect(queue_number, final=True) ) ``` @@ -772,12 +772,12 @@ def handoff_to_specialist(self, args, raw_data): } if specialty not in SPECIALIST_AGENTS: - return FunctionResult( + return SwaigFunctionResult( "I don't have a specialist for that area. Let me help you directly." ) return ( - FunctionResult( + SwaigFunctionResult( f"I'm connecting you with our {specialty} specialist.", post_process=True ) diff --git a/fern/products/sdks/pages/guides/build-ai-agents/concierge.mdx b/fern/products/sdks/pages/guides/build-ai-agents/concierge.mdx index 9e7de79f8..39e90dc7c 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/concierge.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/concierge.mdx @@ -11,7 +11,7 @@ ConciergeAgent provides venue information, answers questions about amenities and ```python -from signalwire.prefabs import ConciergeAgent +from signalwire_agents.prefabs import ConciergeAgent agent = ConciergeAgent( venue_name="Grand Hotel", @@ -67,7 +67,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::Prefabs::ConciergeAgent.new( venue_name: "Grand Hotel", @@ -142,6 +142,18 @@ int main() { } ``` + +```csharp +using SignalWire.Prefabs; + +var agent = new ConciergeAgent(new AgentOptions { Name = "concierge" }); +agent.SetVenueName("Grand Hotel"); +agent.SetAmenities(new List { "Pool", "Spa", "Restaurant" }); + +agent.Run(); +``` + +*/} ```php run(); ``` - -```csharp -using SignalWire.Prefabs; - -var agent = new ConciergeAgent(new AgentOptions { Name = "concierge" }); -agent.SetVenueName("Grand Hotel"); -agent.SetAmenities(new List { "Pool", "Spa", "Restaurant" }); - -agent.Run(); -``` - -*/} ### Amenity Format @@ -191,17 +191,17 @@ amenities = { | Language | Import | |----------|--------| -| Python | `from signalwire.prefabs import ConciergeAgent` | +| Python | `from signalwire_agents.prefabs import ConciergeAgent` | {/* | TypeScript | `import { ConciergeAgent } from 'signalwire-agents'` | | Go | `"github.com/signalwire/signalwire-agents-go/pkg/prefabs"` | -| Ruby | `require 'signalwire'` then `SignalWireAgents::Prefabs::ConciergeAgent` | +| Ruby | `require 'signalwire_agents'` then `SignalWireAgents::Prefabs::ConciergeAgent` | | Java | `import com.signalwire.agents.prefabs.ConciergeAgent` | | Perl | `use SignalWire::Agents::Prefabs::ConciergeAgent` | | C++ | `#include ` | -| PHP | `use SignalWire\Prefabs\ConciergeAgent` | | C# | `using SignalWire.Prefabs;` | */} +| PHP | `use SignalWire\Prefabs\ConciergeAgent` | ### Constructor Parameters @@ -239,7 +239,7 @@ ConciergeAgent provides these SWAIG functions automatically: ```python #!/usr/bin/env python3 ## resort_concierge.py - Hotel concierge agent -from signalwire.prefabs import ConciergeAgent +from signalwire_agents.prefabs import ConciergeAgent agent = ConciergeAgent( venue_name="The Riverside Resort", diff --git a/fern/products/sdks/pages/guides/build-ai-agents/contexts-workflows.mdx b/fern/products/sdks/pages/guides/build-ai-agents/contexts-workflows.mdx index 8c3a8506c..90270c022 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/contexts-workflows.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/contexts-workflows.mdx @@ -70,7 +70,7 @@ The AI automatically tracks which context and step the conversation is in. When ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class OrderAgent(AgentBase): def __init__(self): @@ -166,7 +166,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = AgentBase.new(name: 'order-agent') agent.add_language('English', 'en-US', 'rime.spore') @@ -271,35 +271,6 @@ int main() { } ``` - -```php -addLanguage('English', 'en-US', 'rime.spore'); -$agent->promptAddSection('Role', 'You help customers place orders.'); - -$contexts = $agent->defineContexts(); -$order = $contexts->addContext('default'); - -$order->addStep('get_item') - ->setText('Ask what item they want to order.') - ->setStepCriteria('Customer has specified an item') - ->setValidSteps(['get_quantity']); - -$order->addStep('get_quantity') - ->setText('Ask how many they want.') - ->setStepCriteria('Customer has specified a quantity') - ->setValidSteps(['confirm']); - -$order->addStep('confirm') - ->setText('Confirm the order details and thank them.') - ->setStepCriteria('Order has been confirmed'); - -$agent->run(); -``` - ```csharp using SignalWire.Agent; @@ -330,6 +301,35 @@ agent.Run(); ``` */} + +```php +addLanguage('English', 'en-US', 'rime.spore'); +$agent->promptAddSection('Role', 'You help customers place orders.'); + +$contexts = $agent->defineContexts(); +$order = $contexts->addContext('default'); + +$order->addStep('get_item') + ->setText('Ask what item they want to order.') + ->setStepCriteria('Customer has specified an item') + ->setValidSteps(['get_quantity']); + +$order->addStep('get_quantity') + ->setText('Ask how many they want.') + ->setStepCriteria('Customer has specified a quantity') + ->setValidSteps(['confirm']); + +$order->addStep('confirm') + ->setText('Confirm the order details and thank them.') + ->setStepCriteria('Order has been confirmed'); + +$agent->run(); +``` + ## Compact Step Definition @@ -377,9 +377,9 @@ Simple text prompt for the step: | Java | `step.setText("What item would you like to order?")` | | Perl | `$step->set_text('What item would you like to order?')` | | C++ | `step.set_text("What item would you like to order?")` | -| PHP | `$step->setText('What item would you like to order?')` | | C# | `step.SetText("What item would you like to order?")` | */} +| PHP | `$step->setText('What item would you like to order?')` | ### add_section() / add_bullets() @@ -395,9 +395,9 @@ POM-style structured prompts: | Java | `step.addSection("Task", "Collect customer info").addBullets("Required", List.of("Full name", "Phone"))` | | Perl | `$step->add_section('Task', 'Collect customer info')->add_bullets('Required', ['Full name', 'Phone'])` | | C++ | `step.add_section("Task", "Collect customer info").add_bullets("Required", {"Full name", "Phone"})` | -| PHP | `$step->addSection('Task', 'Collect customer info')->addBullets('Required', ['Full name', 'Phone'])` | | C# | `step.AddSection("Task", "Collect customer info").AddBullets("Required", new List { "Full name", "Phone" })` | */} +| PHP | `$step->addSection('Task', 'Collect customer info')->addBullets('Required', ['Full name', 'Phone'])` | ### set_step_criteria() @@ -413,9 +413,9 @@ Define when the step is complete: | Java | `step.setStepCriteria("Customer has provided their full name and phone number")` | | Perl | `$step->set_step_criteria('Customer has provided their full name and phone number')` | | C++ | `step.set_step_criteria("Customer has provided their full name and phone number")` | -| PHP | `$step->setStepCriteria('Customer has provided their full name and phone number')` | | C# | `step.SetStepCriteria("Customer has provided their full name and phone number")` | */} +| PHP | `$step->setStepCriteria('Customer has provided their full name and phone number')` | ### set_valid_steps() @@ -431,9 +431,9 @@ Control step navigation: | Java | `step.setValidSteps(List.of("confirm", "cancel"))` | | Perl | `$step->set_valid_steps(['confirm', 'cancel'])` | | C++ | `step.set_valid_steps({"confirm", "cancel"})` | -| PHP | `$step->setValidSteps(['confirm', 'cancel'])` | | C# | `step.SetValidSteps(new List { "confirm", "cancel" })` | */} +| PHP | `$step->setValidSteps(['confirm', 'cancel'])` | ### set_functions() @@ -449,9 +449,9 @@ Restrict available functions per step: | Java | `step.setFunctions(List.of("check_inventory", "get_price"))` | | Perl | `$step->set_functions(['check_inventory', 'get_price'])` | | C++ | `step.set_functions({"check_inventory", "get_price"})` | -| PHP | `$step->setFunctions(['check_inventory', 'get_price'])` | | C# | `step.SetFunctions(new List { "check_inventory", "get_price" })` | */} +| PHP | `$step->setFunctions(['check_inventory', 'get_price'])` | ### set_valid_contexts() @@ -467,9 +467,9 @@ Allow navigation to other contexts: | Java | `step.setValidContexts(List.of("support", "manager"))` | | Perl | `$step->set_valid_contexts(['support', 'manager'])` | | C++ | `step.set_valid_contexts({"support", "manager"})` | -| PHP | `$step->setValidContexts(['support', 'manager'])` | | C# | `step.SetValidContexts(new List { "support", "manager" })` | */} +| PHP | `$step->setValidContexts(['support', 'manager'])` | ### Step Behavior Flags @@ -540,9 +540,9 @@ Truncate conversation history when entering: | Java | `context.setIsolated(true)` | | Perl | `$context->set_isolated(1)` | | C++ | `context.set_isolated(true)` | -| PHP | `$context->setIsolated(true)` | | C# | `context.SetIsolated(true)` | */} +| PHP | `$context->setIsolated(true)` | ### set_system_prompt() @@ -558,9 +558,9 @@ New system prompt when entering context: | Java | `context.setSystemPrompt("You are now a technical support specialist.")` | | Perl | `$context->set_system_prompt('You are now a technical support specialist.')` | | C++ | `context.set_system_prompt("You are now a technical support specialist.")` | -| PHP | `$context->setSystemPrompt('You are now a technical support specialist.')` | | C# | `context.SetSystemPrompt("You are now a technical support specialist.")` | */} +| PHP | `$context->setSystemPrompt('You are now a technical support specialist.')` | ### set_user_prompt() @@ -576,9 +576,9 @@ Inject a user message when entering: | Java | `context.setUserPrompt("I need help with a technical issue.")` | | Perl | `$context->set_user_prompt('I need help with a technical issue.')` | | C++ | `context.set_user_prompt("I need help with a technical issue.")` | -| PHP | `$context->setUserPrompt('I need help with a technical issue.')` | | C# | `context.SetUserPrompt("I need help with a technical issue.")` | */} +| PHP | `$context->setUserPrompt('I need help with a technical issue.')` | ### set_consolidate() @@ -594,9 +594,9 @@ Summarize previous conversation when switching: | Java | `context.setConsolidate(true)` | | Perl | `$context->set_consolidate(1)` | | C++ | `context.set_consolidate(true)` | -| PHP | `$context->setConsolidate(true)` | | C# | `context.SetConsolidate(true)` | */} +| PHP | `$context->setConsolidate(true)` | ### set_full_reset() @@ -612,9 +612,9 @@ Completely reset conversation state: | Java | `context.setFullReset(true)` | | Perl | `$context->set_full_reset(1)` | | C++ | `context.set_full_reset(true)` | -| PHP | `$context->setFullReset(true)` | | C# | `context.SetFullReset(true)` | */} +| PHP | `$context->setFullReset(true)` | ### add_enter_filler() / add_exit_filler() @@ -635,7 +635,7 @@ context.add_exit_filler("en-US", [ ## Multi-Context Example ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MultiDepartmentAgent(AgentBase): def __init__(self): @@ -791,7 +791,7 @@ The gather info system lets you define structured question sequences within a st ### Basic Gather Info ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class IntakeAgent(AgentBase): def __init__(self): diff --git a/fern/products/sdks/pages/guides/build-ai-agents/custom-skills.mdx b/fern/products/sdks/pages/guides/build-ai-agents/custom-skills.mdx index f644486a4..4537c7c05 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/custom-skills.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/custom-skills.mdx @@ -50,8 +50,8 @@ my_custom_skill/ ## my_custom_skill/skill.py from typing import List, Dict, Any -from signalwire.skills import SkillBase -from signalwire.core.function_result import FunctionResult +from signalwire_agents.skills import SkillBase +from signalwire_agents.core.function_result import SwaigFunctionResult class GreetingSkill(SkillBase): """A skill that provides personalized greetings""" @@ -94,13 +94,13 @@ class GreetingSkill(SkillBase): else: greeting = f"Hey {name}! Great to hear from you!" - return FunctionResult(greeting) + return SwaigFunctionResult(greeting) ``` {/* ```typescript -import { SkillBase, FunctionResult, AgentBase } from 'signalwire-agents'; +import { SkillBase, SwaigFunctionResult, AgentBase } from 'signalwire-agents'; class GreetingSkill extends SkillBase { static SKILL_NAME = 'greeting'; @@ -125,12 +125,12 @@ class GreetingSkill extends SkillBase { }); } - greetHandler(args: Record, rawData: any): FunctionResult { + greetHandler(args: Record, rawData: any): SwaigFunctionResult { const name = args.name || 'friend'; const greeting = this.greetingStyle === 'formal' ? `Good day, ${name}. How may I assist you?` : `Hey ${name}! Great to hear from you!`; - return new FunctionResult(greeting); + return new SwaigFunctionResult(greeting); } } ``` @@ -170,7 +170,7 @@ func (s *GreetingSkill) RegisterTools() { }) } -func (s *GreetingSkill) greetHandler(args map[string]any, rawData map[string]any) *agent.FunctionResult { +func (s *GreetingSkill) greetHandler(args map[string]any, rawData map[string]any) *agent.SwaigFunctionResult { name, _ := args["name"].(string) if name == "" { name = "friend" } var greeting string @@ -179,13 +179,13 @@ func (s *GreetingSkill) greetHandler(args map[string]any, rawData map[string]any } else { greeting = fmt.Sprintf("Hey %s! Great to hear from you!", name) } - return agent.NewFunctionResult(greeting) + return agent.NewSwaigFunctionResult(greeting) } ``` ```ruby -require 'signalwire' +require 'signalwire_agents' class GreetingSkill < SignalWireAgents::SkillBase SKILL_NAME = 'greeting' @@ -211,7 +211,7 @@ class GreetingSkill < SignalWireAgents::SkillBase greeting = @greeting_style == 'formal' ? "Good day, #{name}. How may I assist you?" : "Hey #{name}! Great to hear from you!" - FunctionResult.new(greeting) + SwaigFunctionResult.new(greeting) end end ``` @@ -220,7 +220,7 @@ end ```java import com.signalwire.agents.skills.SkillBase; import com.signalwire.agents.AgentBase; -import com.signalwire.agents.FunctionResult; +import com.signalwire.agents.SwaigFunctionResult; import java.util.Map; public class GreetingSkill extends SkillBase { @@ -239,12 +239,12 @@ public class GreetingSkill extends SkillBase { this::greetHandler); } - private FunctionResult greetHandler(Map args, Map rawData) { + private SwaigFunctionResult greetHandler(Map args, Map rawData) { String name = (String) args.getOrDefault("name", "friend"); String greeting = greetingStyle.equals("formal") ? "Good day, " + name + ". How may I assist you?" : "Hey " + name + "! Great to hear from you!"; - return new FunctionResult(greeting); + return new SwaigFunctionResult(greeting); } } ``` @@ -275,7 +275,7 @@ sub greet_handler { my $greeting = $self->{greeting_style} eq 'formal' ? "Good day, $name. How may I assist you?" : "Hey $name! Great to hear from you!"; - return SignalWire::Agents::FunctionResult->new($greeting); + return SignalWire::Agents::SwaigFunctionResult->new($greeting); } 1; ``` @@ -298,43 +298,16 @@ public: } private: std::string greeting_style_ = "friendly"; - signalwire::agents::FunctionResult greet_handler(const nlohmann::json& args, const nlohmann::json& raw) { + signalwire::agents::SwaigFunctionResult greet_handler(const nlohmann::json& args, const nlohmann::json& raw) { std::string name = args.value("name", "friend"); std::string greeting = (greeting_style_ == "formal") ? "Good day, " + name + ". How may I assist you?" : "Hey " + name + "! Great to hear from you!"; - return signalwire::agents::FunctionResult(greeting); + return signalwire::agents::SwaigFunctionResult(greeting); } }; ``` - -```php -use SignalWire\Skills\SkillBase; -use SignalWire\Agent\FunctionResult; - -class GreetingSkill extends SkillBase { - private string $greetingStyle = 'friendly'; - - public function setup($agent): bool { - $this->greetingStyle = $this->params['style'] ?? 'friendly'; - return true; - } - public function registerTools(): void { - $this->defineTool(name: 'greet_user', description: 'Generate a personalized greeting', - parameters: ['name' => ['type' => 'string', 'description' => 'Name of the person to greet']], - handler: fn($args, $raw) => $this->greetHandler($args, $raw)); - } - private function greetHandler(array $args, array $rawData): FunctionResult { - $name = $args['name'] ?? 'friend'; - $greeting = $this->greetingStyle === 'formal' - ? "Good day, {$name}. How may I assist you?" - : "Hey {$name}! Great to hear from you!"; - return new FunctionResult($greeting); - } -} -``` - ```csharp using SignalWire.Skills; @@ -361,6 +334,33 @@ class GreetingSkill : SkillBase { ``` */} + +```php +use SignalWire\Skills\SkillBase; +use SignalWire\Agent\SwaigFunctionResult; + +class GreetingSkill extends SkillBase { + private string $greetingStyle = 'friendly'; + + public function setup($agent): bool { + $this->greetingStyle = $this->params['style'] ?? 'friendly'; + return true; + } + public function registerTools(): void { + $this->defineTool(name: 'greet_user', description: 'Generate a personalized greeting', + parameters: ['name' => ['type' => 'string', 'description' => 'Name of the person to greet']], + handler: fn($args, $raw) => $this->greetHandler($args, $raw)); + } + private function greetHandler(array $args, array $rawData): SwaigFunctionResult { + $name = $args['name'] ?? 'friend'; + $greeting = $this->greetingStyle === 'formal' + ? "Good day, {$name}. How may I assist you?" + : "Hey {$name}! Great to hear from you!"; + return new SwaigFunctionResult($greeting); + } +} +``` + ### Required Class Attributes @@ -476,7 +476,7 @@ class StatefulSkill(SkillBase): def my_handler(self, args, raw_data): state = self.get_skill_data(raw_data) count = state.get("call_count", 0) - result = FunctionResult(f"Call #{count + 1}") + result = SwaigFunctionResult(f"Call #{count + 1}") self.update_skill_data(result, {"call_count": count + 1}) return result ``` @@ -546,12 +546,12 @@ Register the skill directory and use the custom skill in your agent: | Java | `SkillRegistry.addSkillDirectory("/path/to/skills")` then `agent.addSkill("product_search", Map.of(...))` | | Perl | `$registry->add_skill_directory('/path/to/skills')` then `$agent->add_skill('product_search', {...})` | | C++ | `skill_registry.add_skill_directory("/path/to/skills")` then `agent.add_skill("product_search", {...})` | -| PHP | `SkillRegistry::addSkillDirectory('/path/to/skills')` then `$agent->addSkill('product_search', [...])` | | C# | `SkillRegistry.AddSkillDirectory("/path/to/skills")` then `agent.AddSkill("product_search", ...)` | */} +| PHP | `SkillRegistry::addSkillDirectory('/path/to/skills')` then `$agent->addSkill('product_search', [...])` | ```python -from signalwire.skills.registry import skill_registry +from signalwire_agents.skills.registry import skill_registry ## Add your skills directory skill_registry.add_skill_directory("/path/to/my_skills") @@ -591,7 +591,7 @@ swaig-test test_agent.py --exec search_products --query "test" **3. Validate skill structure:** ```python -from signalwire.skills.registry import skill_registry +from signalwire_agents.skills.registry import skill_registry skill_registry.add_skill_directory("/path/to/my_skills") available = skill_registry.list_available_skills() print(f"Available skills: {available}") @@ -624,7 +624,7 @@ skill_registry.add_skill_directory("/path/to/my_company_skills") setup( name="my_company_skills", entry_points={ - "signalwire.skills": [ + "signalwire_agents.skills": [ "product_search = my_company_skills.product_search.skill:ProductSearchSkill", "crm_integration = my_company_skills.crm_integration.skill:CRMSkill", ] diff --git a/fern/products/sdks/pages/guides/build-ai-agents/datamap.mdx b/fern/products/sdks/pages/guides/build-ai-agents/datamap.mdx index fa546e09e..0a05286cd 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/datamap.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/datamap.mdx @@ -64,9 +64,9 @@ Choosing between DataMap and handler functions is one of the first decisions you ```python -from signalwire import AgentBase -from signalwire.core.data_map import DataMap -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.data_map import DataMap +from signalwire_agents.core.function_result import SwaigFunctionResult class WeatherAgent(AgentBase): def __init__(self): @@ -79,7 +79,7 @@ class WeatherAgent(AgentBase): .description("Get current weather for a city") .parameter("city", "string", "City name", required=True) .webhook("GET", "https://api.weather.com/v1/current?key=API_KEY&q=${enc:args.city}") - .output(FunctionResult( + .output(SwaigFunctionResult( "The weather in ${args.city} is ${response.current.condition.text}, " "${response.current.temp_f} degrees Fahrenheit" )) @@ -92,7 +92,7 @@ class WeatherAgent(AgentBase): {/* ```typescript -import { AgentBase, FunctionResult } from 'signalwire-agents'; +import { AgentBase, SwaigFunctionResult } from 'signalwire-agents'; import { DataMap } from 'signalwire-agents/data-map'; const agent = new AgentBase({ name: 'weather-agent' }); @@ -102,7 +102,7 @@ const weatherDm = new DataMap('get_weather') .purpose('Get current weather for a city') .parameter('city', 'string', 'City name') .webhook('GET', 'https://api.weather.com/v1/current?key=API_KEY&q=${enc:args.city}') - .output(new FunctionResult( + .output(new SwaigFunctionResult( 'The weather in ${args.city} is ${response.current.condition.text}, ' + '${response.current.temp_f} degrees Fahrenheit' )); @@ -134,7 +134,7 @@ a.RegisterSwaigFunction(weatherDm.ToSwaigFunction()) ```ruby -require 'signalwire' +require 'signalwire_agents' agent = AgentBase.new(name: 'weather-agent') agent.add_language('English', 'en-US', 'rime.spore') @@ -204,27 +204,6 @@ auto weather_dm = datamap::DataMap("get_weather") agent.register_swaig_function(weather_dm.to_swaig_function()); ``` - -```php -use SignalWire\Agent\AgentBase; -use SignalWire\DataMap\DataMap; -use SignalWire\SWAIG\FunctionResult; - -$agent = new AgentBase(name: 'weather-agent'); -$agent->addLanguage('English', 'en-US', 'rime.spore'); - -$weatherDm = (new DataMap('get_weather')) - ->purpose('Get current weather for a city') - ->parameter('city', 'string', 'City name', required: true) - ->webhookUrl('GET', 'https://api.weather.com/v1/current?key=API_KEY&q=${enc:args.city}') - ->output(new FunctionResult( - 'The weather in ${args.city} is ${response.current.condition.text}, ' - . '${response.current.temp_f} degrees Fahrenheit' - )); - -$agent->registerSwaigFunction($weatherDm->toSwaigFunction()); -``` - ```csharp using SignalWire.Agent; @@ -246,6 +225,27 @@ agent.RegisterSwaigFunction(weatherDm.ToSwaigFunction()); ``` */} + +```php +use SignalWire\Agent\AgentBase; +use SignalWire\DataMap\DataMap; +use SignalWire\SWAIG\FunctionResult; + +$agent = new AgentBase(name: 'weather-agent'); +$agent->addLanguage('English', 'en-US', 'rime.spore'); + +$weatherDm = (new DataMap('get_weather')) + ->purpose('Get current weather for a city') + ->parameter('city', 'string', 'City name', required: true) + ->webhookUrl('GET', 'https://api.weather.com/v1/current?key=API_KEY&q=${enc:args.city}') + ->output(new FunctionResult( + 'The weather in ${args.city} is ${response.current.condition.text}, ' + . '${response.current.temp_f} degrees Fahrenheit' + )); + +$agent->registerSwaigFunction($weatherDm->toSwaigFunction()); +``` + ### Variable Substitution @@ -294,7 +294,7 @@ The DataMap fluent builder API: | Description | `.description("d")` | | Parameter | `.parameter("p","string","d")` | | Webhook | `.webhook("GET","url")` | -| Output | `.output(FunctionResult("..."))` | +| Output | `.output(SwaigFunctionResult("..."))` | | Fallback | `.fallback_output(...)` | @@ -353,7 +353,7 @@ Set request body for POST/PUT: Set the response for a webhook: ```python -.output(FunctionResult( +.output(SwaigFunctionResult( "Found product: ${response.name}. Price: $${response.price}" )) ``` @@ -363,7 +363,7 @@ Set the response for a webhook: Set fallback if all webhooks fail: ```python -.fallback_output(FunctionResult( +.fallback_output(SwaigFunctionResult( "Sorry, the service is currently unavailable" )) ``` @@ -377,9 +377,9 @@ The examples below use Python. The DataMap fluent builder pattern and variable s ```python #!/usr/bin/env python3 ## weather_datamap_agent.py - Weather agent using DataMap -from signalwire import AgentBase -from signalwire.core.data_map import DataMap -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.data_map import DataMap +from signalwire_agents.core.function_result import SwaigFunctionResult class WeatherAgent(AgentBase): def __init__(self): @@ -397,12 +397,12 @@ class WeatherAgent(AgentBase): "https://api.weatherapi.com/v1/current.json" "?key=YOUR_API_KEY&q=${enc:args.city}" ) - .output(FunctionResult( + .output(SwaigFunctionResult( "Current weather in ${args.city}: " "${response.current.condition.text}, " "${response.current.temp_f} degrees Fahrenheit" )) - .fallback_output(FunctionResult( + .fallback_output(SwaigFunctionResult( "Sorry, I couldn't get weather data for ${args.city}" )) ) @@ -428,10 +428,10 @@ product_dm = ( .description("Look up product by SKU") .parameter("sku", "string", "Product SKU", required=True) .webhook("GET", "https://api.store.com/products/${enc:args.sku}") - .output(FunctionResult( + .output(SwaigFunctionResult( "Found ${response.name}: $${response.price}. ${response.description}" )) - .fallback_output(FunctionResult( + .fallback_output(SwaigFunctionResult( "I couldn't find a product with SKU ${args.sku}. " "Please check the SKU and try again." )) @@ -459,9 +459,9 @@ A common pattern is looking up customer information from a CRM system. This exam ```python #!/usr/bin/env python3 ## crm_agent.py - Customer lookup using DataMap -from signalwire import AgentBase -from signalwire.core.data_map import DataMap -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.data_map import DataMap +from signalwire_agents.core.function_result import SwaigFunctionResult class CRMAgent(AgentBase): def __init__(self): @@ -484,13 +484,13 @@ class CRMAgent(AgentBase): "Content-Type": "application/json" } ) - .output(FunctionResult( + .output(SwaigFunctionResult( "Found customer ${response.data.first_name} ${response.data.last_name}. " "Account status: ${response.data.status}. " "Member since: ${response.data.created_at}. " "Total orders: ${response.data.order_count}." )) - .fallback_output(FunctionResult( + .fallback_output(SwaigFunctionResult( "I couldn't find a customer with email ${args.email}. " "Would you like to try a different email address?" )) @@ -510,9 +510,9 @@ This example shows a POST request to check appointment availability: ```python #!/usr/bin/env python3 ## appointment_agent.py - Appointment scheduling with DataMap -from signalwire import AgentBase -from signalwire.core.data_map import DataMap -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.data_map import DataMap +from signalwire_agents.core.function_result import SwaigFunctionResult class AppointmentAgent(AgentBase): def __init__(self): @@ -541,12 +541,12 @@ class AppointmentAgent(AgentBase): "service": "${args.service_type}", "duration_minutes": 30 }) - .output(FunctionResult( + .output(SwaigFunctionResult( "For ${args.date}, I found ${response.available_slots} available time slots. " "The earliest is at ${response.slots[0].time} and the latest is at " "${response.slots[-1].time}. Would you like to book one of these times?" )) - .fallback_output(FunctionResult( + .fallback_output(SwaigFunctionResult( "I couldn't check availability for ${args.date}. " "This might be a weekend or holiday. Would you like to try another date?" )) @@ -564,9 +564,9 @@ if __name__ == "__main__": ```python #!/usr/bin/env python3 ## order_agent.py - Order tracking with DataMap -from signalwire import AgentBase -from signalwire.core.data_map import DataMap -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.data_map import DataMap +from signalwire_agents.core.function_result import SwaigFunctionResult class OrderAgent(AgentBase): def __init__(self): @@ -585,13 +585,13 @@ class OrderAgent(AgentBase): "https://api.orders.example.com/v1/orders/${enc:args.order_number}", headers={"X-API-Key": "${global_data.orders_api_key}"} ) - .output(FunctionResult( + .output(SwaigFunctionResult( "Order ${args.order_number} status: ${response.status}. " "Shipped on ${response.shipped_date} via ${response.carrier}. " "Tracking number: ${response.tracking_number}. " "Estimated delivery: ${response.estimated_delivery}." )) - .fallback_output(FunctionResult( + .fallback_output(SwaigFunctionResult( "I couldn't find order ${args.order_number}. " "Please verify the order number. It should be in the format ORD-XXXXX." )) @@ -609,9 +609,9 @@ if __name__ == "__main__": ```python #!/usr/bin/env python3 ## multi_service_agent.py - Agent with multiple DataMap integrations -from signalwire import AgentBase -from signalwire.core.data_map import DataMap -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.data_map import DataMap +from signalwire_agents.core.function_result import SwaigFunctionResult class MultiServiceAgent(AgentBase): def __init__(self): @@ -630,11 +630,11 @@ class MultiServiceAgent(AgentBase): .webhook("GET", "https://api.weatherapi.com/v1/current.json" "?key=${global_data.weather_key}&q=${enc:args.city}") - .output(FunctionResult( + .output(SwaigFunctionResult( "${args.city}: ${response.current.temp_f} degrees F, " "${response.current.condition.text}" )) - .fallback_output(FunctionResult( + .fallback_output(SwaigFunctionResult( "Couldn't get weather for ${args.city}" )) .to_swaig_function() @@ -648,11 +648,11 @@ class MultiServiceAgent(AgentBase): .webhook("GET", "https://api.stocks.example.com/v1/quote/${enc:args.symbol}", headers={"Authorization": "Bearer ${global_data.stocks_key}"}) - .output(FunctionResult( + .output(SwaigFunctionResult( "${args.symbol}: $${response.price} " "(${response.change_percent}% today)" )) - .fallback_output(FunctionResult( + .fallback_output(SwaigFunctionResult( "Couldn't find stock ${args.symbol}" )) .to_swaig_function() @@ -669,11 +669,11 @@ class MultiServiceAgent(AgentBase): "https://api.exchange.example.com/convert" "?from=${enc:args.from_currency}&to=${enc:args.to_currency}" "&amount=${args.amount}") - .output(FunctionResult( + .output(SwaigFunctionResult( "${args.amount} ${args.from_currency} = " "${response.result} ${args.to_currency}" )) - .fallback_output(FunctionResult( + .fallback_output(SwaigFunctionResult( "Couldn't convert currency. Please check the currency codes." )) .to_swaig_function() @@ -751,7 +751,7 @@ def get_weather(self, args, raw_data): city = args.get("city") response = requests.get(f"https://api.weather.com?city={city}&key=API_KEY") data = response.json() - return FunctionResult( + return SwaigFunctionResult( f"Weather in {city}: {data['temp']} degrees F, {data['condition']}" ) ``` @@ -763,10 +763,10 @@ weather_dm = ( .description("Get weather for a city") .parameter("city", "string", "City name", required=True) .webhook("GET", "https://api.weather.com?city=${enc:args.city}&key=API_KEY") - .output(FunctionResult( + .output(SwaigFunctionResult( "Weather in ${args.city}: ${response.temp} degrees F, ${response.condition}" )) - .fallback_output(FunctionResult("Couldn't get weather for ${args.city}")) + .fallback_output(SwaigFunctionResult("Couldn't get weather for ${args.city}")) ) self.register_swaig_function(weather_dm.to_swaig_function()) ``` diff --git a/fern/products/sdks/pages/guides/build-ai-agents/defining-functions.mdx b/fern/products/sdks/pages/guides/build-ai-agents/defining-functions.mdx index 738b2d746..6df1b84b4 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/defining-functions.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/defining-functions.mdx @@ -34,7 +34,7 @@ Here's a complete agent with a SWAIG function: ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class OrderAgent(AgentBase): def __init__(self): @@ -73,7 +73,7 @@ class OrderAgent(AgentBase): } status = orders.get(order_number, "Order not found") - return FunctionResult(f"Order {order_number}: {status}") + return SwaigFunctionResult(f"Order {order_number}: {status}") if __name__ == "__main__": agent = OrderAgent() @@ -83,7 +83,7 @@ if __name__ == "__main__": {/* ```typescript -import { AgentBase, FunctionResult } from 'signalwire-agents'; +import { AgentBase, SwaigFunctionResult } from 'signalwire-agents'; const agent = new AgentBase({ name: 'order-agent' }); agent.addLanguage('English', 'en-US', 'rime.spore'); @@ -105,7 +105,7 @@ agent.defineTool({ '67890': 'Processing, ships tomorrow' }; const status = orders[args.order_number] || 'Order not found'; - return new FunctionResult(`Order ${args.order_number}: ${status}`); + return new SwaigFunctionResult(`Order ${args.order_number}: ${status}`); } }); @@ -159,7 +159,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = AgentBase.new(name: 'order-agent') agent.add_language('English', 'en-US', 'rime.spore') @@ -281,35 +281,6 @@ int main() { } ``` - -```php -use SignalWire\Agent\AgentBase; -use SignalWire\SWAIG\FunctionResult; - -$agent = new AgentBase(name: 'order-agent'); -$agent->addLanguage('English', 'en-US', 'rime.spore'); -$agent->promptAddSection('Role', 'You are an order status assistant. Help customers check their orders.'); - -$agent->defineTool('check_order', - 'Look up order status by order number', - ['type' => 'object', - 'properties' => [ - 'order_number' => ['type' => 'string', 'description' => 'The order number to look up'] - ], - 'required' => ['order_number']], - function (array $args, array $rawData) { - $orders = [ - '12345' => 'Shipped Monday, arriving Thursday', - '67890' => 'Processing, ships tomorrow', - ]; - $status = $orders[$args['order_number']] ?? 'Order not found'; - return new FunctionResult("Order {$args['order_number']}: $status"); - } -); - -$agent->run(); -``` - ```csharp using SignalWire.Agent; @@ -351,6 +322,35 @@ agent.Run(); ``` */} + +```php +use SignalWire\Agent\AgentBase; +use SignalWire\SWAIG\FunctionResult; + +$agent = new AgentBase(name: 'order-agent'); +$agent->addLanguage('English', 'en-US', 'rime.spore'); +$agent->promptAddSection('Role', 'You are an order status assistant. Help customers check their orders.'); + +$agent->defineTool('check_order', + 'Look up order status by order number', + ['type' => 'object', + 'properties' => [ + 'order_number' => ['type' => 'string', 'description' => 'The order number to look up'] + ], + 'required' => ['order_number']], + function (array $args, array $rawData) { + $orders = [ + '12345' => 'Shipped Monday, arriving Thursday', + '67890' => 'Processing, ships tomorrow', + ]; + $status = $orders[$args['order_number']] ?? 'Order not found'; + return new FunctionResult("Order {$args['order_number']}: $status"); + } +); + +$agent->run(); +``` + ## Function Types @@ -378,14 +378,14 @@ agent.Run(); | Complex business logic | Handler function | | Simple REST API calls | DataMap | | Pattern-based responses | DataMap expressions | -| Call transfers | Native function or FunctionResult.connect() | -| SMS sending | FunctionResult.send_sms() | +| Call transfers | Native function or SwaigFunctionResult.connect() | +| SMS sending | SwaigFunctionResult.send_sms() | ## Key Concepts **Handler Functions**: Python code that runs on your server when the AI decides to call a function. You have full access to databases, APIs, and any Python library. -**FunctionResult**: The return type for all SWAIG functions. Contains the response text the AI will speak and optional actions to execute. +**SwaigFunctionResult**: The return type for all SWAIG functions. Contains the response text the AI will speak and optional actions to execute. **Parameters**: JSON Schema definitions that tell the AI what arguments your function accepts. The AI will extract these from the conversation. @@ -398,7 +398,7 @@ Let's start by learning how to define functions. ## Basic Function Definition ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class MyAgent(AgentBase): def __init__(self): @@ -425,7 +425,7 @@ class MyAgent(AgentBase): def get_weather(self, args, raw_data): city = args.get("city") # Your logic here - return FunctionResult(f"The weather in {city} is sunny, 72 degrees") + return SwaigFunctionResult(f"The weather in {city} is sunny, 72 degrees") ``` ### define_tool() Across Languages @@ -442,9 +442,9 @@ The `define_tool()` method is available in all SDK languages. The parameters JSO | Java | `agent.defineTool("x", "d", Map.of("type","object","properties",Map.of(...)), (args, raw) -> new FunctionResult("..."))` | | Perl | `$agent->define_tool(name => 'x', description => 'd', parameters => {...}, handler => sub { my ($args,$raw) = @_; ... })` | | C++ | `agent.define_tool("x", "d", {{"type","object"},{"properties",{...}}}, [](const json& args, const json& raw) -> swaig::FunctionResult {...})` | -| PHP | `$agent->defineTool('x', 'd', ['type' => 'object', 'properties' => [...]], function(array $args, array $rawData) { ... })` | | C# | `agent.DefineTool("x", "d", new Dictionary{...}, (args, raw) => new FunctionResult("..."))` | */} +| PHP | `$agent->defineTool('x', 'd', ['type' => 'object', 'properties' => [...]], function(array $args, array $rawData) { ... })` | ## The define_tool() Method @@ -485,26 +485,26 @@ def my_handler(self, args, raw_data): - And more... Returns: - FunctionResult with response text and optional actions + SwaigFunctionResult with response text and optional actions """ - return FunctionResult("Response text") + return SwaigFunctionResult("Response text") ``` The handler signature across languages: | Language | Signature | |----------|-----------| -| Python | `def handler(self, args, raw_data):` returns `FunctionResult` | +| Python | `def handler(self, args, raw_data):` returns `SwaigFunctionResult` | {/* -| TypeScript | `(args: Record, raw?: Record) =>` returns `FunctionResult` | +| TypeScript | `(args: Record, raw?: Record) =>` returns `SwaigFunctionResult` | | Go | `func(args map[string]any, raw map[string]any) *swaig.FunctionResult` | | Ruby | `do \|args, raw\| ... end` returns `FunctionResult` | | Java | `(Map args, Map raw) ->` returns `FunctionResult` | | Perl | `sub { my ($args, $raw) = @_; ... }` returns `FunctionResult` | | C++ | `[](const json& args, const json& raw) -> swaig::FunctionResult` | -| PHP | `function(array $args, array $rawData): FunctionResult` | | C# | `(Dictionary args, Dictionary raw) => FunctionResult` | */} +| PHP | `function(array $args, array $rawData): FunctionResult` | ## Accessing Call Data @@ -518,7 +518,7 @@ def check_account(self, args, raw_data): account_id = args.get("account_id") # Use both for your logic - return FunctionResult( + return SwaigFunctionResult( f"Account {account_id} for caller {caller_number} is active" ) ``` @@ -586,15 +586,15 @@ class CustomerServiceAgent(AgentBase): def check_order(self, args, raw_data): order_number = args.get("order_number") - return FunctionResult(f"Order {order_number} is in transit") + return SwaigFunctionResult(f"Order {order_number} is in transit") def get_balance(self, args, raw_data): account_id = args.get("account_id") - return FunctionResult(f"Account {account_id} balance: $150.00") + return SwaigFunctionResult(f"Account {account_id} balance: $150.00") def get_store_hours(self, args, raw_data): location = args.get("location") - return FunctionResult(f"{location} store: Mon-Fri 9AM-9PM, Sat-Sun 10AM-6PM") + return SwaigFunctionResult(f"{location} store: Mon-Fri 9AM-9PM, Sat-Sun 10AM-6PM") ``` ## Function Fillers @@ -636,7 +636,7 @@ The `@tool` decorator is a Python-specific convenience. Other languages achieve Alternative syntax using decorators: ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class MyAgent(AgentBase): def __init__(self): @@ -658,7 +658,7 @@ class MyAgent(AgentBase): ) def get_time(self, args, raw_data): timezone = args.get("timezone", "UTC") - return FunctionResult(f"The current time in {timezone} is 3:45 PM") + return SwaigFunctionResult(f"The current time in {timezone} is 3:45 PM") ``` ## define_tool() vs @tool: Choosing an Approach @@ -710,7 +710,7 @@ def __init__(self, functions_config): ```python def external_handler(agent, args, raw_data): - return FunctionResult("Handled externally") + return SwaigFunctionResult("Handled externally") class MyAgent(AgentBase): def __init__(self): @@ -740,7 +740,7 @@ class CustomerServiceAgent(AgentBase): ) def check_order(self, args, raw_data): # Handler right here with its definition - return FunctionResult("...") + return SwaigFunctionResult("...") @AgentBase.tool( name="get_balance", @@ -748,7 +748,7 @@ class CustomerServiceAgent(AgentBase): parameters={...} ) def get_balance(self, args, raw_data): - return FunctionResult("...") + return SwaigFunctionResult("...") ``` The decorator keeps the function metadata with the implementation, making it easier to see what a function does at a glance. @@ -763,7 +763,7 @@ When using the `@tool` decorator (or `define_tool()`) **without** explicit `para ```python from typing import Optional, Literal -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class TypedAgent(AgentBase): def __init__(self): @@ -782,7 +782,7 @@ class TypedAgent(AgentBase): result = f"Order {order_number}: {status}" if include_tracking: result += " Tracking: https://track.example.com/12345" - return FunctionResult(result) + return SwaigFunctionResult(result) @AgentBase.tool(name="set_priority") def set_priority(self, ticket_id: str, level: Literal["low", "medium", "high"]): @@ -792,7 +792,7 @@ class TypedAgent(AgentBase): ticket_id: The support ticket ID level: Priority level to set """ - return FunctionResult(f"Ticket {ticket_id} set to {level} priority") + return SwaigFunctionResult(f"Ticket {ticket_id} set to {level} priority") ``` **How type inference works:** @@ -823,7 +823,7 @@ class TypedAgent(AgentBase): def caller_info(self, raw_data: dict): """Get information about the current caller.""" caller = raw_data.get("caller_id_num", "unknown") - return FunctionResult(f"Your number is {caller}") + return SwaigFunctionResult(f"Your number is {caller}") ``` **When to use type inference vs explicit parameters:** @@ -857,7 +857,7 @@ class HybridAgent(AgentBase): parameters={"type": "object", "properties": {}} ) def get_help(self, args, raw_data): - return FunctionResult("How can I help you?") + return SwaigFunctionResult("How can I help you?") ``` ## Registering Pre-Built SWAIG Functions @@ -874,9 +874,9 @@ The `register_swaig_function()` method registers a function definition object di | Java | `agent.registerSwaigFunction(dm.toSwaigFunction())` | | Perl | `$agent->register_swaig_function($dm->to_swaig_function())` | | C++ | `agent.register_swaig_function(dm.to_swaig_function())` | -| PHP | `$agent->registerSwaigFunction($dm->toSwaigFunction())` | | C# | `agent.RegisterSwaigFunction(dm.ToSwaigFunction())` | */} +| PHP | `$agent->registerSwaigFunction($dm->toSwaigFunction())` | ## External Webhook Functions @@ -964,7 +964,7 @@ The following example is shown in Python. All concepts demonstrated (multiple `d ```python #!/usr/bin/env python3 # restaurant_agent.py - Restaurant order assistant -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class RestaurantAgent(AgentBase): MENU = { @@ -1030,10 +1030,10 @@ class RestaurantAgent(AgentBase): item = self.MENU.get(item_name) if item: - return FunctionResult( + return SwaigFunctionResult( f"{item_name.title()}: {item['description']}. Price: ${item['price']}" ) - return FunctionResult(f"Sorry, {item_name} is not on our menu.") + return SwaigFunctionResult(f"Sorry, {item_name} is not on our menu.") def place_order(self, args, raw_data): items = args.get("items", []) @@ -1048,9 +1048,9 @@ class RestaurantAgent(AgentBase): msg = f"Order placed: {', '.join(items)}. Total: ${total:.2f}" if special: msg += f" Special requests: {special}" - return FunctionResult(msg) + return SwaigFunctionResult(msg) - return FunctionResult("Could not place order. Please check item names.") + return SwaigFunctionResult("Could not place order. Please check item names.") if __name__ == "__main__": agent = RestaurantAgent() diff --git a/fern/products/sdks/pages/guides/build-ai-agents/faq-bot.mdx b/fern/products/sdks/pages/guides/build-ai-agents/faq-bot.mdx index 8a7928cb0..1a057588f 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/faq-bot.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/faq-bot.mdx @@ -11,7 +11,7 @@ FAQBotAgent answers frequently asked questions from a provided knowledge base. I ```python -from signalwire.prefabs import FAQBotAgent +from signalwire_agents.prefabs import FAQBotAgent agent = FAQBotAgent( faqs=[ @@ -70,7 +70,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::Prefabs::FAQBotAgent.new( faqs: [ @@ -132,6 +132,22 @@ int main() { } ``` + +```csharp +using SignalWire.Prefabs; + +var agent = new FAQBotAgent(new AgentOptions { Name = "faq-bot" }); +agent.SetFaqs(new List> +{ + new() { ["question"] = "What are your business hours?", ["answer"] = "We're open Monday through Friday, 9 AM to 5 PM." }, + new() { ["question"] = "Where are you located?", ["answer"] = "Our main office is at 123 Main Street, Downtown." }, + new() { ["question"] = "How do I contact support?", ["answer"] = "Email support@example.com or call 555-1234." }, +}); + +agent.Run(); +``` + +*/} ```php run(); ``` - -```csharp -using SignalWire.Prefabs; - -var agent = new FAQBotAgent(new AgentOptions { Name = "faq-bot" }); -agent.SetFaqs(new List> -{ - new() { ["question"] = "What are your business hours?", ["answer"] = "We're open Monday through Friday, 9 AM to 5 PM." }, - new() { ["question"] = "Where are you located?", ["answer"] = "Our main office is at 123 Main Street, Downtown." }, - new() { ["question"] = "How do I contact support?", ["answer"] = "Email support@example.com or call 555-1234." }, -}); - -agent.Run(); -``` - -*/} ### FAQ Format @@ -178,17 +178,17 @@ agent.Run(); | Language | Import | |----------|--------| -| Python | `from signalwire.prefabs import FAQBotAgent` | +| Python | `from signalwire_agents.prefabs import FAQBotAgent` | {/* | TypeScript | `import { FAQBotAgent } from 'signalwire-agents'` | | Go | `"github.com/signalwire/signalwire-agents-go/pkg/prefabs"` | -| Ruby | `require 'signalwire'` then `SignalWireAgents::Prefabs::FAQBotAgent` | +| Ruby | `require 'signalwire_agents'` then `SignalWireAgents::Prefabs::FAQBotAgent` | | Java | `import com.signalwire.agents.prefabs.FAQBotAgent` | | Perl | `use SignalWire::Agents::Prefabs::FAQBotAgent` | | C++ | `#include ` | -| PHP | `use SignalWire\Prefabs\FAQBotAgent` | | C# | `using SignalWire.Prefabs;` | */} +| PHP | `use SignalWire\Prefabs\FAQBotAgent` | ### Constructor Parameters @@ -208,7 +208,7 @@ FAQBotAgent( Use categories to organize FAQs: ```python -from signalwire.prefabs import FAQBotAgent +from signalwire_agents.prefabs import FAQBotAgent agent = FAQBotAgent( faqs=[ @@ -256,7 +256,7 @@ agent = FAQBotAgent( ```python #!/usr/bin/env python3 ## product_faq_bot.py - FAQ bot for product questions -from signalwire.prefabs import FAQBotAgent +from signalwire_agents.prefabs import FAQBotAgent agent = FAQBotAgent( faqs=[ diff --git a/fern/products/sdks/pages/guides/build-ai-agents/hints.mdx b/fern/products/sdks/pages/guides/build-ai-agents/hints.mdx index b7d77339b..d105a4f65 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/hints.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/hints.mdx @@ -27,14 +27,14 @@ The hint methods accept a single string or a list of strings: | Java | `agent.addHint("Acme")` | `agent.addHints(List.of("Acme", "SignalWire"))` | | Perl | `$agent->add_hint('Acme')` | `$agent->add_hints(['Acme', 'SignalWire'])` | | C++ | `agent.add_hint("Acme")` | `agent.add_hints({"Acme", "SignalWire"})` | -| PHP | `$agent->addHint('Acme')` | `$agent->addHints('Acme', 'SignalWire')` | | C# | `agent.AddHint("Acme")` | `agent.AddHints(new List { "Acme", "SignalWire" })` | */} +| PHP | `$agent->addHint('Acme')` | `$agent->addHints('Acme', 'SignalWire')` | #### Single Hint ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -319,7 +319,7 @@ Check the generated SWML for the hints array: ```python #!/usr/bin/env python3 ## hinted_agent.py - Agent with speech recognition hints -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class HintedAgent(AgentBase): def __init__(self): @@ -356,8 +356,8 @@ class HintedAgent(AgentBase): "ENT500": "Acme Enterprise - Custom pricing" } if sku in products: - return FunctionResult(f"{sku}: {products[sku]}") - return FunctionResult(f"SKU {sku} not found.") + return SwaigFunctionResult(f"{sku}: {products[sku]}") + return SwaigFunctionResult(f"SKU {sku} not found.") if __name__ == "__main__": agent = HintedAgent() @@ -367,7 +367,7 @@ if __name__ == "__main__": {/* ```typescript -import { AgentBase, FunctionResult } from 'signalwire-agents'; +import { AgentBase, SwaigFunctionResult } from 'signalwire-agents'; const agent = new AgentBase({ name: "hinted-agent" }); agent.addLanguage({ name: 'English', code: 'en-US', voice: 'rime.spore' }); agent.addHints(['Acme', 'Acme Pro', 'Acme Enterprise', 'AcmePay', 'AcmeCloud']); @@ -376,7 +376,7 @@ agent.addHints(['account', 'billing', 'invoice', 'refund', 'cancel', 'upgrade', agent.addHints(['API', 'webhook', 'integration', 'OAuth', 'SSO', 'MFA']); agent.promptAddSection('Role', 'You are a customer service agent for Acme Corporation.'); const products: Record = { 'A100': 'Acme Basic - $99/month', 'A200': 'Acme Standard - $199/month', 'A300': 'Acme Premium - $299/month', 'PRO100': 'Acme Pro - $499/month', 'ENT500': 'Acme Enterprise - Custom pricing' }; -agent.defineTool({ name: 'lookup_product', description: 'Look up product by SKU', parameters: { type: 'object', properties: { sku: { type: 'string', description: 'Product SKU like A100 or PRO100' } }, required: ['sku'] }, handler: async (args) => { const sku = (args.sku as string).toUpperCase(); return new FunctionResult(products[sku] ? `${sku}: ${products[sku]}` : `SKU ${sku} not found.`); } }); +agent.defineTool({ name: 'lookup_product', description: 'Look up product by SKU', parameters: { type: 'object', properties: { sku: { type: 'string', description: 'Product SKU like A100 or PRO100' } }, required: ['sku'] }, handler: async (args) => { const sku = (args.sku as string).toUpperCase(); return new SwaigFunctionResult(products[sku] ? `${sku}: ${products[sku]}` : `SKU ${sku} not found.`); } }); agent.run(); ``` @@ -400,7 +400,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = AgentBase.new(name: "hinted-agent") agent.add_language(name: 'English', code: 'en-US', voice: 'rime.spore') agent.add_hints(['Acme', 'Acme Pro', 'Acme Enterprise', 'AcmePay', 'AcmeCloud']) @@ -467,22 +467,6 @@ int main() { } ``` - -```php -addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); -$agent->addHints('Acme', 'Acme Pro', 'Acme Enterprise', 'AcmePay', 'AcmeCloud'); -$agent->addHints('SKU', 'A100', 'A200', 'A300', 'PRO100', 'ENT500'); -$agent->addHints('account', 'billing', 'invoice', 'refund', 'cancel', 'upgrade', 'downgrade', 'representative', 'supervisor'); -$agent->addHints('API', 'webhook', 'integration', 'OAuth', 'SSO', 'MFA'); -$agent->promptAddSection('Role', 'You are a customer service agent for Acme Corporation.'); -$products = ['A100' => 'Acme Basic - $99/month', 'A200' => 'Acme Standard - $199/month', 'A300' => 'Acme Premium - $299/month', 'PRO100' => 'Acme Pro - $499/month', 'ENT500' => 'Acme Enterprise - Custom pricing']; -$agent->defineTool('lookup_product', 'Look up product by SKU', ['type' => 'object', 'properties' => ['sku' => ['type' => 'string', 'description' => 'Product SKU like A100 or PRO100']], 'required' => ['sku']], function ($args, $raw) use ($products) { $sku = strtoupper($args['sku']); return new FunctionResult(isset($products[$sku]) ? "$sku: {$products[$sku]}" : "SKU $sku not found."); }); -$agent->run('0.0.0.0', 3000); -``` - ```csharp using SignalWire.Agent; using SignalWire.SWAIG; @@ -499,6 +483,22 @@ agent.Run(); ``` */} + +```php +addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); +$agent->addHints('Acme', 'Acme Pro', 'Acme Enterprise', 'AcmePay', 'AcmeCloud'); +$agent->addHints('SKU', 'A100', 'A200', 'A300', 'PRO100', 'ENT500'); +$agent->addHints('account', 'billing', 'invoice', 'refund', 'cancel', 'upgrade', 'downgrade', 'representative', 'supervisor'); +$agent->addHints('API', 'webhook', 'integration', 'OAuth', 'SSO', 'MFA'); +$agent->promptAddSection('Role', 'You are a customer service agent for Acme Corporation.'); +$products = ['A100' => 'Acme Basic - $99/month', 'A200' => 'Acme Standard - $199/month', 'A300' => 'Acme Premium - $299/month', 'PRO100' => 'Acme Pro - $499/month', 'ENT500' => 'Acme Enterprise - Custom pricing']; +$agent->defineTool('lookup_product', 'Look up product by SKU', ['type' => 'object', 'properties' => ['sku' => ['type' => 'string', 'description' => 'Product SKU like A100 or PRO100']], 'required' => ['sku']], function ($args, $raw) use ($products) { $sku = strtoupper($args['sku']); return new SwaigFunctionResult(isset($products[$sku]) ? "$sku: {$products[$sku]}" : "SKU $sku not found."); }); +$agent->run('0.0.0.0', 3000); +``` + ### Next Steps diff --git a/fern/products/sdks/pages/guides/build-ai-agents/info-gatherer.mdx b/fern/products/sdks/pages/guides/build-ai-agents/info-gatherer.mdx index 6cf30947c..846970406 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/info-gatherer.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/info-gatherer.mdx @@ -11,7 +11,7 @@ InfoGatherer is a pre-built agent that collects answers to a series of questions ```python -from signalwire.prefabs import InfoGathererAgent +from signalwire_agents.prefabs import InfoGathererAgent agent = InfoGathererAgent( questions=[ @@ -61,7 +61,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::Prefabs::InfoGathererAgent.new( questions: [ @@ -123,6 +123,22 @@ int main() { } ``` + +```csharp +using SignalWire.Prefabs; + +var agent = new InfoGathererAgent(new AgentOptions { Name = "info-gatherer" }); +agent.SetFields(new List> +{ + new() { ["name"] = "full_name", ["description"] = "What is your full name?", ["required"] = true }, + new() { ["name"] = "email", ["description"] = "What is your email address?", ["required"] = true }, + new() { ["name"] = "reason", ["description"] = "How can I help you today?", ["required"] = true }, +}); + +agent.Run(); +``` + +*/} ```php run(); ``` - -```csharp -using SignalWire.Prefabs; - -var agent = new InfoGathererAgent(new AgentOptions { Name = "info-gatherer" }); -agent.SetFields(new List> -{ - new() { ["name"] = "full_name", ["description"] = "What is your full name?", ["required"] = true }, - new() { ["name"] = "email", ["description"] = "What is your email address?", ["required"] = true }, - new() { ["name"] = "reason", ["description"] = "How can I help you today?", ["required"] = true }, -}); - -agent.Run(); -``` - -*/} ### Question Format @@ -180,17 +180,17 @@ InfoGathererAgent( | Language | Import | |----------|--------| -| Python | `from signalwire.prefabs import InfoGathererAgent` | +| Python | `from signalwire_agents.prefabs import InfoGathererAgent` | {/* | TypeScript | `import { InfoGathererAgent } from 'signalwire-agents'` | | Go | `"github.com/signalwire/signalwire-agents-go/pkg/prefabs"` | -| Ruby | `require 'signalwire'` then `SignalWireAgents::Prefabs::InfoGathererAgent` | +| Ruby | `require 'signalwire_agents'` then `SignalWireAgents::Prefabs::InfoGathererAgent` | | Java | `import com.signalwire.agents.prefabs.InfoGathererAgent` | | Perl | `use SignalWire::Agents::Prefabs::InfoGathererAgent` | | C++ | `#include ` | -| PHP | `use SignalWire\Prefabs\InfoGathererAgent` | | C# | `using SignalWire.Prefabs;` | */} +| PHP | `use SignalWire\Prefabs\InfoGathererAgent` | ### Flow Diagram @@ -212,7 +212,7 @@ InfoGatherer provides these SWAIG functions automatically: Instead of static questions, use a callback to determine questions at runtime: ```python -from signalwire.prefabs import InfoGathererAgent +from signalwire_agents.prefabs import InfoGathererAgent def get_questions(query_params, body_params, headers): """Dynamically determine questions based on request""" @@ -262,7 +262,7 @@ answers = global_data.get("answers", []) ```python #!/usr/bin/env python3 # appointment_scheduler.py - Info gatherer for scheduling appointments -from signalwire.prefabs import InfoGathererAgent +from signalwire_agents.prefabs import InfoGathererAgent agent = InfoGathererAgent( questions=[ diff --git a/fern/products/sdks/pages/guides/build-ai-agents/lifecycle.mdx b/fern/products/sdks/pages/guides/build-ai-agents/lifecycle.mdx index 42485da6d..894d6de83 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/lifecycle.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/lifecycle.mdx @@ -123,13 +123,13 @@ Configure post-prompt handling in your agent: | Java | `agent.setPostPrompt("Summarize this call...")` | | Perl | `$agent->set_post_prompt('Summarize this call...')` | | C++ | `agent.set_post_prompt("Summarize this call...")` | -| PHP | `$agent->setPostPrompt('Summarize this call...')` | | C# | `agent.SetPostPrompt("Summarize this call...")` | */} +| PHP | `$agent->setPostPrompt('Summarize this call...')` | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -219,23 +219,6 @@ agent.on_summary([](const json& summary, const json& raw) { }); ``` - -```php -setPostPrompt( - 'Summarize this call including: 1) The caller\'s main question ' - . '2) How it was resolved 3) Any follow-up actions needed' -); - -$agent->onSummary(function (array $summary, array $rawData): void { - echo 'Call summary: ' . json_encode($summary) . PHP_EOL; -}); -``` - ```csharp using SignalWire.Agent; @@ -253,6 +236,23 @@ agent.OnSummary((summary, rawData) => ``` */} + +```php +setPostPrompt( + 'Summarize this call including: 1) The caller\'s main question ' + . '2) How it was resolved 3) Any follow-up actions needed' +); + +$agent->onSummary(function (array $summary, array $rawData): void { + echo 'Call summary: ' . json_encode($summary) . PHP_EOL; +}); +``` + ### Request/Response Headers @@ -321,7 +321,7 @@ swaig-test my_agent.py --exec get_balance --account_id 12345 --verbose #### Monitor Live Traffic ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class DebugAgent(AgentBase): def __init__(self): @@ -372,16 +372,16 @@ If a function fails: def get_balance(self, args, raw_data): try: balance = self.lookup_balance(args.get("account_id")) - return FunctionResult(f"Your balance is ${balance}") + return SwaigFunctionResult(f"Your balance is ${balance}") except DatabaseError: - return FunctionResult( + return SwaigFunctionResult( "I'm having trouble accessing account information right now. " "Please try again in a moment." ) except Exception as e: # Log the error but return user-friendly message self.logger.error(f"Function error: {e}") - return FunctionResult( + return SwaigFunctionResult( "I encountered an unexpected error. " "Let me transfer you to a representative." ) diff --git a/fern/products/sdks/pages/guides/build-ai-agents/mcp-gateway.mdx b/fern/products/sdks/pages/guides/build-ai-agents/mcp-gateway.mdx index af2e7effd..445d138d4 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/mcp-gateway.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/mcp-gateway.mdx @@ -135,11 +135,11 @@ The `mcp_gateway` skill connects agents to the gateway across all languages: | Java | `agent.addSkill("mcp_gateway", Map.of("gateway_url", "http://localhost:8080"))` | | Perl | `$agent->add_skill('mcp_gateway', { gateway_url => 'http://localhost:8080' })` | | C++ | `agent.add_skill("mcp_gateway", {{"gateway_url", "http://localhost:8080"}})` | -| PHP | `$agent->addSkill('mcp_gateway', ['url' => 'http://localhost:8080'])` | */} +| PHP | `$agent->addSkill('mcp_gateway', ['url' => 'http://localhost:8080'])` | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MCPAgent(AgentBase): def __init__(self): @@ -448,7 +448,7 @@ docker-compose up -d #!/usr/bin/env python3 # greeter_agent.py - Agent with MCP Gateway integration """Agent with MCP Gateway integration using the greeter MCP server""" -from signalwire import AgentBase +from signalwire_agents import AgentBase class GreeterAgent(AgentBase): def __init__(self): diff --git a/fern/products/sdks/pages/guides/build-ai-agents/multi-agent.mdx b/fern/products/sdks/pages/guides/build-ai-agents/multi-agent.mdx index 11d841d58..33aa58054 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/multi-agent.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/multi-agent.mdx @@ -46,7 +46,7 @@ Choosing between `agent.run()` and [`AgentServer`][ref-agentserver] depends on y ```python -from signalwire import AgentBase, AgentServer +from signalwire_agents import AgentBase, AgentServer class SalesAgent(AgentBase): def __init__(self): @@ -112,7 +112,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' sales = AgentBase.new(name: 'sales-agent') sales.add_language('English', 'en-US', 'rime.spore') @@ -191,26 +191,6 @@ int main() { } ``` - -```php -addLanguage('English', 'en-US', 'rime.spore'); -$sales->promptAddSection('Role', 'You are a sales representative.'); - -$support = new AgentBase(name: 'support-agent'); -$support->addLanguage('English', 'en-US', 'rime.spore'); -$support->promptAddSection('Role', 'You are a support specialist.'); - -$server = new AgentServer(port: 3000); -$server->addAgent($sales, '/sales'); -$server->addAgent($support, '/support'); -$server->run(); -``` - ```csharp using SignalWire.Agent; @@ -231,6 +211,26 @@ server.Run(); ``` */} + +```php +addLanguage('English', 'en-US', 'rime.spore'); +$sales->promptAddSection('Role', 'You are a sales representative.'); + +$support = new AgentBase(name: 'support-agent'); +$support->addLanguage('English', 'en-US', 'rime.spore'); +$support->promptAddSection('Role', 'You are a support specialist.'); + +$server = new AgentServer(port: 3000); +$server->addAgent($sales, '/sales'); +$server->addAgent($support, '/support'); +$server->run(); +``` + Agents are available at: @@ -304,7 +304,7 @@ server.unregister("/sales") Route SIP calls to specific agents based on username: ```python -from signalwire import AgentBase, AgentServer +from signalwire_agents import AgentBase, AgentServer class SalesAgent(AgentBase): def __init__(self): @@ -368,7 +368,7 @@ Response: AgentServer supports serverless environments automatically: ```python -from signalwire import AgentBase, AgentServer +from signalwire_agents import AgentBase, AgentServer class MyAgent(AgentBase): def __init__(self): @@ -392,8 +392,8 @@ if __name__ == "__main__": ```python #!/usr/bin/env python3 ## multi_agent_server.py - Server with multiple specialized agents -from signalwire import AgentBase, AgentServer -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase, AgentServer +from signalwire_agents.core.function_result import SwaigFunctionResult class SalesAgent(AgentBase): def __init__(self): @@ -420,7 +420,7 @@ class SalesAgent(AgentBase): def get_pricing(self, args, raw_data): product = args.get("product", "") - return FunctionResult(f"The price for {product} is $99.99") + return SwaigFunctionResult(f"The price for {product} is $99.99") class SupportAgent(AgentBase): def __init__(self): @@ -447,7 +447,7 @@ class SupportAgent(AgentBase): def create_ticket(self, args, raw_data): issue = args.get("issue", "") - return FunctionResult(f"Created ticket #12345 for: {issue}") + return SwaigFunctionResult(f"Created ticket #12345 for: {issue}") class BillingAgent(AgentBase): def __init__(self): @@ -498,7 +498,6 @@ if __name__ == "__main__": {/* **Method names across languages:** -| Python | TypeScript | Go | Ruby | Java | Perl | C++ | PHP | C# | |--------|------------|-----|------|------|------|-----|-----|-----| | `register()` | `register()` | `Register()` | `register()` | `register()` | `register()` | `register_agent()` | `addAgent()` | `Register()` | | `unregister()` | `unregister()` | `Unregister()` | `unregister()` | `unregister()` | `unregister()` | `unregister_agent()` | `removeAgent()` | `Unregister()` | @@ -506,6 +505,7 @@ if __name__ == "__main__": | `setup_sip_routing()` | `setupSipRouting()` | `SetupSIPRouting()` | `setup_sip_routing()` | `setupSipRouting()` | `setup_sip_routing()` | `setup_sip_routing()` | `setupSipRouting()` | `SetupSipRouting()` | | `run()` | `run()` | `Run()` | `run()` | `run()` | `run()` | `run()` | `run()` | `Run()` | */} +| Python | TypeScript | Go | Ruby | Java | Perl | C++ | PHP | C# | ### Performance Considerations @@ -543,7 +543,7 @@ class SharedStateAgent(AgentBase): shared_value = self.redis.get("shared_key") # Update shared state self.redis.set("shared_key", "new_value") - return FunctionResult("Done") + return SwaigFunctionResult("Done") # In main redis_client = redis.Redis(host='localhost', port=6379) diff --git a/fern/products/sdks/pages/guides/build-ai-agents/native-functions.mdx b/fern/products/sdks/pages/guides/build-ai-agents/native-functions.mdx index 84d32046a..df51f3f13 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/native-functions.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/native-functions.mdx @@ -36,11 +36,11 @@ Enable native functions in the constructor. The syntax varies by language: | Java | `new AgentBase("my-agent", Map.of("nativeFunctions", List.of("web_search")))` | | Perl | `AgentBase->new(name => 'my-agent', native_functions => ['web_search'])` | | C++ | `AgentBase("my-agent", {{"native_functions", {"web_search"}}})` | -| PHP | `$agent->setNativeFunctions(['web_search'])` | */} +| PHP | `$agent->setNativeFunctions(['web_search'])` | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -201,10 +201,10 @@ The debug function exposes diagnostic information during calls: ### Call Transfers -For call transfers, use `FunctionResult.connect()` in a custom handler function - there is no native transfer function: +For call transfers, use `SwaigFunctionResult.connect()` in a custom handler function - there is no native transfer function: ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class TransferAgent(AgentBase): DEPARTMENTS = { @@ -244,10 +244,10 @@ class TransferAgent(AgentBase): number = self.DEPARTMENTS.get(department) if not number: - return FunctionResult("Invalid department") + return SwaigFunctionResult("Invalid department") return ( - FunctionResult(f"Transferring you to {department}") + SwaigFunctionResult(f"Transferring you to {department}") .connect(number, final=True) ) ``` @@ -261,7 +261,7 @@ The examples below use Python. The pattern of passing `native_functions` in the Use native functions alongside your custom handlers: ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class HybridAgent(AgentBase): def __init__(self): @@ -296,7 +296,7 @@ class HybridAgent(AgentBase): def check_account(self, args, raw_data): account_id = args.get("account_id") - return FunctionResult(f"Account {account_id} is active") + return SwaigFunctionResult(f"Account {account_id} is active") ``` ### When to Use Native vs Custom Functions @@ -305,8 +305,8 @@ class HybridAgent(AgentBase): |----------|----------------| | Web search capability | Use `web_search` native function | | Development testing | Use `debug` native function | -| Transfer to phone number | Use FunctionResult.connect() in custom handler | -| Transfer to SIP address | Use FunctionResult.connect() in custom handler | +| Transfer to phone number | Use SwaigFunctionResult.connect() in custom handler | +| Transfer to SIP address | Use SwaigFunctionResult.connect() in custom handler | | Custom business logic | Use define_tool() with handler | | Database lookups | Use define_tool() with handler | diff --git a/fern/products/sdks/pages/guides/build-ai-agents/parameters.mdx b/fern/products/sdks/pages/guides/build-ai-agents/parameters.mdx index 89db5840e..ac425a5f7 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/parameters.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/parameters.mdx @@ -34,8 +34,8 @@ parameters={ | Java | `Map.of("type", "object", "properties", Map.of("p", Map.of("type", "string", "description", "d")), "required", List.of("p"))` | | Perl | `{ type => 'object', properties => { p => { type => 'string', description => 'd' } }, required => ['p'] }` | | C++ | `{{"type", "object"}, {"properties", {{"p", {{"type", "string"}, {"description", "d"}}}}}, {"required", {"p"}}}` | -| PHP | `['type' => 'object', 'properties' => ['p' => ['type' => 'string', 'description' => 'd']], 'required' => ['p']]` | */} +| PHP | `['type' => 'object', 'properties' => ['p' => ['type' => 'string', 'description' => 'd']], 'required' => ['p']]` | All parameter examples below use Python dict syntax. The JSON Schema structure is the same in every language -- translate the dict/map syntax to your language as shown in the table above. @@ -232,8 +232,8 @@ Handle missing optional parameters in your handler. The pattern for accessing ar | Java | `args.getOrDefault("key", "default")` | | Perl | `$args->{key} // 'default'` | | C++ | `args.value("key", "default")` | -| PHP | `$args['key'] ?? 'default'` | */} +| PHP | `$args['key'] ?? 'default'` | ```python def search_products(self, args, raw_data): @@ -253,7 +253,7 @@ def search_products(self, args, raw_data): sort=sort_by ) - return FunctionResult(f"Found {len(results)} products") + return SwaigFunctionResult(f"Found {len(results)} products") ``` ### Parameter Descriptions @@ -294,7 +294,7 @@ parameters={ ### Complex Example ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class TravelAgent(AgentBase): def __init__(self): @@ -365,7 +365,7 @@ class TravelAgent(AgentBase): nonstop = prefs.get("nonstop_only", False) # Your flight search logic here - return FunctionResult( + return SwaigFunctionResult( f"Found 3 flights from {from_city} to {to_city} on {date}. " f"Cheapest: $299 {cabin} class" ) @@ -382,18 +382,18 @@ def process_payment(self, args, raw_data): # Validate amount if amount is None or amount <= 0: - return FunctionResult( + return SwaigFunctionResult( "Invalid amount. Please specify a positive dollar amount." ) # Validate card if not card_last_four or len(card_last_four) != 4: - return FunctionResult( + return SwaigFunctionResult( "Please provide the last 4 digits of your card." ) # Process payment - return FunctionResult(f"Processing ${amount:.2f} on card ending {card_last_four}") + return SwaigFunctionResult(f"Processing ${amount:.2f} on card ending {card_last_four}") ``` ### Parameter Best Practices diff --git a/fern/products/sdks/pages/guides/build-ai-agents/prompts-pom.mdx b/fern/products/sdks/pages/guides/build-ai-agents/prompts-pom.mdx index 7e4b99dc0..cd58c6f69 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/prompts-pom.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/prompts-pom.mdx @@ -41,7 +41,7 @@ The `prompt_add_section` method is the primary way to build prompts: ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -92,14 +92,6 @@ agent::AgentBase agent("my-agent"); agent.prompt_add_section("Role", "You are a helpful customer service representative for Acme Corp."); ``` - -```php -promptAddSection('Role', 'You are a helpful customer service representative for Acme Corp.'); -``` - ```csharp using SignalWire.Agent; @@ -108,6 +100,14 @@ agent.PromptAddSection("Role", "You are a helpful customer service representativ ``` */} + +```php +promptAddSection('Role', 'You are a helpful customer service representative for Acme Corp.'); +``` + #### Section with Bullets @@ -123,9 +123,9 @@ Adding bullets to a section follows a similar pattern across languages: | Java | `promptAddSection("Title", "text", List.of(...))` | | Perl | `$agent->prompt_add_section('Title', 'text', bullets => [...])` | | C++ | `prompt_add_section("Title", "text", {...})` | -| PHP | `$agent->promptAddSection('Title', 'text', bullets: [...])` | | C# | `agent.PromptAddSection("Title", "text", bullets: new List{...})` | */} +| PHP | `$agent->promptAddSection('Title', 'text', bullets: [...])` | ```python ## Section with bullet points @@ -308,9 +308,9 @@ Use `set_post_prompt()` for simple text instructions: | Java | `agent.setPostPrompt("Summarize this call...")` | | Perl | `$agent->set_post_prompt('Summarize this call...')` | | C++ | `agent.set_post_prompt("Summarize this call...")` | -| PHP | `$agent->setPostPrompt('Summarize this call...')` | | C# | `agent.SetPostPrompt("Summarize this call...")` | */} +| PHP | `$agent->setPostPrompt('Summarize this call...')` | ```python self.set_post_prompt( diff --git a/fern/products/sdks/pages/guides/build-ai-agents/receptionist.mdx b/fern/products/sdks/pages/guides/build-ai-agents/receptionist.mdx index eaf16df6e..210f16e05 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/receptionist.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/receptionist.mdx @@ -11,7 +11,7 @@ ReceptionistAgent greets callers, collects their information, and transfers them ```python -from signalwire.prefabs import ReceptionistAgent +from signalwire_agents.prefabs import ReceptionistAgent agent = ReceptionistAgent( departments=[ @@ -73,7 +73,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::Prefabs::ReceptionistAgent.new( departments: [ @@ -135,6 +135,22 @@ int main() { } ``` + +```csharp +using SignalWire.Prefabs; + +var agent = new ReceptionistAgent(new AgentOptions { Name = "receptionist" }); +agent.SetDepartments(new List> +{ + new() { ["name"] = "sales", ["description"] = "Product inquiries, pricing, and purchasing", ["number"] = "+15551234567" }, + new() { ["name"] = "support", ["description"] = "Technical help and troubleshooting", ["number"] = "+15551234568" }, + new() { ["name"] = "billing", ["description"] = "Payment questions and account issues", ["number"] = "+15551234569" }, +}); + +agent.Run(); +``` + +*/} ```php run(); ``` - -```csharp -using SignalWire.Prefabs; - -var agent = new ReceptionistAgent(new AgentOptions { Name = "receptionist" }); -agent.SetDepartments(new List> -{ - new() { ["name"] = "sales", ["description"] = "Product inquiries, pricing, and purchasing", ["number"] = "+15551234567" }, - new() { ["name"] = "support", ["description"] = "Technical help and troubleshooting", ["number"] = "+15551234568" }, - new() { ["name"] = "billing", ["description"] = "Payment questions and account issues", ["number"] = "+15551234569" }, -}); - -agent.Run(); -``` - -*/} ### Department Format @@ -181,17 +181,17 @@ agent.Run(); | Language | Import | |----------|--------| -| Python | `from signalwire.prefabs import ReceptionistAgent` | +| Python | `from signalwire_agents.prefabs import ReceptionistAgent` | {/* | TypeScript | `import { ReceptionistAgent } from 'signalwire-agents'` | | Go | `"github.com/signalwire/signalwire-agents-go/pkg/prefabs"` | -| Ruby | `require 'signalwire'` then `SignalWireAgents::Prefabs::ReceptionistAgent` | +| Ruby | `require 'signalwire_agents'` then `SignalWireAgents::Prefabs::ReceptionistAgent` | | Java | `import com.signalwire.agents.prefabs.ReceptionistAgent` | | Perl | `use SignalWire::Agents::Prefabs::ReceptionistAgent` | | C++ | `#include ` | -| PHP | `use SignalWire\Prefabs\ReceptionistAgent` | | C# | `using SignalWire.Prefabs;` | */} +| PHP | `use SignalWire\Prefabs\ReceptionistAgent` | ### Constructor Parameters @@ -226,7 +226,7 @@ ReceptionistAgent provides these SWAIG functions automatically: ```python #!/usr/bin/env python3 ## company_receptionist.py - Custom receptionist agent -from signalwire.prefabs import ReceptionistAgent +from signalwire_agents.prefabs import ReceptionistAgent agent = ReceptionistAgent( departments=[ diff --git a/fern/products/sdks/pages/guides/build-ai-agents/results-actions.mdx b/fern/products/sdks/pages/guides/build-ai-agents/results-actions.mdx index 3eee3bc99..52edb8a3f 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/results-actions.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/results-actions.mdx @@ -1,6 +1,6 @@ --- title: "Results & Actions" -description: FunctionResult is the return type for all SWAIG functions, containing response text and optional actions like transfers, SMS, or context changes. +description: SwaigFunctionResult is the return type for all SWAIG functions, containing response text and optional actions like transfers, SMS, or context changes. slug: /guides/result-actions max-toc-depth: 3 --- @@ -13,20 +13,20 @@ Return a simple response: ```python -from signalwire import FunctionResult +from signalwire_agents import SwaigFunctionResult def check_order(self, args, raw_data): order_number = args.get("order_number") - return FunctionResult(f"Order {order_number} shipped yesterday") + return SwaigFunctionResult(f"Order {order_number} shipped yesterday") ``` {/* ```typescript -import { FunctionResult } from 'signalwire-agents'; +import { SwaigFunctionResult } from 'signalwire-agents'; -function checkOrder(args: Record): FunctionResult { - return new FunctionResult(`Order ${args.order_number} shipped yesterday`); +function checkOrder(args: Record): SwaigFunctionResult { + return new SwaigFunctionResult(`Order ${args.order_number} shipped yesterday`); } ``` @@ -69,15 +69,6 @@ sub { } ``` - -```php -use SignalWire\SWAIG\FunctionResult; - -function checkOrder(array $args, array $rawData): FunctionResult { - return new FunctionResult("Order {$args['order_number']} shipped yesterday"); -} -``` - ```csharp using SignalWire.SWAIG; @@ -89,24 +80,33 @@ FunctionResult CheckOrder(Dictionary args, Dictionary */} + +```php +use SignalWire\SWAIG\FunctionResult; + +function checkOrder(array $args, array $rawData): FunctionResult { + return new FunctionResult("Order {$args['order_number']} shipped yesterday"); +} +``` + ### [FunctionResult][ref-functionresult] Constructor Across Languages | Language | Constructor | |----------|------------| -| Python | `FunctionResult("response text")` | +| Python | `SwaigFunctionResult("response text")` | {/* -| TypeScript | `new FunctionResult("response text")` | +| TypeScript | `new SwaigFunctionResult("response text")` | | Go | `swaig.NewFunctionResult("response text")` | | Ruby | `FunctionResult.new("response text")` | | Java | `new FunctionResult("response text")` | | Perl | `FunctionResult->new("response text")` | | C++ | `swaig::FunctionResult("response text")` | -| PHP | `new FunctionResult('response text')` | | C# | `new FunctionResult("response text")` | */} +| PHP | `new FunctionResult('response text')` | -### FunctionResult Components +### SwaigFunctionResult Components | Component | Description | |-----------|-------------| @@ -116,14 +116,14 @@ FunctionResult CheckOrder(Dictionary args, Dictionaryconnect(dest)` | `.connect(dest, true)` | `->connect(dest)` | `.Connect(dest)` | | Hang up | `.hangup()` | `.Hangup()` | `.hangup` | `.hangup()` | `$r->hangup` | `.hangup()` | `->hangup()` | `.Hangup()` | @@ -149,6 +148,7 @@ The key action methods are available in all SDK languages with consistent naming | Global data | `.updateGlobalData({})` | `.UpdateGlobalData(m)` | `.update_global_data({})` | `.updateGlobalData(m)` | `$r->update_global_data({})` | `.update_global_data({})` | `->updateGlobalData([])` | `.UpdateGlobalData(dict)` | | Toggle funcs | `.toggleFunctions([])` | `.ToggleFunctions([]...)` | `.toggle_functions([])` | `.toggleFunctions(l)` | `$r->toggle_functions([])` | `.toggle_functions({})` | `->toggleFunctions([])` | `.ToggleFunctions(list)` | */} +| Action | TypeScript | Go | Ruby | Java | Perl | C++ | PHP | C# | The Python examples below demonstrate all action methods. The same methods are available in every SDK language using the naming conventions shown above. @@ -171,7 +171,7 @@ def transfer_call(self, args, raw_data): dest = numbers.get(department, "+15550000000") return ( - FunctionResult(f"Transferring you to {department}") + SwaigFunctionResult(f"Transferring you to {department}") .connect(dest, final=True) ) ``` @@ -201,7 +201,7 @@ def transfer_to_extension(self, args, raw_data): extension = args.get("extension") return ( - FunctionResult(f"Transferring to extension {extension}") + SwaigFunctionResult(f"Transferring to extension {extension}") .sip_refer(f"sip:{extension}@pbx.example.com") ) ``` @@ -215,7 +215,7 @@ def transfer_with_context(self, args, raw_data): department = args.get("department") return ( - FunctionResult("Let me connect you") + SwaigFunctionResult("Let me connect you") .swml_transfer( dest="+15551234567", ai_response=f"Customer needs help with {department}", @@ -234,7 +234,7 @@ def send_confirmation(self, args, raw_data): order_id = args.get("order_id") return ( - FunctionResult("I've sent you a confirmation text") + SwaigFunctionResult("I've sent you a confirmation text") .send_sms( to_number=phone, from_number="+15559876543", @@ -251,7 +251,7 @@ def send_receipt(self, args, raw_data): receipt_url = args.get("receipt_url") return ( - FunctionResult("I've sent your receipt") + SwaigFunctionResult("I've sent your receipt") .send_sms( to_number=phone, from_number="+15559876543", @@ -271,7 +271,7 @@ def collect_payment(self, args, raw_data): description = args.get("description", "Purchase") return ( - FunctionResult("I'll collect your payment information now") + SwaigFunctionResult("I'll collect your payment information now") .pay( payment_connector_url="https://api.example.com/payment", charge_amount=amount, @@ -288,7 +288,7 @@ def collect_payment(self, args, raw_data): ```python def subscription_payment(self, args, raw_data): return ( - FunctionResult("Let's set up your monthly subscription") + SwaigFunctionResult("Let's set up your monthly subscription") .pay( payment_connector_url="https://api.example.com/subscribe", charge_amount="29.99", @@ -315,7 +315,7 @@ Start and stop call recording: ```python def start_recording(self, args, raw_data): return ( - FunctionResult("Starting call recording") + SwaigFunctionResult("Starting call recording") .record_call( control_id="my_recording", stereo=True, @@ -326,7 +326,7 @@ def start_recording(self, args, raw_data): def stop_recording(self, args, raw_data): return ( - FunctionResult("Recording stopped") + SwaigFunctionResult("Recording stopped") .stop_record_call(control_id="my_recording") ) ``` @@ -336,7 +336,7 @@ def stop_recording(self, args, raw_data): ```python def record_with_timeout(self, args, raw_data): return ( - FunctionResult("Recording your message") + SwaigFunctionResult("Recording your message") .record_call( control_id="voicemail", max_length=120.0, # Stop after 2 minutes @@ -355,7 +355,7 @@ Tap audio to external endpoint for monitoring or transcription. Supports WebSock ```python def start_websocket_monitoring(self, args, raw_data): return ( - FunctionResult("Call monitoring started") + SwaigFunctionResult("Call monitoring started") .tap( uri="wss://monitor.example.com/audio", control_id="supervisor_tap", @@ -370,7 +370,7 @@ def start_websocket_monitoring(self, args, raw_data): ```python def start_rtp_tap(self, args, raw_data): return ( - FunctionResult("Recording to RTP endpoint") + SwaigFunctionResult("Recording to RTP endpoint") .tap( uri="rtp://192.168.1.100:5004", control_id="rtp_tap", @@ -382,7 +382,7 @@ def start_rtp_tap(self, args, raw_data): def stop_monitoring(self, args, raw_data): return ( - FunctionResult("Monitoring stopped") + SwaigFunctionResult("Monitoring stopped") .stop_tap(control_id="supervisor_tap") ) ``` @@ -396,7 +396,7 @@ Put caller on hold: ```python def hold_for_agent(self, args, raw_data): return ( - FunctionResult("Please hold while I find an available agent") + SwaigFunctionResult("Please hold while I find an available agent") .hold(timeout=60) # Hold for up to 60 seconds ) ``` @@ -408,7 +408,7 @@ End the call: ```python def end_call(self, args, raw_data): return ( - FunctionResult("Thank you for calling. Goodbye!") + SwaigFunctionResult("Thank you for calling. Goodbye!") .hangup() ) ``` @@ -422,7 +422,7 @@ RPC actions enable communication between calls, essential for call screening and ```python def execute_custom_rpc(self, args, raw_data): return ( - FunctionResult("Executing RPC") + SwaigFunctionResult("Executing RPC") .execute_rpc( method="ai_message", call_id="target-call-id", @@ -440,7 +440,7 @@ def screen_call_to_human(self, args, raw_data): caller_info = args.get("caller_name", "Unknown") return ( - FunctionResult("Please hold while I connect you.") + SwaigFunctionResult("Please hold while I connect you.") .hold(timeout=120) .rpc_dial( to_number=human_number, @@ -458,7 +458,7 @@ def notify_caller(self, args, raw_data): caller_call_id = args.get("original_call_id") return ( - FunctionResult("I'll let them know.") + SwaigFunctionResult("I'll let them know.") .rpc_ai_message( call_id=caller_call_id, message_text="The person you're trying to reach is unavailable. Please leave a message." @@ -474,7 +474,7 @@ def release_caller(self, args, raw_data): caller_call_id = args.get("original_call_id") return ( - FunctionResult("Returning you to the caller.") + SwaigFunctionResult("Returning you to the caller.") .rpc_ai_message(caller_call_id, "You can take their message now.") .rpc_ai_unhold(caller_call_id) ) @@ -496,7 +496,7 @@ def set_product_context(self, args, raw_data): } return ( - FunctionResult(f"Switching to {category} mode") + SwaigFunctionResult(f"Switching to {category} mode") .add_dynamic_hints(hints.get(category, [])) ) ``` @@ -510,7 +510,7 @@ def set_name_hints(self, args, raw_data): name = args.get("customer_name", "") return ( - FunctionResult(f"I'll listen for {name}") + SwaigFunctionResult(f"I'll listen for {name}") .add_dynamic_hints([ name, {"pattern": "cab bee", "replace": "Cabby", "ignore_case": True} @@ -525,7 +525,7 @@ Each hint can be a simple string or a dict with `pattern` (regex), `replace` (re ```python def reset_context(self, args, raw_data): return ( - FunctionResult("Context reset") + SwaigFunctionResult("Context reset") .clear_dynamic_hints() ) ``` @@ -543,7 +543,7 @@ def process_sensitive_data(self, args, raw_data): # ... process ssn ... return ( - FunctionResult("I've verified your identity.") + SwaigFunctionResult("I've verified your identity.") .replace_in_history(True) # Removes this Q&A pair from history ) ``` @@ -556,7 +556,7 @@ def collect_payment_info(self, args, raw_data): # ... process payment ... return ( - FunctionResult("Payment processed successfully.") + SwaigFunctionResult("Payment processed successfully.") .replace_in_history("Payment information was collected and processed.") ) ``` @@ -576,7 +576,7 @@ def announce_status(self, args, raw_data): order_status = args.get("status") return ( - FunctionResult() + SwaigFunctionResult() .say(f"Your order status is: {order_status}") ) ``` @@ -586,7 +586,7 @@ def announce_status(self, args, raw_data): ```python def interrupt_speech(self, args, raw_data): return ( - FunctionResult() + SwaigFunctionResult() .stop() # Immediately stop AI speech .say("Let me start over") ) @@ -599,7 +599,7 @@ Pause and wait for the user to speak: ```python def wait_for_confirmation(self, args, raw_data): return ( - FunctionResult("I'll wait for your response") + SwaigFunctionResult("I'll wait for your response") .wait_for_user(enabled=True, timeout=10) ) ``` @@ -611,7 +611,7 @@ Inject text as if the user spoke it: ```python def auto_confirm(self, args, raw_data): return ( - FunctionResult() + SwaigFunctionResult() .simulate_user_input("yes, I confirm") ) ``` @@ -623,7 +623,7 @@ Play audio files in the background during conversation: ```python def play_hold_music(self, args, raw_data): return ( - FunctionResult("Please hold") + SwaigFunctionResult("Please hold") .play_background_file( filename="https://example.com/hold-music.mp3", wait=False @@ -632,7 +632,7 @@ def play_hold_music(self, args, raw_data): def stop_hold_music(self, args, raw_data): return ( - FunctionResult("I'm back") + SwaigFunctionResult("I'm back") .stop_background_file() ) ``` @@ -647,7 +647,7 @@ def save_customer_info(self, args, raw_data): customer_name = args.get("name") return ( - FunctionResult(f"I've noted your information, {customer_name}") + SwaigFunctionResult(f"I've noted your information, {customer_name}") .update_global_data({ "customer_id": customer_id, "customer_name": customer_name, @@ -661,7 +661,7 @@ def save_customer_info(self, args, raw_data): ```python def clear_session_data(self, args, raw_data): return ( - FunctionResult("Session data cleared") + SwaigFunctionResult("Session data cleared") .remove_global_data(["customer_id", "verified"]) ) ``` @@ -673,7 +673,7 @@ Store function-specific metadata (separate from global data): ```python def track_function_usage(self, args, raw_data): return ( - FunctionResult("Usage tracked") + SwaigFunctionResult("Usage tracked") .set_metadata({ "function_called": "check_order", "timestamp": "2024-01-15T10:30:00Z", @@ -687,7 +687,7 @@ def track_function_usage(self, args, raw_data): ```python def clear_function_metadata(self, args, raw_data): return ( - FunctionResult("Metadata cleared") + SwaigFunctionResult("Metadata cleared") .remove_metadata(["timestamp", "user_id"]) ) ``` @@ -701,7 +701,7 @@ Change the agent's prompt/context with new system and user prompts: ```python def switch_to_technical(self, args, raw_data): return ( - FunctionResult("Switching to technical support mode") + SwaigFunctionResult("Switching to technical support mode") .switch_context( system_prompt="You are now a technical support specialist. " "Help the customer with their technical issue.", @@ -717,7 +717,7 @@ Switch to a named SWML context: ```python def switch_to_billing(self, args, raw_data): return ( - FunctionResult("Let me connect you with billing") + SwaigFunctionResult("Let me connect you with billing") .swml_change_context("billing_context") ) ``` @@ -729,7 +729,7 @@ Change to a specific workflow step: ```python def move_to_checkout(self, args, raw_data): return ( - FunctionResult("Moving to checkout") + SwaigFunctionResult("Moving to checkout") .swml_change_step("checkout_step") ) ``` @@ -741,7 +741,7 @@ Dynamically enable or disable functions during the call: ```python def enable_payment_functions(self, args, raw_data): return ( - FunctionResult("Payment functions are now available") + SwaigFunctionResult("Payment functions are now available") .toggle_functions([ {"function": "collect_payment", "active": True}, {"function": "refund_payment", "active": True}, @@ -755,7 +755,7 @@ def enable_payment_functions(self, args, raw_data): ```python def enable_escalation_on_timeout(self, args, raw_data): return ( - FunctionResult("I'll help you with that") + SwaigFunctionResult("I'll help you with that") .enable_functions_on_timeout(enabled=True) ) ``` @@ -765,7 +765,7 @@ def enable_escalation_on_timeout(self, args, raw_data): ```python def adjust_speech_timing(self, args, raw_data): return ( - FunctionResult("Adjusting response timing") + SwaigFunctionResult("Adjusting response timing") .update_settings({ "end_of_speech_timeout": 1000, "attention_timeout": 30000 @@ -778,7 +778,7 @@ def adjust_speech_timing(self, args, raw_data): ```python def configure_timeouts(self, args, raw_data): return ( - FunctionResult() + SwaigFunctionResult() .set_end_of_speech_timeout(800) # 800ms .set_speech_event_timeout(5000) # 5s ) @@ -793,7 +793,7 @@ def join_team_conference(self, args, raw_data): conf_name = args.get("conference_name") return ( - FunctionResult(f"Joining {conf_name}") + SwaigFunctionResult(f"Joining {conf_name}") .join_conference( name=conf_name, muted=False, @@ -808,7 +808,7 @@ def join_team_conference(self, args, raw_data): ```python def join_support_room(self, args, raw_data): return ( - FunctionResult("Connecting to support room") + SwaigFunctionResult("Connecting to support room") .join_room(name="support-room-1") ) ``` @@ -820,7 +820,7 @@ Let AI speak once more before executing actions: ```python def transfer_with_confirmation(self, args, raw_data): return ( - FunctionResult( + SwaigFunctionResult( "I'll transfer you to billing. Is there anything else first?", post_process=True # AI can respond to follow-up before transfer ) @@ -837,7 +837,7 @@ def complete_interaction(self, args, raw_data): customer_phone = args.get("phone") return ( - FunctionResult("I've completed your request") + SwaigFunctionResult("I've completed your request") .update_global_data({"interaction_complete": True}) .send_sms( to_number=customer_phone, @@ -853,12 +853,12 @@ When chaining multiple actions, understanding how they interact is important. #### Execution Order -Actions execute in the order they're added to the FunctionResult. The response text is processed first, then actions execute sequentially. +Actions execute in the order they're added to the SwaigFunctionResult. The response text is processed first, then actions execute sequentially. ```python # These execute in order: 1, 2, 3 return ( - FunctionResult("Starting process") + SwaigFunctionResult("Starting process") .update_global_data({"step": 1}) # 1st .send_sms(to_number=phone, ...) # 2nd .update_global_data({"step": 2}) # 3rd @@ -887,7 +887,7 @@ Some actions end the call or AI session. Once a terminal action executes, subseq ```python # Good - data saved before transfer return ( - FunctionResult("Transferring you now") + SwaigFunctionResult("Transferring you now") .update_global_data({"transferred": True}) # Executes .send_sms(to_number=phone, body="...") # Executes .connect("+15551234567", final=True) # Terminal @@ -895,7 +895,7 @@ return ( # Risky - SMS might not send return ( - FunctionResult("Transferring you now") + SwaigFunctionResult("Transferring you now") .connect("+15551234567", final=True) # Terminal - call leaves .send_sms(to_number=phone, body="...") # May not execute ) @@ -919,7 +919,7 @@ When `post_process=True`, the AI speaks the response and can respond to follow-u ```python return ( - FunctionResult( + SwaigFunctionResult( "I'll transfer you. Anything else first?", post_process=True # AI waits for response ) @@ -973,7 +973,7 @@ def execute_custom_swml(self, args, raw_data): } return ( - FunctionResult() + SwaigFunctionResult() .execute_swml(swml_doc, transfer=False) ) ``` diff --git a/fern/products/sdks/pages/guides/build-ai-agents/search-knowledge.mdx b/fern/products/sdks/pages/guides/build-ai-agents/search-knowledge.mdx index eb06aa1cd..909be6616 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/search-knowledge.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/search-knowledge.mdx @@ -142,11 +142,11 @@ Add the `native_vector_search` skill to enable search: | Java | `agent.addSkill("native_vector_search", Map.of("index_file", "./knowledge.swsearch", "count", 5))` | | Perl | `$agent->add_skill('native_vector_search', index_file => './knowledge.swsearch', count => 5)` | | C++ | `agent.add_skill("native_vector_search", {{"index_file", "./knowledge.swsearch"}, {"count", 5}})` | -| PHP | `$agent->addSkill('datasphere', ['document_id' => '...', 'space_name' => '...'])` | */} +| PHP | `$agent->addSkill('datasphere', ['document_id' => '...', 'space_name' => '...'])` | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class KnowledgeAgent(AgentBase): def __init__(self): @@ -245,8 +245,8 @@ sw-search search knowledge.swsearch "how do I configure auth" ```python #!/usr/bin/env python3 ## documentation_agent.py - Agent that searches documentation -from signalwire import AgentBase -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.function_result import SwaigFunctionResult class DocumentationAgent(AgentBase): """Agent that searches documentation to answer questions""" @@ -292,7 +292,7 @@ class DocumentationAgent(AgentBase): def search_docs(self, args, raw_data): """Stub search function for demonstration""" query = args.get("query", "") - return FunctionResult( + return SwaigFunctionResult( f"Search results for '{query}': This is a demonstration. " "In production, use native_vector_search skill with a .swsearch index file." ) diff --git a/fern/products/sdks/pages/guides/build-ai-agents/security.mdx b/fern/products/sdks/pages/guides/build-ai-agents/security.mdx index 51a05cc21..c9d25d5e8 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/security.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/security.mdx @@ -86,7 +86,7 @@ INFO: Password: a7b3x9k2m5n1p8q4 # Use this in SignalWire webhook config #### Credentials in Your Agent ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase import os class MyAgent(AgentBase): @@ -140,11 +140,11 @@ Enable per-function token validation with the `secure` flag: | Java | `toolDef.setSecure(true)` | | Perl | `$agent->define_tool(..., secure => 1)` | | C++ | `ToolDefinition{ ..., .secure = true }` | -| PHP | `$agent->defineTool(..., secure: true)` | */} +| PHP | `$agent->defineTool(..., secure: true)` | ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class SecureAgent(AgentBase): def __init__(self): @@ -168,11 +168,11 @@ class SecureAgent(AgentBase): ) def get_balance(self, args, raw_data): - return FunctionResult("Balance is $150.00") + return SwaigFunctionResult("Balance is $150.00") def transfer_funds(self, args, raw_data): # This only executes if token is valid - return FunctionResult("Transfer complete") + return SwaigFunctionResult("Transfer complete") ``` #### Token Generation @@ -210,7 +210,7 @@ export SWML_DOMAIN=my-agent.example.com ``` ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class SecureAgent(AgentBase): def __init__(self): @@ -269,21 +269,21 @@ def transfer_funds(self, args, raw_data): # Validate inputs if not amount or not isinstance(amount, (int, float)): - return FunctionResult("Invalid amount specified") + return SwaigFunctionResult("Invalid amount specified") if amount <= 0: - return FunctionResult("Amount must be positive") + return SwaigFunctionResult("Amount must be positive") if amount > 10000: - return FunctionResult( + return SwaigFunctionResult( "Transfers over $10,000 require additional verification" ) if not to_account or len(to_account) != 10: - return FunctionResult("Invalid account number") + return SwaigFunctionResult("Invalid account number") # Proceed with transfer - return FunctionResult(f"Transferred ${amount} to account {to_account}") + return SwaigFunctionResult(f"Transferred ${amount} to account {to_account}") ``` #### 4. Use Secure Functions for Sensitive Operations @@ -344,7 +344,7 @@ class SecureAgent(AgentBase): f"Transfer completed: call_id={call_id}, result={result}" ) - return FunctionResult(f"Transfer of ${amount} complete") + return SwaigFunctionResult(f"Transfer of ${amount} complete") ``` #### 6. Implement Rate Limiting @@ -381,12 +381,12 @@ class RateLimitedAgent(AgentBase): caller = raw_data.get("caller_id_num") if not self.check_rate_limit(caller): - return FunctionResult( + return SwaigFunctionResult( "You've made too many requests. Please wait a moment." ) # Process normally - return FunctionResult("Your balance is $150.00") + return SwaigFunctionResult("Your balance is $150.00") ``` ### Configuring SignalWire Webhooks @@ -462,7 +462,7 @@ def sensitive_operation(self, args, raw_data): verification_code = args.get("verification_code") if not self.verify_caller(caller, verification_code): - return FunctionResult( + return SwaigFunctionResult( "Please provide your verification code to continue." ) @@ -563,13 +563,13 @@ def transfer_funds(self, args, raw_data): "reason": "amount_exceeded", "amount": amount }, raw_data) - return FunctionResult("Amount exceeds limit") + return SwaigFunctionResult("Amount exceeds limit") # Success self.log_security_event("transfer_success", { "amount": amount }, raw_data) - return FunctionResult("Transfer complete") + return SwaigFunctionResult("Transfer complete") ``` ### Incident Response @@ -612,7 +612,7 @@ class EmergencyModeAgent(AgentBase): self.log_security_event("emergency_block", { "function": "transfer_funds" }, raw_data) - return FunctionResult( + return SwaigFunctionResult( "This service is temporarily unavailable." ) diff --git a/fern/products/sdks/pages/guides/build-ai-agents/skill-config.mdx b/fern/products/sdks/pages/guides/build-ai-agents/skill-config.mdx index eb1009794..2885743f9 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/skill-config.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/skill-config.mdx @@ -28,8 +28,8 @@ Pass configuration when adding a skill: | Java | `agent.addSkill("web_search", Map.of("api_key", "...", "num_results", 5))` | | Perl | `$agent->add_skill('web_search', { api_key => '...', num_results => 5 })` | | C++ | `agent.add_skill("web_search", {{"api_key", "..."}, {"num_results", "5"}})` | -| PHP | `$agent->addSkill('web_search', ['api_key' => '...', 'num_results' => 5])` | */} +| PHP | `$agent->addSkill('web_search', ['api_key' => '...', 'num_results' => 5])` | ```python self.add_skill("web_search", { @@ -113,8 +113,8 @@ Override SWAIG function metadata for skill tools: | Java | `agent.addSkill("datetime", Map.of("swaig_fields", Map.of("fillers", ...)))` | | Perl | `$agent->add_skill('datetime', { swaig_fields => { fillers => {...} } })` | | C++ | `agent.add_skill("datetime", {{"swaig_fields", {{"fillers", ...}}}})` | -| PHP | `$agent->addSkill('datetime', ['swaig_fields' => ['fillers' => [...]]])` | */} +| PHP | `$agent->addSkill('datetime', ['swaig_fields' => ['fillers' => [...]]])` | ```python self.add_skill("datetime", { @@ -145,7 +145,7 @@ Available SWAIG fields: Register custom skill directories: ```python -from signalwire.skills.registry import skill_registry +from signalwire_agents.skills.registry import skill_registry ## Add directory at runtime skill_registry.add_skill_directory("/opt/custom_skills") @@ -163,7 +163,7 @@ Install skills via pip packages: setup( name="my-skills-package", entry_points={ - "signalwire.skills": [ + "signalwire_agents.skills": [ "weather = my_package.skills:WeatherSkill", "stock = my_package.skills:StockSkill" ] @@ -174,7 +174,7 @@ setup( ### Listing Available Skills ```python -from signalwire.skills.registry import skill_registry +from signalwire_agents.skills.registry import skill_registry ## List all available skills skills = skill_registry.list_skills() @@ -200,8 +200,8 @@ Skills supporting multiple instances need unique tool names: | Java | `agent.addSkill("web_search", Map.of("tool_name", "search_news", "api_key", "KEY"))` | | Perl | `$agent->add_skill('web_search', { tool_name => 'search_news', api_key => 'KEY' })` | | C++ | `agent.add_skill("web_search", {{"tool_name", "search_news"}, {"api_key", "KEY"}})` | -| PHP | `$agent->addSkill('web_search', ['tool_name' => 'search_news', 'api_key' => 'KEY'])` | */} +| PHP | `$agent->addSkill('web_search', ['tool_name' => 'search_news', 'api_key' => 'KEY'])` | ```python ## Instance 1: News search @@ -228,8 +228,8 @@ self.add_skill("web_search", { ### Complete Configuration Example ```python -from signalwire import AgentBase -from signalwire.skills.registry import skill_registry +from signalwire_agents import AgentBase +from signalwire_agents.skills.registry import skill_registry import os ## Register external skills diff --git a/fern/products/sdks/pages/guides/build-ai-agents/state-management.mdx b/fern/products/sdks/pages/guides/build-ai-agents/state-management.mdx index 0002fd004..33fc68551 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/state-management.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/state-management.mdx @@ -21,7 +21,7 @@ If you need data to persist across calls (like customer profiles or order histor 1. Agent initialization sets initial `global_data` 2. AI uses state in prompts via `${global_data.key}` substitution -3. SWAIG functions can read state from `raw_data` and update it via `FunctionResult` +3. SWAIG functions can read state from `raw_data` and update it via `SwaigFunctionResult` 4. Updated state becomes available to subsequent prompts and function calls 5. When the call ends, `post_prompt` runs to extract structured data 6. All in-memory state is cleared @@ -59,12 +59,12 @@ Global data persists throughout the entire call session and is available to all | Java | `agent.setGlobalData(Map.of("business_name", "Acme Corp"))` | | Perl | `$agent->set_global_data({ business_name => 'Acme Corp' })` | | C++ | `agent.set_global_data({{"business_name", "Acme Corp"}})` | -| PHP | `$agent->setGlobalData(['business_name' => 'Acme Corp'])` | | C# | `agent.SetGlobalData(new Dictionary { ["business_name"] = "Acme Corp" })` | */} +| PHP | `$agent->setGlobalData(['business_name' => 'Acme Corp'])` | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class CustomerAgent(AgentBase): def __init__(self): @@ -118,9 +118,9 @@ self.set_global_data({ | Java | `agent.updateGlobalData(Map.of("customer_tier", "premium"))` | | Perl | `$agent->update_global_data({ customer_tier => 'premium' })` | | C++ | `agent.update_global_data({{"customer_tier", "premium"}})` | -| PHP | `$agent->updateGlobalData(['customer_tier' => 'premium'])` | | C# | `agent.UpdateGlobalData(new Dictionary { ["customer_tier"] = "premium" })` | */} +| PHP | `$agent->updateGlobalData(['customer_tier' => 'premium'])` | ```python self.update_global_data({ @@ -135,7 +135,7 @@ Updating state from within a SWAIG function handler: | Language | Syntax | |----------|--------| -| Python | `FunctionResult("Done").update_global_data({"key": "val"})` | +| Python | `SwaigFunctionResult("Done").update_global_data({"key": "val"})` | {/* | TypeScript | `result.updateGlobalData({ key: 'val' })` | | Go | `result.UpdateGlobalData(map[string]any{"key": "val"})` | @@ -143,13 +143,13 @@ Updating state from within a SWAIG function handler: | Java | `result.updateGlobalData(Map.of("key", "val"))` | | Perl | `$result->update_global_data({ key => 'val' })` | | C++ | `result.update_global_data({{"key", "val"}})` | -| PHP | `(new FunctionResult('Done'))->updateGlobalData(['key' => 'val'])` | | C# | `new FunctionResult("Done").UpdateGlobalData(new Dictionary { ["key"] = "val" })` | */} +| PHP | `(new SwaigFunctionResult('Done'))->updateGlobalData(['key' => 'val'])` | ```python -from signalwire import AgentBase -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.function_result import SwaigFunctionResult class StateAgent(AgentBase): def __init__(self): @@ -173,7 +173,7 @@ class StateAgent(AgentBase): name = args.get("name", "") return ( - FunctionResult(f"Stored name: {name}") + SwaigFunctionResult(f"Stored name: {name}") .update_global_data({"customer_name": name}) ) @@ -213,16 +213,16 @@ Metadata is scoped to a specific function's `meta_data_token`, providing isolate | Java | `result.setMetadata(Map.of("order_id", orderId, "status", "pending"))` | | Perl | `$result->set_metadata({ order_id => $order_id, status => 'pending' })` | | C++ | `result.set_metadata({{"order_id", order_id}, {"status", "pending"}})` | -| PHP | `$result->setMetadata(['order_id' => $orderId, 'status' => 'pending'])` | | C# | `result.SetMetadata(new Dictionary { ["order_id"] = orderId, ["status"] = "pending" })` | */} +| PHP | `$result->setMetadata(['order_id' => $orderId, 'status' => 'pending'])` | ```python def process_order(self, args, raw_data): order_id = create_order() return ( - FunctionResult(f"Created order {order_id}") + SwaigFunctionResult(f"Created order {order_id}") .set_metadata({"order_id": order_id, "status": "pending"}) ) ``` @@ -239,14 +239,14 @@ def process_order(self, args, raw_data): | Java | `result.removeMetadata(List.of("order_id", "status"))` | | Perl | `$result->remove_metadata(['order_id', 'status'])` | | C++ | `result.remove_metadata({"order_id", "status"})` | -| PHP | `$result->removeMetadata(['order_id', 'status'])` | | C# | `result.RemoveMetadata(new List { "order_id", "status" })` | */} +| PHP | `$result->removeMetadata(['order_id', 'status'])` | ```python def cancel_order(self, args, raw_data): return ( - FunctionResult("Order cancelled") + SwaigFunctionResult("Order cancelled") .remove_metadata(["order_id", "status"]) ) ``` @@ -258,7 +258,7 @@ The post-prompt runs after the call ends and generates structured data from the #### Setting Post-Prompt ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class SurveyAgent(AgentBase): def __init__(self): @@ -317,7 +317,7 @@ def my_handler(self, args, raw_data): self.log.info(f"Call from {caller_id_number}") - return FunctionResult("Processing...") + return SwaigFunctionResult("Processing...") ``` ### Complete Example @@ -326,8 +326,8 @@ def my_handler(self, args, raw_data): ```python #!/usr/bin/env python3 ## order_agent.py - Order management with state -from signalwire import AgentBase -from signalwire.core.function_result import FunctionResult +from signalwire_agents import AgentBase +from signalwire_agents.core.function_result import SwaigFunctionResult class OrderAgent(AgentBase): def __init__(self): @@ -388,7 +388,7 @@ class OrderAgent(AgentBase): # Note: In real implementation, maintain state server-side # This example shows the pattern return ( - FunctionResult(f"Added {item} (${price}) to your order") + SwaigFunctionResult(f"Added {item} (${price}) to your order") .update_global_data({ "last_item_added": item, "last_item_price": price @@ -403,7 +403,7 @@ if __name__ == "__main__": {/* ```typescript -import { AgentBase, FunctionResult } from 'signalwire-agents'; +import { AgentBase, SwaigFunctionResult } from 'signalwire-agents'; const agent = new AgentBase({ name: 'order-agent' }); agent.addLanguage('English', 'en-US', 'rime.spore'); @@ -433,7 +433,7 @@ agent.defineTool({ required: ['item', 'price'], }, handler: (args) => { - return new FunctionResult(`Added ${args.item} ($${args.price}) to your order`) + return new SwaigFunctionResult(`Added ${args.item} ($${args.price}) to your order`) .updateGlobalData({ last_item_added: args.item, last_item_price: args.price }); }, }); @@ -467,10 +467,10 @@ func main() { a.DefineTool("add_item", "Add an item to the order", agents.Params("item", "string", "Item name", "price", "number", "Item price"), - func(args map[string]any, rawData map[string]any) *agents.FunctionResult { + func(args map[string]any, rawData map[string]any) *agents.SwaigFunctionResult { item := args["item"].(string) price := args["price"].(float64) - return agents.NewFunctionResult(fmt.Sprintf("Added %s ($%.2f) to your order", item, price)). + return agents.NewSwaigFunctionResult(fmt.Sprintf("Added %s ($%.2f) to your order", item, price)). UpdateGlobalData(map[string]any{"last_item_added": item, "last_item_price": price}) }) @@ -480,7 +480,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = AgentBase.new(name: 'order-agent') agent.add_language('English', 'en-US', 'rime.spore') @@ -501,7 +501,7 @@ agent.define_tool( description: 'Add an item to the order', parameters: { item: { type: 'string' }, price: { type: 'number' } } ) do |args, raw_data| - FunctionResult.new("Added #{args['item']} ($#{args['price']}) to your order") + SwaigFunctionResult.new("Added #{args['item']} ($#{args['price']}) to your order") .update_global_data('last_item_added' => args['item'], 'last_item_price' => args['price']) end @@ -511,7 +511,7 @@ agent.run ```java import com.signalwire.agents.AgentBase; -import com.signalwire.agents.FunctionResult; +import com.signalwire.agents.SwaigFunctionResult; public class OrderAgent { public static void main(String[] args) { @@ -534,7 +534,7 @@ public class OrderAgent { (fnArgs, rawData) -> { String item = (String) fnArgs.get("item"); double price = (double) fnArgs.get("price"); - return new FunctionResult("Added " + item + " to your order") + return new SwaigFunctionResult("Added " + item + " to your order") .updateGlobalData(Map.of("last_item_added", item, "last_item_price", price)); }); @@ -567,7 +567,7 @@ $agent->define_tool( parameters => { item => { type => 'string' }, price => { type => 'number' } }, handler => sub { my ($args, $raw_data) = @_; - return SignalWire::Agents::FunctionResult + return SignalWire::Agents::SwaigFunctionResult ->new("Added $args->{item} to your order") ->update_global_data({ last_item_added => $args->{item} }); }, @@ -599,7 +599,7 @@ int main() { {{"item", "string", "Item name"}, {"price", "number", "Item price"}}, [](auto args, auto raw_data) { auto item = args["item"].get(); - return FunctionResult("Added " + item + " to your order") + return SwaigFunctionResult("Added " + item + " to your order") .update_global_data({{"last_item_added", item}}); }); @@ -607,43 +607,6 @@ int main() { } ``` - -```php -addLanguage('English', 'en-US', 'rime.spore'); - -$agent->setGlobalData([ - 'store_name' => 'Pizza Palace', - 'order_items' => [], - 'order_total' => 0.0, -]); - -$agent->promptAddSection('Role', - 'You are an order assistant for ${global_data.store_name}. Help customers place their order.'); -$agent->promptAddSection('Current Order', - 'Items: ${global_data.order_items}\nTotal: $${global_data.order_total}'); - -$agent->setPostPrompt('Extract the final order as JSON: { "items": [], "total": 0.00 }'); - -$agent->defineTool('add_item', 'Add an item to the order', [ - 'type' => 'object', - 'properties' => [ - 'item' => ['type' => 'string', 'description' => 'Item name'], - 'price' => ['type' => 'number', 'description' => 'Item price'], - ], - 'required' => ['item', 'price'], -], function ($args, $rawData) { - return (new FunctionResult("Added {$args['item']} to your order")) - ->updateGlobalData(['last_item_added' => $args['item'], 'last_item_price' => $args['price']]); -}); - -$agent->run(); -``` - ```csharp using SignalWire.Agent; @@ -685,14 +648,51 @@ agent.Run(); ``` */} + +```php +addLanguage('English', 'en-US', 'rime.spore'); + +$agent->setGlobalData([ + 'store_name' => 'Pizza Palace', + 'order_items' => [], + 'order_total' => 0.0, +]); + +$agent->promptAddSection('Role', + 'You are an order assistant for ${global_data.store_name}. Help customers place their order.'); +$agent->promptAddSection('Current Order', + 'Items: ${global_data.order_items}\nTotal: $${global_data.order_total}'); + +$agent->setPostPrompt('Extract the final order as JSON: { "items": [], "total": 0.00 }'); + +$agent->defineTool('add_item', 'Add an item to the order', [ + 'type' => 'object', + 'properties' => [ + 'item' => ['type' => 'string', 'description' => 'Item name'], + 'price' => ['type' => 'number', 'description' => 'Item price'], + ], + 'required' => ['item', 'price'], +], function ($args, $rawData) { + return (new SwaigFunctionResult("Added {$args['item']} to your order")) + ->updateGlobalData(['last_item_added' => $args['item'], 'last_item_price' => $args['price']]); +}); + +$agent->run(); +``` + ### [DataMap][ref-datamap] Variable Access In DataMap functions, use variable substitution: ```python -from signalwire.core.data_map import DataMap -from signalwire.core.function_result import FunctionResult +from signalwire_agents.core.data_map import DataMap +from signalwire_agents.core.function_result import SwaigFunctionResult lookup_dm = ( DataMap("lookup_customer") @@ -703,7 +703,7 @@ lookup_dm = ( "https://api.example.com/customers/${enc:args.customer_id}" "?store=${enc:global_data.store_id}" ) - .output(FunctionResult( + .output(SwaigFunctionResult( "Customer: ${response.name}, Tier: ${response.tier}" )) ) @@ -715,9 +715,9 @@ lookup_dm = ( |--------|-------|---------| | `set_global_data()` | Agent | Merge data into global state | | `update_global_data()` | Agent | Update global state at runtime | -| `FunctionResult.update_global_data()` | Function | Update state from function | -| `FunctionResult.set_metadata()` | Function | Set function-scoped data | -| `FunctionResult.remove_metadata()` | Function | Remove function-scoped data | +| `SwaigFunctionResult.update_global_data()` | Function | Update state from function | +| `SwaigFunctionResult.set_metadata()` | Function | Set function-scoped data | +| `SwaigFunctionResult.remove_metadata()` | Function | Remove function-scoped data | | `set_post_prompt()` | Agent | Set post-call data extraction | | `set_post_prompt_url()` | Agent | Set webhook for post-prompt data | | `set_post_prompt_llm_params()` | Agent | Configure post-prompt model | @@ -725,12 +725,12 @@ lookup_dm = ( {/* **Naming conventions across languages:** -| Method (Python) | TypeScript | Go | Ruby | Java | Perl | C++ | PHP | C# | |-----------------|------------|-----|------|------|------|-----|-----|-----| | `set_global_data()` | `setGlobalData()` | `SetGlobalData()` | `set_global_data()` | `setGlobalData()` | `set_global_data()` | `set_global_data()` | `setGlobalData()` | `SetGlobalData()` | | `update_global_data()` | `updateGlobalData()` | `UpdateGlobalData()` | `update_global_data()` | `updateGlobalData()` | `update_global_data()` | `update_global_data()` | `updateGlobalData()` | `UpdateGlobalData()` | | `set_post_prompt()` | `setPostPrompt()` | `SetPostPrompt()` | `set_post_prompt()` | `setPostPrompt()` | `set_post_prompt()` | `set_post_prompt()` | `setPostPrompt()` | `SetPostPrompt()` | */} +| Method (Python) | TypeScript | Go | Ruby | Java | Perl | C++ | PHP | C# | ### Timeout and Disconnection Behavior diff --git a/fern/products/sdks/pages/guides/build-ai-agents/static-vs-dynamic.mdx b/fern/products/sdks/pages/guides/build-ai-agents/static-vs-dynamic.mdx index 07e130499..e5293192e 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/static-vs-dynamic.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/static-vs-dynamic.mdx @@ -34,7 +34,7 @@ Static agents have fixed configuration determined at instantiation time. ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class StaticSupportAgent(AgentBase): """Same behavior for all callers.""" @@ -67,7 +67,7 @@ class StaticSupportAgent(AgentBase): ) def get_store_hours(self, args, raw_data): - return FunctionResult( + return SwaigFunctionResult( "We're open Monday through Friday, 9 AM to 5 PM." ) @@ -79,12 +79,12 @@ if __name__ == "__main__": {/* ```typescript -import { AgentBase, FunctionResult } from 'signalwire-agents'; +import { AgentBase, SwaigFunctionResult } from 'signalwire-agents'; const agent = new AgentBase({ name: "static-support" }); agent.addLanguage({ name: 'English', code: 'en-US', voice: 'rime.spore' }); agent.promptAddSection('Role', 'You are a customer service agent for Acme Corp. ' + 'Help callers with general inquiries about our products.'); agent.promptAddSection('Guidelines', { bullets: ['Be helpful and professional', 'Answer questions about products', 'Transfer complex issues to support'] }); -agent.defineTool({ name: 'get_store_hours', description: 'Get store hours', parameters: {}, handler: async () => new FunctionResult("We're open Monday through Friday, 9 AM to 5 PM.") }); +agent.defineTool({ name: 'get_store_hours', description: 'Get store hours', parameters: {}, handler: async () => new SwaigFunctionResult("We're open Monday through Friday, 9 AM to 5 PM.") }); agent.run(); ``` @@ -107,7 +107,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' class StaticSupportAgent < AgentBase def initialize super(name: "static-support") @@ -163,18 +163,6 @@ int main() { } ``` - -```php -addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); -$agent->promptAddSection('Role', 'You are a customer service agent for Acme Corp. ' . 'Help callers with general inquiries about our products.'); -$agent->promptAddSection('Guidelines', bullets: ['Be helpful and professional', 'Answer questions about products', 'Transfer complex issues to support']); -$agent->defineTool('get_store_hours', 'Get store hours', [], function ($args, $raw) { return new FunctionResult("We're open Monday through Friday, 9 AM to 5 PM."); }); -$agent->run('0.0.0.0', 3000); -``` - ```csharp using SignalWire.Agent; using SignalWire.SWAIG; @@ -187,6 +175,18 @@ agent.Run(); ``` */} + +```php +addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); +$agent->promptAddSection('Role', 'You are a customer service agent for Acme Corp. ' . 'Help callers with general inquiries about our products.'); +$agent->promptAddSection('Guidelines', bullets: ['Be helpful and professional', 'Answer questions about products', 'Transfer complex issues to support']); +$agent->defineTool('get_store_hours', 'Get store hours', [], function ($args, $raw) { return new SwaigFunctionResult("We're open Monday through Friday, 9 AM to 5 PM."); }); +$agent->run('0.0.0.0', 3000); +``` + ### Dynamic Agents @@ -204,9 +204,9 @@ Dynamic agents customize their behavior based on the incoming request using the | Java | `void onSwmlRequest(Map requestData, String callbackPath)` | | Perl | `sub on_swml_request { my ($self, %args) = @_; ... }` | | C++ | `void on_swml_request(json request_data, std::string callback_path)` | -| PHP | `$agent->setDynamicConfigCallback(function($query) { ... })` | | C# | `agent.SetDynamicConfigCallback((queryParams, bodyParams, headers, agent) => { ... })` | */} +| PHP | `$agent->setDynamicConfigCallback(function($query) { ... })` | ```python def on_swml_request(self, request_data=None, callback_path=None, request=None): @@ -225,7 +225,7 @@ def on_swml_request(self, request_data=None, callback_path=None, request=None): #### Example: Dynamic Personalized Agent ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class DynamicPersonalizedAgent(AgentBase): """Customizes greeting based on caller.""" @@ -264,8 +264,8 @@ class DynamicPersonalizedAgent(AgentBase): def get_account_status(self, args, raw_data): if self._current_caller: - return FunctionResult(f"Account {self._current_caller['account']} is active. Tier: {self._current_caller['tier'].upper()}") - return FunctionResult("No account found. Would you like to create one?") + return SwaigFunctionResult(f"Account {self._current_caller['account']} is active. Tier: {self._current_caller['tier'].upper()}") + return SwaigFunctionResult("No account found. Would you like to create one?") if __name__ == "__main__": agent = DynamicPersonalizedAgent() @@ -323,13 +323,13 @@ class DynamicFunctionsAgent(AgentBase): self.define_tool(name="admin_report", description="Generate system report (admin only)", parameters={}, handler=self.admin_report) def get_info(self, args, raw_data): - return FunctionResult("General information...") + return SwaigFunctionResult("General information...") def admin_reset(self, args, raw_data): - return FunctionResult("System reset initiated.") + return SwaigFunctionResult("System reset initiated.") def admin_report(self, args, raw_data): - return FunctionResult("Report generated: All systems operational.") + return SwaigFunctionResult("Report generated: All systems operational.") ``` ### Multi-Tenant Applications diff --git a/fern/products/sdks/pages/guides/build-ai-agents/survey.mdx b/fern/products/sdks/pages/guides/build-ai-agents/survey.mdx index 8c5c4ab22..c918f4fa5 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/survey.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/survey.mdx @@ -11,7 +11,7 @@ SurveyAgent conducts automated surveys with different question types (rating, mu ```python -from signalwire.prefabs import SurveyAgent +from signalwire_agents.prefabs import SurveyAgent agent = SurveyAgent( survey_name="Customer Satisfaction Survey", @@ -78,7 +78,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::Prefabs::SurveyAgent.new( survey_name: "Customer Satisfaction Survey", @@ -142,6 +142,22 @@ int main() { } ``` + +```csharp +using SignalWire.Prefabs; + +var agent = new SurveyAgent(new AgentOptions { Name = "survey" }); +agent.SetQuestions(new List> +{ + new() { ["text"] = "How satisfied were you with our service?", ["type"] = "rating", ["scale"] = 5 }, + new() { ["text"] = "Would you recommend us to others?", ["type"] = "yes_no" }, + new() { ["text"] = "Any additional comments?", ["type"] = "open_ended", ["required"] = false }, +}); + +agent.Run(); +``` + +*/} ```php run(); ``` - -```csharp -using SignalWire.Prefabs; - -var agent = new SurveyAgent(new AgentOptions { Name = "survey" }); -agent.SetQuestions(new List> -{ - new() { ["text"] = "How satisfied were you with our service?", ["type"] = "rating", ["scale"] = 5 }, - new() { ["text"] = "Would you recommend us to others?", ["type"] = "yes_no" }, - new() { ["text"] = "Any additional comments?", ["type"] = "open_ended", ["required"] = false }, -}); - -agent.Run(); -``` - -*/} ### Question Types @@ -200,17 +200,17 @@ agent.Run(); | Language | Import | |----------|--------| -| Python | `from signalwire.prefabs import SurveyAgent` | +| Python | `from signalwire_agents.prefabs import SurveyAgent` | {/* | TypeScript | `import { SurveyAgent } from 'signalwire-agents'` | | Go | `"github.com/signalwire/signalwire-agents-go/pkg/prefabs"` | -| Ruby | `require 'signalwire'` then `SignalWireAgents::Prefabs::SurveyAgent` | +| Ruby | `require 'signalwire_agents'` then `SignalWireAgents::Prefabs::SurveyAgent` | | Java | `import com.signalwire.agents.prefabs.SurveyAgent` | | Perl | `use SignalWire::Agents::Prefabs::SurveyAgent` | | C++ | `#include ` | -| PHP | `use SignalWire\Prefabs\SurveyAgent` | | C# | `using SignalWire.Prefabs;` | */} +| PHP | `use SignalWire\Prefabs\SurveyAgent` | ### Constructor Parameters @@ -238,7 +238,7 @@ SurveyAgent provides these SWAIG functions automatically: | `log_response` | Record a validated response | -Survey handlers return `FunctionResult(string)` objects (not plain dicts). If extending SurveyAgent with custom handlers, always return a `FunctionResult`. +Survey handlers return `SwaigFunctionResult(string)` objects (not plain dicts). If extending SurveyAgent with custom handlers, always return a `SwaigFunctionResult`. ### Survey Flow @@ -252,7 +252,7 @@ Survey handlers return `FunctionResult(string)` objects (not plain dicts). If ex ```python #!/usr/bin/env python3 ## product_survey.py - Product feedback survey agent -from signalwire.prefabs import SurveyAgent +from signalwire_agents.prefabs import SurveyAgent agent = SurveyAgent( survey_name="Product Feedback Survey", diff --git a/fern/products/sdks/pages/guides/build-ai-agents/swaig.mdx b/fern/products/sdks/pages/guides/build-ai-agents/swaig.mdx index ad8fe8764..04ba489ad 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/swaig.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/swaig.mdx @@ -67,7 +67,7 @@ The most explicit way to register a function: ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class MyAgent(AgentBase): def __init__(self): @@ -91,7 +91,7 @@ class MyAgent(AgentBase): def get_balance(self, args, raw_data): account_id = args.get("account_id") - return FunctionResult(f"Account {account_id} has a balance of $150.00") + return SwaigFunctionResult(f"Account {account_id} has a balance of $150.00") ``` {/* @@ -104,7 +104,7 @@ agent.defineTool({ account_id: { type: 'string', description: 'The account ID to look up' }, }, handler: (args) => { - return new FunctionResult(`Account ${args.account_id} has a balance of $150.00`); + return new SwaigFunctionResult(`Account ${args.account_id} has a balance of $150.00`); }, }); ``` @@ -173,24 +173,6 @@ agent.define_tool("get_balance", "Get account balance for a customer", }); ``` - -```php -defineTool('get_balance', 'Get account balance for a customer', - ['type' => 'object', 'properties' => [ - 'account_id' => ['type' => 'string', 'description' => 'The account ID to look up'], - ], 'required' => ['account_id']], - function (array $args, array $rawData): FunctionResult { - return new FunctionResult("Account {$args['account_id']} has a balance of \$150.00"); - } -); -``` - ```csharp using SignalWire.Agent; @@ -223,13 +205,31 @@ agent.DefineTool( ``` */} + +```php +defineTool('get_balance', 'Get account balance for a customer', + ['type' => 'object', 'properties' => [ + 'account_id' => ['type' => 'string', 'description' => 'The account ID to look up'], + ], 'required' => ['account_id']], + function (array $args, array $rawData): FunctionResult { + return new FunctionResult("Account {$args['account_id']} has a balance of \$150.00"); + } +); +``` + #### Method 2: @[AgentBase][ref-agentbase].tool Decorator A cleaner approach using decorators: ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class MyAgent(AgentBase): def __init__(self): @@ -251,7 +251,7 @@ class MyAgent(AgentBase): ) def get_balance(self, args, raw_data): account_id = args.get("account_id") - return FunctionResult(f"Account {account_id} has a balance of $150.00") + return SwaigFunctionResult(f"Account {account_id} has a balance of $150.00") ``` #### Method 3: [DataMap][ref-datamap] (Serverless) @@ -259,7 +259,7 @@ class MyAgent(AgentBase): For direct API integration without code: ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -300,15 +300,15 @@ Every SWAIG function handler receives two arguments -- the parsed arguments and |----------|------------------| | Python | `def handler(self, args: dict, raw_data: dict)` | {/* -| TypeScript | `(args: Record, rawData: Record) => FunctionResult` | +| TypeScript | `(args: Record, rawData: Record) => SwaigFunctionResult` | | Go | `func(args map[string]any, rawData map[string]any) *swaig.FunctionResult` | | Ruby | `do \|args, raw_data\| ... end` (block with two hash params) | | Java | `(Map args, Map rawData) -> FunctionResult` | | Perl | `sub { my ($args, $raw_data) = @_; ... }` | | C++ | `[](const json& args, const json& raw) -> swaig::FunctionResult { ... }` | -| PHP | `function(array $args, array $rawData): FunctionResult { ... }` | | C# | `(Dictionary args, Dictionary raw) => FunctionResult` | */} +| PHP | `function(array $args, array $rawData): FunctionResult { ... }` | #### The raw_data Payload @@ -333,42 +333,42 @@ def my_function(self, args, raw_data): # Conversation context meta_data = raw_data.get("meta_data", {}) - return FunctionResult("Processed") + return SwaigFunctionResult("Processed") ``` -### FunctionResult +### SwaigFunctionResult Always return a [`FunctionResult`][ref-functionresult] from your handlers. The class name varies by language: | Language | FunctionResult Constructor | |----------|---------------------------| -| Python | `FunctionResult("text")` | +| Python | `SwaigFunctionResult("text")` | {/* -| TypeScript | `FunctionResult("text")` | +| TypeScript | `SwaigFunctionResult("text")` | | Go | `swaig.NewFunctionResult("text")` | | Ruby | `SignalWireAgents::Swaig::FunctionResult.new("text")` | | Java | `FunctionResult("text")` | | Perl | `SignalWire::Agents::SWAIG::FunctionResult->new("text")` | | C++ | `swaig::FunctionResult("text")` | -| PHP | `FunctionResult("text")` | | C# | `FunctionResult("text")` | */} +| PHP | `FunctionResult("text")` | ```python -from signalwire import FunctionResult +from signalwire_agents import SwaigFunctionResult def simple_response(self, args, raw_data): # Simple text response - AI will speak this - return FunctionResult("Your order has been placed successfully.") + return SwaigFunctionResult("Your order has been placed successfully.") def response_with_actions(self, args, raw_data): - result = FunctionResult("Transferring you now.") + result = SwaigFunctionResult("Transferring you now.") result.connect("+15551234567", final=True, from_addr="+15559876543") return result def response_with_data(self, args, raw_data): - result = FunctionResult("I've saved your preferences.") + result = SwaigFunctionResult("I've saved your preferences.") result.update_global_data({"user_preference": "email", "confirmed": True}) return result ``` @@ -377,14 +377,14 @@ def response_with_data(self, args, raw_data): ```typescript // Simple response -return new FunctionResult('Your order has been placed successfully.'); +return new SwaigFunctionResult('Your order has been placed successfully.'); // With transfer -return new FunctionResult('Transferring you now.') +return new SwaigFunctionResult('Transferring you now.') .connect('+15551234567', false, '+15559876543'); // With data -return new FunctionResult("I've saved your preferences.") +return new SwaigFunctionResult("I've saved your preferences.") .updateGlobalData({ user_preference: 'email', confirmed: true }); ``` @@ -469,25 +469,6 @@ result.update_global_data({{"user_preference", "email"}, {"confirmed", true}}); return result; ``` - -```php -connect('+15551234567', final: false, from: '+15559876543'); -return $result; - -// With data -$result = new FunctionResult("I've saved your preferences."); -$result->updateGlobalData(['user_preference' => 'email', 'confirmed' => true]); -return $result; -``` - ```csharp using SignalWire.SWAIG; @@ -507,6 +488,25 @@ return result; ``` */} + +```php +connect('+15551234567', final: false, from: '+15559876543'); +return $result; + +// With data +$result = new FunctionResult("I've saved your preferences."); +$result->updateGlobalData(['user_preference' => 'email', 'confirmed' => true]); +return $result; +``` + ### Common Actions @@ -687,16 +687,16 @@ def get_balance(self, args, raw_data): account_id = args.get("account_id") if not account_id: - return FunctionResult( + return SwaigFunctionResult( "I need an account ID to look up the balance. " "Could you provide your account number?" ) try: balance = self.lookup_balance(account_id) - return FunctionResult(f"Your current balance is ${balance:.2f}") + return SwaigFunctionResult(f"Your current balance is ${balance:.2f}") except AccountNotFoundError: - return FunctionResult( + return SwaigFunctionResult( "I couldn't find an account with that ID. " "Could you verify the account number?" ) diff --git a/fern/products/sdks/pages/guides/build-ai-agents/swml.mdx b/fern/products/sdks/pages/guides/build-ai-agents/swml.mdx index 60f2ba531..1ea49ba70 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/swml.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/swml.mdx @@ -239,7 +239,7 @@ You don't write SWML by hand. Your agent configuration becomes SWML automaticall ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -274,7 +274,7 @@ a.DefineTool(agent.ToolDefinition{Name: "get_help", Description: "Get help", Han ```ruby -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::AgentBase.new(name: 'my-agent') agent.add_language(name: 'English', code: 'en-US', voice: 'rime.spore') # -> languages @@ -314,19 +314,6 @@ a.set_params({{"end_of_speech_timeout", 500}}); // -> a.define_tool("get_help", "Get help", {}, [](const json& args, const json& raw) { ... }); // -> SWAIG ``` - -```php -addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); // -> languages -$agent->promptAddSection('Role', 'You are helpful.'); // -> prompt -$agent->addHints(['help', 'support']); // -> hints -$agent->setParams(['end_of_speech_timeout' => 500]); // -> params -$agent->defineTool('get_help', 'Get help', [], function ($args, $raw) { ... }); // -> SWAIG -``` - ```csharp using SignalWire.Agent; @@ -340,6 +327,19 @@ agent.DefineTool(name: "get_help", description: "Get help", parameters: new Dict ``` */} + +```php +addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore'); // -> languages +$agent->promptAddSection('Role', 'You are helpful.'); // -> prompt +$agent->addHints(['help', 'support']); // -> hints +$agent->setParams(['end_of_speech_timeout' => 500]); // -> params +$agent->defineTool('get_help', 'Get help', [], function ($args, $raw) { ... }); // -> SWAIG +``` + The above examples all produce identical SWML output. See the [Architecture][architecture] section for the full API comparison table. @@ -375,7 +375,7 @@ swaig-test my_agent.py --dump-swml --raw | jq '.' The SDK validates SWML against the official schema: -- Located at `signalwire/core/schema.json` +- Located at `signalwire_agents/core/schema.json` - Catches invalid configurations before sending to SignalWire - Provides helpful error messages diff --git a/fern/products/sdks/pages/guides/build-ai-agents/understanding-skills.mdx b/fern/products/sdks/pages/guides/build-ai-agents/understanding-skills.mdx index 79d1a4628..c415913f9 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/understanding-skills.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/understanding-skills.mdx @@ -51,9 +51,9 @@ The `add_skill()` method is available across all SDK languages: | Java | `agent.addSkill("weather", Map.of())` | | Perl | `$agent->add_skill('weather')` | | C++ | `agent.add_skill("weather")` | -| PHP | `$agent->addSkill('weather')` | | C# | `agent.AddSkill("weather")` | */} +| PHP | `$agent->addSkill('weather')` | ## Quick Start @@ -61,7 +61,7 @@ Add a skill in one line: ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -126,7 +126,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::AgentBase.new(name: 'my-agent') agent.add_language('English', 'en-US', 'rime.spore') @@ -211,27 +211,6 @@ int main() { } ``` - -```php -use SignalWire\Agent\AgentBase; - -$agent = new AgentBase(name: 'my-agent'); -$agent->addLanguage('English', 'en-US', 'rime.spore'); - -// Add datetime capability -$agent->addSkill('datetime'); - -// Add math capability -$agent->addSkill('math'); - -$agent->promptAddSection( - 'Role', - 'You are a helpful assistant that can tell time and do math.' -); - -$agent->run(); -``` - ```csharp using SignalWire.Agent; @@ -255,6 +234,27 @@ agent.Run(); ``` */} + +```php +use SignalWire\Agent\AgentBase; + +$agent = new AgentBase(name: 'my-agent'); +$agent->addLanguage('English', 'en-US', 'rime.spore'); + +// Add datetime capability +$agent->addSkill('datetime'); + +// Add math capability +$agent->addSkill('math'); + +$agent->promptAddSection( + 'Role', + 'You are a helpful assistant that can tell time and do math.' +); + +$agent->run(); +``` + ## Available Built-in Skills @@ -303,9 +303,9 @@ The `add_skill()` vs `define_tool()` distinction applies across all languages: | Java | `agent.addSkill("name", Map.of())` | `agent.defineTool(...)` | | Perl | `$agent->add_skill('name')` | `$agent->define_tool(...)` | | C++ | `agent.add_skill("name")` | `agent.define_tool(...)` | -| PHP | `$agent->addSkill('name')` | `$agent->defineTool(...)` | | C# | `agent.AddSkill("name")` | `agent.DefineTool(...)` | */} +| PHP | `$agent->addSkill('name')` | `$agent->defineTool(...)` | ## When to Use Skills @@ -333,7 +333,7 @@ The `add_skill()` vs `define_tool()` distinction applies across all languages: ```python #!/usr/bin/env python3 # assistant_agent.py - Agent with multiple skills -from signalwire import AgentBase +from signalwire_agents import AgentBase class AssistantAgent(AgentBase): def __init__(self): @@ -414,7 +414,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::AgentBase.new(name: 'assistant') agent.add_language('English', 'en-US', 'rime.spore') @@ -507,29 +507,6 @@ int main() { } ``` - -```php -use SignalWire\Agent\AgentBase; - -$agent = new AgentBase(name: 'assistant'); -$agent->addLanguage('English', 'en-US', 'rime.spore'); - -// Add multiple skills -$agent->addSkill('datetime'); -$agent->addSkill('math'); - -$agent->promptAddSection('Role', 'You are a helpful assistant named Alex.'); -$agent->promptAddSection('Capabilities', [ - 'body' => 'You can help with:', - 'bullets' => [ - 'Telling the current date and time', - 'Performing math calculations', - ], -]); - -$agent->run(); -``` - ```csharp using SignalWire.Agent; @@ -557,6 +534,29 @@ agent.Run(); ``` */} + +```php +use SignalWire\Agent\AgentBase; + +$agent = new AgentBase(name: 'assistant'); +$agent->addLanguage('English', 'en-US', 'rime.spore'); + +// Add multiple skills +$agent->addSkill('datetime'); +$agent->addSkill('math'); + +$agent->promptAddSection('Role', 'You are a helpful assistant named Alex.'); +$agent->promptAddSection('Capabilities', [ + 'body' => 'You can help with:', + 'bullets' => [ + 'Telling the current date and time', + 'Performing math calculations', + ], +]); + +$agent->run(); +``` + Let's start by understanding how skills work internally. @@ -598,7 +598,7 @@ Understanding this helps when debugging: a skill's function behaves exactly like Built-in skills live in the SDK: ```text -signalwire/ +signalwire_agents/ skills/ datetime/ __init__.py @@ -635,13 +635,13 @@ All skills inherit from [`SkillBase`][ref-skillbase]. The pattern is similar acr | Java | `class MySkill extends SkillBase { void setup(AgentBase agent) { ... } }` | | Perl | `package MySkill; use parent 'SkillBase'; sub setup { my ($self, $agent) = @_; ... }` | | C++ | `class MySkill : public skills::SkillBase { void setup(agent::AgentBase& agent) override { ... } };` | -| PHP | `class MySkill extends SignalWire\Skills\SkillBase { public function setup(AgentBase $agent): bool { ... } }` | | C# | `class MySkill : SkillBase { public override bool Setup(AgentBase agent) { ... } }` | */} +| PHP | `class MySkill extends SignalWire\Skills\SkillBase { public function setup(AgentBase $agent): bool { ... } }` | ```python -from signalwire.skills import SkillBase -from signalwire.core.function_result import FunctionResult +from signalwire_agents.skills import SkillBase +from signalwire_agents.core.function_result import SwaigFunctionResult class MySkill(SkillBase): # Required class attributes @@ -671,7 +671,7 @@ class MySkill(SkillBase): def my_handler(self, args, raw_data): """Handle function calls.""" - return FunctionResult("Result") + return SwaigFunctionResult("Result") ``` ## Skill Lifecycle @@ -750,8 +750,8 @@ Skills are discovered from multiple locations in priority order: | Priority | Source | Example | |----------|--------|---------| | 1 | Already registered skills (in memory) | - | -| 2 | Entry points (pip installed packages) | `entry_points={'signalwire.skills': ['my_skill = pkg:Skill']}` | -| 3 | Built-in skills directory | `signalwire/skills/` | +| 2 | Entry points (pip installed packages) | `entry_points={'signalwire_agents.skills': ['my_skill = pkg:Skill']}` | +| 3 | Built-in skills directory | `signalwire_agents/skills/` | | 4 | External paths | `skill_registry.add_skill_directory('/opt/custom_skills')` | | 5 | Environment variable paths | `SIGNALWIRE_SKILL_PATHS=/path1:/path2` | @@ -796,9 +796,9 @@ Usage across languages: | Java | `agent.addSkill("web_search", Map.of("tool_name", "search_news", "api_key", "KEY"))` | | Perl | `$agent->add_skill('web_search', { tool_name => 'search_news', api_key => 'KEY' })` | | C++ | `agent.add_skill("web_search", {{"tool_name", "search_news"}, {"api_key", "KEY"}})` | -| PHP | `$agent->addSkill('web_search', ['tool_name' => 'search_news', 'api_key' => 'KEY'])` | | C# | `agent.AddSkill("web_search", new Dictionary { ["tool_name"] = "search_news", ["api_key"] = "KEY" })` | */} +| PHP | `$agent->addSkill('web_search', ['tool_name' => 'search_news', 'api_key' => 'KEY'])` | ```python # Add two instances with different configs @@ -848,21 +848,21 @@ def search_handler(self, args, raw_data): ## Result Handling -Skill handlers return `FunctionResult` just like regular SWAIG functions: +Skill handlers return `SwaigFunctionResult` just like regular SWAIG functions: ```python def my_handler(self, args, raw_data): # Success case - return FunctionResult("The result is 42") + return SwaigFunctionResult("The result is 42") # With actions return ( - FunctionResult("Updated your preferences") + SwaigFunctionResult("Updated your preferences") .update_global_data({"preference": "value"}) ) # Error case - still return a result for the AI - return FunctionResult("I couldn't complete that request. Please try again.") + return SwaigFunctionResult("I couldn't complete that request. Please try again.") ``` The result goes back to the AI, which uses it to formulate a response to the user. @@ -875,26 +875,26 @@ Skills should handle errors gracefully and return meaningful messages: def api_handler(self, args, raw_data): try: result = self.call_external_api(args) - return FunctionResult(f"Result: {result}") + return SwaigFunctionResult(f"Result: {result}") except requests.Timeout: - return FunctionResult( + return SwaigFunctionResult( "The service is taking too long to respond. Please try again." ) except requests.RequestException as e: self.agent.log.error(f"API error: {e}") - return FunctionResult( + return SwaigFunctionResult( "I'm having trouble connecting to the service right now." ) except Exception as e: self.agent.log.error(f"Unexpected error: {e}") - return FunctionResult( + return SwaigFunctionResult( "Something went wrong. Please try again." ) ``` **Error handling principles:** -- Always return a `FunctionResult`, even on errors +- Always return a `SwaigFunctionResult`, even on errors - Make error messages user-friendly (the AI will relay them) - Log technical details for debugging - Don't expose internal errors to users @@ -926,5 +926,5 @@ Skills log warnings if required packages or environment variables are missing. C Built-in skills are in the SDK source. Examine them to understand how they work: ```bash pip show signalwire -# Find location, then look in signalwire/skills/ +# Find location, then look in signalwire_agents/skills/ ``` diff --git a/fern/products/sdks/pages/guides/build-ai-agents/voice-language.mdx b/fern/products/sdks/pages/guides/build-ai-agents/voice-language.mdx index 9c2b78d88..5c37b5862 100644 --- a/fern/products/sdks/pages/guides/build-ai-agents/voice-language.mdx +++ b/fern/products/sdks/pages/guides/build-ai-agents/voice-language.mdx @@ -38,12 +38,12 @@ The `add_language` method configures Text-to-Speech and Speech-to-Text for an ag | Java | `agent.addLanguage("English", "en-US", "rime.spore")` | | Perl | `$agent->add_language(name => 'English', code => 'en-US', voice => 'rime.spore')` | | C++ | `agent.add_language({"English", "en-US", "rime.spore"})` | -| PHP | `$agent->addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore')` | | C# | `agent.AddLanguage("English", "en-US", "rime.spore")` | */} +| PHP | `$agent->addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore')` | ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -189,9 +189,9 @@ Fix pronunciation of specific words: | Java | `agent.addPronunciation("ACME", "Ack-me")` | | Perl | `$agent->add_pronunciation(replace => 'ACME', with_text => 'Ack-me')` | | C++ | `agent.add_pronunciation("ACME", "Ack-me")` | -| PHP | `$agent->addPronunciation('ACME', 'Ack-me')` | | C# | `agent.AddPronunciation("ACME", "Ack-me")` | */} +| PHP | `$agent->addPronunciation('ACME', 'Ack-me')` | ```python class AgentWithPronunciation(AgentBase): @@ -374,7 +374,7 @@ Supported language codes: ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class FullyConfiguredVoiceAgent(AgentBase): def __init__(self): @@ -461,17 +461,6 @@ agent.set_pronunciations({{{"replace", "ACME"}, {"with", "Ack-me"}}, {{"replace" agent.prompt_add_section("Role", "You are a friendly customer service agent."); ``` - -```php -addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore', speechFillers: ['Um', 'Well', 'Let me see', 'So'], functionFillers: ['Let me look that up for you', 'One moment while I check', "I'm searching for that now", 'Just a second']); -$agent->addLanguage(name: 'Spanish', code: 'es-MX', voice: 'rime.luna', speechFillers: ['Pues', 'Bueno'], functionFillers: ['Un momento', 'Dejame ver']); -$agent->setPronunciations([['replace' => 'ACME', 'with' => 'Ack-me'], ['replace' => 'www', 'with' => 'dub dub dub'], ['replace' => '.com', 'with' => 'dot com'], ['replace' => '@', 'with' => 'at']]); -$agent->promptAddSection('Role', 'You are a friendly customer service agent.'); -``` - ```csharp using SignalWire.Agent; @@ -483,3 +472,14 @@ agent.PromptAddSection("Role", "You are a friendly customer service agent."); ``` */} + +```php +addLanguage(name: 'English', code: 'en-US', voice: 'rime.spore', speechFillers: ['Um', 'Well', 'Let me see', 'So'], functionFillers: ['Let me look that up for you', 'One moment while I check', "I'm searching for that now", 'Just a second']); +$agent->addLanguage(name: 'Spanish', code: 'es-MX', voice: 'rime.luna', speechFillers: ['Pues', 'Bueno'], functionFillers: ['Un momento', 'Dejame ver']); +$agent->setPronunciations([['replace' => 'ACME', 'with' => 'Ack-me'], ['replace' => 'www', 'with' => 'dub dub dub'], ['replace' => '.com', 'with' => 'dot com'], ['replace' => '@', 'with' => 'at']]); +$agent->promptAddSection('Role', 'You are a friendly customer service agent.'); +``` + diff --git a/fern/products/sdks/pages/guides/deploy/cgi-mode.mdx b/fern/products/sdks/pages/guides/deploy/cgi-mode.mdx index a83747e4c..2e325c188 100644 --- a/fern/products/sdks/pages/guides/deploy/cgi-mode.mdx +++ b/fern/products/sdks/pages/guides/deploy/cgi-mode.mdx @@ -24,9 +24,9 @@ CGI mode is primarily supported by the **Python** and **Perl** SDKs. Compiled la | Go | Not recommended | Compiled binary; use server mode | | Java | Not recommended | JVM startup too slow for CGI; use server or serverless | | C++ | Not recommended | Compiled binary; use server mode | -| PHP | Full | Natural CGI/FastCGI fit; works with PHP-FPM and the SDK | | C# | Not applicable | .NET uses Kestrel natively; use server or serverless mode | */} +| PHP | Full | Natural CGI/FastCGI fit; works with PHP-FPM and the SDK | **Benefits:** @@ -57,7 +57,7 @@ if os.getenv('GATEWAY_INTERFACE'): ```python ## agent.py - Basic CGI agent script (add #!/usr/bin/env python3 shebang) -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -85,19 +85,6 @@ $agent->prompt_add_section("Role", "You are a helpful assistant."); $agent->run; # Automatically detects CGI mode ``` - -```php -addLanguage('English', 'en-US', 'rime.spore'); -$agent->promptAddSection('Role', 'You are a helpful assistant.'); - -$agent->run(); // Automatically detects CGI/FastCGI mode -``` - > **Note:** .NET does not use CGI. The built-in Kestrel web server handles HTTP natively. For equivalent single-request handling in serverless contexts, use the serverless adapter pattern: @@ -114,6 +101,19 @@ agent.Run(); // Uses Kestrel web server natively ``` */} + +```php +addLanguage('English', 'en-US', 'rime.spore'); +$agent->promptAddSection('Role', 'You are a helpful assistant.'); + +$agent->run(); // Automatically detects CGI/FastCGI mode +``` + Make scripts executable: @@ -256,7 +256,7 @@ import os ## Add local packages directory sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'packages')) -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): diff --git a/fern/products/sdks/pages/guides/deploy/docker-kubernetes.mdx b/fern/products/sdks/pages/guides/deploy/docker-kubernetes.mdx index d730b7972..88a867c78 100644 --- a/fern/products/sdks/pages/guides/deploy/docker-kubernetes.mdx +++ b/fern/products/sdks/pages/guides/deploy/docker-kubernetes.mdx @@ -163,6 +163,29 @@ EXPOSE 3000 CMD ["./signalwire-agent"] ``` + +```dockerfile +## Multi-stage build +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /app +COPY *.csproj . +RUN dotnet restore +COPY . . +RUN dotnet publish -c Release -o out + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 + +RUN adduser --disabled-password appuser +WORKDIR /app +COPY --from=build /app/out . + +USER appuser +EXPOSE 3000 + +ENTRYPOINT ["dotnet", "MyAgent.dll"] +``` + +*/} ```dockerfile FROM php:8.1-cli @@ -188,35 +211,12 @@ EXPOSE 3000 CMD ["php", "agent.php"] ``` - -```dockerfile -## Multi-stage build -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build -WORKDIR /app -COPY *.csproj . -RUN dotnet restore -COPY . . -RUN dotnet publish -c Release -o out - -FROM mcr.microsoft.com/dotnet/aspnet:8.0 - -RUN adduser --disabled-password appuser -WORKDIR /app -COPY --from=build /app/out . - -USER appuser -EXPOSE 3000 - -ENTRYPOINT ["dotnet", "MyAgent.dll"] -``` - -*/} ## Application entry point (Python) ```python ## app.py -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -304,9 +304,9 @@ Kubernetes manifests are language-agnostic. The only difference is the Docker im | Java | `docker build -f Dockerfile.java -t your-registry/agent:latest .` | | Perl | `docker build -f Dockerfile.perl -t your-registry/agent:latest .` | | C++ | `docker build -f Dockerfile.cpp -t your-registry/agent:latest .` | -| PHP | `docker build -f Dockerfile.php -t your-registry/agent:latest .` | | C# | `docker build -f Dockerfile.cs -t your-registry/agent:latest .` | */} +| PHP | `docker build -f Dockerfile.php -t your-registry/agent:latest .` | ### Deployment manifest diff --git a/fern/products/sdks/pages/guides/deploy/local-development.mdx b/fern/products/sdks/pages/guides/deploy/local-development.mdx index 95d128b43..202427a28 100644 --- a/fern/products/sdks/pages/guides/deploy/local-development.mdx +++ b/fern/products/sdks/pages/guides/deploy/local-development.mdx @@ -21,9 +21,9 @@ max-toc-depth: 3 | Java | `agent.run("0.0.0.0", 8080)` | | Perl | `$agent->run(host => "0.0.0.0", port => 8080)` | | C++ | `agent.run("0.0.0.0", 8080)` | -| PHP | `$agent->run(host: '0.0.0.0', port: 8080)` | | C# | `agent.Run("0.0.0.0", 8080)` | */} +| PHP | `$agent->run(host: '0.0.0.0', port: 8080)` | ### Using serve() directly (Python) @@ -223,7 +223,7 @@ uvicorn dev:app --reload --port 3000 Use `AgentServer.serve_static_files()` to serve static files alongside your agents. This is useful for web dashboards, documentation, or any static content: ```python -from signalwire import AgentServer +from signalwire_agents import AgentServer from pathlib import Path # Create your agents diff --git a/fern/products/sdks/pages/guides/deploy/overview.mdx b/fern/products/sdks/pages/guides/deploy/overview.mdx index f08367b9b..d3b90a1f8 100644 --- a/fern/products/sdks/pages/guides/deploy/overview.mdx +++ b/fern/products/sdks/pages/guides/deploy/overview.mdx @@ -62,7 +62,7 @@ The SDK automatically detects your deployment environment: ```python #!/usr/bin/env python3 -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -106,7 +106,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::AgentBase.new(name: "my-agent") agent.add_language("English", "en-US", "rime.spore") @@ -157,18 +157,6 @@ int main() { } ``` - -```php -addLanguage('English', 'en-US', 'rime.spore'); -$agent->promptAddSection('Role', 'You are a helpful assistant.'); - -$agent->run(); -``` - ```csharp using SignalWire.Agent; @@ -181,6 +169,18 @@ agent.Run(); ``` */} + +```php +addLanguage('English', 'en-US', 'rime.spore'); +$agent->promptAddSection('Role', 'You are a helpful assistant.'); + +$agent->run(); +``` + The `run()` method automatically: @@ -202,8 +202,8 @@ The simplest way to run your agent locally: | Java | `java -jar my-agent.jar` or `mvn exec:java` | | Perl | `perl my_agent.pl` | | C++ | `./my_agent` (after compilation) | -| PHP | `php my_agent.php` | | C# | `dotnet run` | */} +| PHP | `php my_agent.php` | All languages default to `http://localhost:3000`. diff --git a/fern/products/sdks/pages/guides/deploy/production.mdx b/fern/products/sdks/pages/guides/deploy/production.mdx index 0be431351..86b933c4f 100644 --- a/fern/products/sdks/pages/guides/deploy/production.mdx +++ b/fern/products/sdks/pages/guides/deploy/production.mdx @@ -69,7 +69,7 @@ Create an entry point module: ```python #!/usr/bin/env python3 # my_agent.py -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -132,7 +132,7 @@ go build -o signalwire-agent . Use Puma for production: ```ruby -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::AgentBase.new(name: "my-agent") agent.add_language("English", "en-US", "rime.spore") @@ -213,29 +213,6 @@ cmake --build build --config Release ./build/signalwire-agent ``` - -Use PHP built-in server, nginx + PHP-FPM, or Apache + mod_php: - -```php -addLanguage('English', 'en-US', 'rime.spore'); -$agent->promptAddSection('Role', 'You are a helpful assistant.'); - -$agent->run(host: '0.0.0.0', port: 3000); -``` - -```bash -## Run with PHP built-in server -php agent.php - -## Or use nginx + PHP-FPM for production -## Configure PHP-FPM pool and nginx fastcgi_pass -``` - Use Kestrel (the built-in .NET web server): @@ -262,6 +239,29 @@ dotnet out/MyAgent.dll ``` */} + +Use PHP built-in server, nginx + PHP-FPM, or Apache + mod_php: + +```php +addLanguage('English', 'en-US', 'rime.spore'); +$agent->promptAddSection('Role', 'You are a helpful assistant.'); + +$agent->run(host: '0.0.0.0', port: 3000); +``` + +```bash +## Run with PHP built-in server +php agent.php + +## Or use nginx + PHP-FPM for production +## Configure PHP-FPM pool and nginx fastcgi_pass +``` + ## Systemd service @@ -277,9 +277,9 @@ Create `/etc/systemd/system/signalwire-agent.service`. Adjust `ExecStart` for yo | Java | `/usr/bin/java -jar /opt/agent/my-agent.jar` | | Perl | `/usr/local/bin/starman --workers 4 --port 3000 /opt/agent/app.psgi` | | C++ | `/opt/agent/signalwire-agent` | -| PHP | `/usr/bin/php /opt/agent/agent.php` | | C# | `/opt/agent/MyAgent` (self-contained) or `dotnet /opt/agent/MyAgent.dll` | */} +| PHP | `/usr/bin/php /opt/agent/agent.php` | ```ini [Unit] @@ -457,9 +457,9 @@ call_duration = Histogram('agent_call_duration_seconds', 'Call duration') | Java | Virtual threads scale automatically (Java 21+) | | Perl | Increase Starman workers (`--workers N`) | | C++ | Built-in thread pool; configure thread count | -| PHP | Use nginx + PHP-FPM with multiple workers (`pm.max_children`) | | C# | Kestrel scales with async I/O; increase thread pool or use multiple instances | */} +| PHP | Use nginx + PHP-FPM with multiple workers (`pm.max_children`) | - Use larger server instances - Optimize agent code and external calls diff --git a/fern/products/sdks/pages/guides/deploy/serverless.mdx b/fern/products/sdks/pages/guides/deploy/serverless.mdx index 4a73edc69..157980ac6 100644 --- a/fern/products/sdks/pages/guides/deploy/serverless.mdx +++ b/fern/products/sdks/pages/guides/deploy/serverless.mdx @@ -28,13 +28,13 @@ max-toc-depth: 3 | Java | Yes (Java runtime) | Yes (Java runtime) | Yes (Java runtime) | | Perl | No (use custom runtime) | No | No | | C++ | No (use custom runtime) | No | No | -| PHP | Yes (custom runtime via Bref) | Yes (custom runtime via Bref) | No | | C# | Yes (.NET runtime) | Yes (.NET runtime) | Yes (.NET runtime) | Python and TypeScript have the broadest serverless support. Go and Java have native Lambda runtimes. PHP can use Bref for Lambda and Cloud Functions. Ruby, Perl, and C++ require custom runtimes and are better suited to container or server deployments. */} +| PHP | Yes (custom runtime via Bref) | Yes (custom runtime via Bref) | No | **Benefits:** @@ -51,7 +51,7 @@ Python and TypeScript have the broadest serverless support. Go and Java have nat `handler.py`: ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class MyAgent(AgentBase): def __init__(self): @@ -76,7 +76,7 @@ class MyAgent(AgentBase): ) def say_hello(args, raw_data): name = args.get("name", "World") - return FunctionResult(f"Hello {name}!") + return SwaigFunctionResult(f"Hello {name}!") # Create agent instance outside handler for warm starts agent = MyAgent() @@ -91,7 +91,7 @@ def lambda_handler(event, context): `handler.ts`: ```typescript -import { AgentBase, FunctionResult } from 'signalwire-agents'; +import { AgentBase, SwaigFunctionResult } from 'signalwire-agents'; const agent = new AgentBase({ name: "my-agent" }); agent.addLanguage("English", "en-US", "rime.spore"); @@ -109,7 +109,7 @@ agent.defineTool({ }, handler: (args: any) => { const name = args.name || "World"; - return new FunctionResult(`Hello ${name}!`); + return new SwaigFunctionResult(`Hello ${name}!`); } }); @@ -137,12 +137,12 @@ func init() { a.PromptAddSection("Role", "You are a helpful assistant.") a.DefineTool("say_hello", "Say hello to a user", agent.ToolHandler( - func(args map[string]interface{}) *agent.FunctionResult { + func(args map[string]interface{}) *agent.SwaigFunctionResult { name, _ := args["name"].(string) if name == "" { name = "World" } - return agent.NewFunctionResult("Hello " + name + "!") + return agent.NewSwaigFunctionResult("Hello " + name + "!") }, )) } @@ -157,7 +157,7 @@ func main() { ```java import com.signalwire.agents.agent.AgentBase; -import com.signalwire.agents.agent.FunctionResult; +import com.signalwire.agents.agent.SwaigFunctionResult; import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.RequestHandler; @@ -171,7 +171,7 @@ public class Handler implements RequestHandler { agent.promptAddSection("Role", "You are a helpful assistant."); agent.defineTool("say_hello", "Say hello to a user", (args, rawData) -> { String name = args.getOrDefault("name", "World").toString(); - return new FunctionResult("Hello " + name + "!"); + return new SwaigFunctionResult("Hello " + name + "!"); }); } @@ -203,7 +203,7 @@ agent.DefineTool("say_hello", "Say hello to a user", new }, (args, rawData) => { var name = args.GetValueOrDefault("name", "World")?.ToString() ?? "World"; - return new FunctionResult($"Hello {name}!"); + return new SwaigFunctionResult($"Hello {name}!"); }); var handler = new LambdaAdapter(agent); @@ -257,7 +257,7 @@ functions: `main.py`: ```python -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class MyAgent(AgentBase): def __init__(self): @@ -282,7 +282,7 @@ class MyAgent(AgentBase): ) def say_hello(args, raw_data): name = args.get("name", "World") - return FunctionResult(f"Hello {name}!") + return SwaigFunctionResult(f"Hello {name}!") # Create agent instance outside handler for warm starts agent = MyAgent() @@ -297,7 +297,7 @@ def main(request): `index.ts`: ```typescript -import { AgentBase, FunctionResult } from 'signalwire-agents'; +import { AgentBase, SwaigFunctionResult } from 'signalwire-agents'; import { HttpFunction } from '@google-cloud/functions-framework'; const agent = new AgentBase({ name: "my-agent" }); @@ -315,7 +315,7 @@ agent.defineTool({ required: ["name"] }, handler: (args: any) => { - return new FunctionResult(`Hello ${args.name || "World"}!`); + return new SwaigFunctionResult(`Hello ${args.name || "World"}!`); } }); @@ -417,7 +417,7 @@ gcloud functions deploy signalwire-agent \ ```python import azure.functions as func -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class MyAgent(AgentBase): def __init__(self): @@ -442,7 +442,7 @@ class MyAgent(AgentBase): ) def say_hello(args, raw_data): name = args.get("name", "World") - return FunctionResult(f"Hello {name}!") + return SwaigFunctionResult(f"Hello {name}!") # Create agent instance outside handler for warm starts agent = MyAgent() @@ -458,7 +458,7 @@ def main(req: func.HttpRequest) -> func.HttpResponse: ```typescript import { app, HttpRequest, HttpResponseInit, InvocationContext } from "@azure/functions"; -import { AgentBase, FunctionResult } from 'signalwire-agents'; +import { AgentBase, SwaigFunctionResult } from 'signalwire-agents'; const agent = new AgentBase({ name: "my-agent" }); agent.addLanguage("English", "en-US", "rime.spore"); @@ -475,7 +475,7 @@ agent.defineTool({ required: ["name"] }, handler: (args: any) => { - return new FunctionResult(`Hello ${args.name || "World"}!`); + return new SwaigFunctionResult(`Hello ${args.name || "World"}!`); } }); @@ -658,7 +658,7 @@ agent.run(req, force_mode='azure_function') Deploy multiple agents with [AgentServer][ref-agentserver]: ```python -from signalwire import AgentBase, AgentServer +from signalwire_agents import AgentBase, AgentServer class SalesAgent(AgentBase): def __init__(self): diff --git a/fern/products/sdks/pages/guides/getting-started/dev-environment.mdx b/fern/products/sdks/pages/guides/getting-started/dev-environment.mdx index 535532fbe..4c646acc7 100644 --- a/fern/products/sdks/pages/guides/getting-started/dev-environment.mdx +++ b/fern/products/sdks/pages/guides/getting-started/dev-environment.mdx @@ -136,22 +136,6 @@ my-agent-project/ - - -```text -my-agent-project/ -├── vendor/ # Composer dependencies -├── src/ -│ └── Agents/ -│ ├── CustomerService.php -│ └── SupportAgent.php -├── .env -├── .gitignore -├── composer.json -└── main.php # Entry point -``` - - @@ -168,6 +152,22 @@ my-agent-project/ */} + + +```text +my-agent-project/ +├── vendor/ # Composer dependencies +├── src/ +│ └── Agents/ +│ ├── CustomerService.php +│ └── SupportAgent.php +├── .env +├── .gitignore +├── composer.json +└── main.php # Entry point +``` + + ### Create the Project @@ -386,7 +386,7 @@ Create `.vscode/launch.json` for debugging: "name": "Test Agent with swaig-test", "type": "python", "request": "launch", - "module": "signalwire.cli.test_swaig", + "module": "signalwire_agents.cli.test_swaig", "args": ["${file}", "--dump-swml"], "console": "integratedTerminal" } @@ -464,7 +464,7 @@ A production-ready customer service agent template. """ import os -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class CustomerServiceAgent(AgentBase): """Customer service voice AI agent.""" @@ -546,13 +546,13 @@ class CustomerServiceAgent(AgentBase): identifier = args.get("identifier", "") # In production, query your database here - return FunctionResult( + return SwaigFunctionResult( f"Found account for {identifier}: Status is Active, Balance is $0.00" ) def transfer_to_human(self, args, raw_data): """Transfer to human support.""" - return FunctionResult( + return SwaigFunctionResult( "Transferring you to a human representative now." ).connect("+15551234567", final=True, from_addr="+15559876543") diff --git a/fern/products/sdks/pages/guides/getting-started/installation.mdx b/fern/products/sdks/pages/guides/getting-started/installation.mdx index f099b9176..8651bdadf 100644 --- a/fern/products/sdks/pages/guides/getting-started/installation.mdx +++ b/fern/products/sdks/pages/guides/getting-started/installation.mdx @@ -18,9 +18,9 @@ max-toc-depth: 3 | Java | 21+ | Gradle/Maven | Linux, macOS, Windows | | Perl | 5.26+ | cpanm | Linux, macOS, Windows | | C++ | GCC 9+/Clang 10+ (C++17) | CMake 3.16+ | Linux, macOS | -| PHP | 8.1+ | Composer | Linux, macOS, Windows | | C# | .NET 8+ | NuGet/dotnet CLI | Linux, macOS, Windows | */} +| PHP | 8.1+ | Composer | Linux, macOS, Windows | ## Basic Installation @@ -42,7 +42,7 @@ go get github.com/signalwire/signalwire-agents-go ```bash -gem install signalwire +gem install signalwire_agents ``` @@ -80,11 +80,6 @@ cd signalwire-agents-cpp mkdir build && cd build && cmake .. && make ``` - -```bash -composer require signalwire/agents -``` - ```bash dotnet new console -n my-agent-project @@ -93,12 +88,17 @@ dotnet add package SignalWire.Sdk ``` */} + +```bash +composer require signalwire/agents +``` + ## Verify Installation ```bash -python -c "from signalwire import AgentBase; print('SDK installed successfully!')" +python -c "from signalwire_agents import AgentBase; print('SDK installed successfully!')" ``` {/* @@ -114,7 +114,7 @@ go run -e 'package main; import _ "github.com/signalwire/signalwire-agents-go/pk ```bash -ruby -e "require 'signalwire'; puts 'SDK installed successfully!'" +ruby -e "require 'signalwire_agents'; puts 'SDK installed successfully!'" ``` @@ -132,17 +132,17 @@ perl -e "use SignalWire::Agents::Agent::AgentBase; print \"SDK installed success cd build && ./run_tests ``` - -```bash -php -r "require 'vendor/autoload.php'; use SignalWire\Agent\AgentBase; echo \"SDK installed successfully!\n\";" -``` - ```bash dotnet run --project my-agent-project ``` */} + +```bash +php -r "require 'vendor/autoload.php'; use SignalWire\Agent\AgentBase; echo \"SDK installed successfully!\n\";" +``` + ## Installation Extras (Python) @@ -240,7 +240,7 @@ def main(): # Check core import try: - from signalwire import AgentBase + from signalwire_agents import AgentBase print("[OK] Core SDK: AgentBase imported successfully") except ImportError as e: print(f"[FAIL] Core SDK: Failed to import AgentBase - {e}") @@ -248,22 +248,22 @@ def main(): # Check SWAIG function support try: - from signalwire import FunctionResult - print("[OK] SWAIG: FunctionResult imported successfully") + from signalwire_agents import SwaigFunctionResult + print("[OK] SWAIG: SwaigFunctionResult imported successfully") except ImportError as e: - print(f"[FAIL] SWAIG: Failed to import FunctionResult - {e}") + print(f"[FAIL] SWAIG: Failed to import SwaigFunctionResult - {e}") return False # Check prefabs try: - from signalwire.prefabs import InfoGathererAgent + from signalwire_agents.prefabs import InfoGathererAgent print("[OK] Prefabs: InfoGathererAgent imported successfully") except ImportError as e: print(f"[FAIL] Prefabs: Failed to import - {e}") # Check search (optional) try: - from signalwire.search import SearchEngine + from signalwire_agents.search import SearchEngine print("[OK] Search: SearchEngine available") except ImportError: print("[SKIP] Search: Not installed (optional)") @@ -289,7 +289,7 @@ Expected output: Checking SignalWire Agents SDK installation... [OK] Core SDK: AgentBase imported successfully -[OK] SWAIG: FunctionResult imported successfully +[OK] SWAIG: SwaigFunctionResult imported successfully [OK] Prefabs: InfoGathererAgent imported successfully [SKIP] Search: Not installed (optional) @@ -304,7 +304,7 @@ Installation verification complete! | Problem | Cause | Solution | |---------|-------|----------| -| `ModuleNotFoundError: No module named 'signalwire'` | Package not installed | Run `pip install signalwire` | +| `ModuleNotFoundError: No module named 'signalwire_agents'` | Package not installed | Run `pip install signalwire` | | `pip: command not found` | pip not in PATH | Use `python -m pip install signalwire` | | Permission errors | Installing globally without sudo | Use virtual environment or `pip install --user` | | Old pip version | pip can't resolve dependencies | Run `pip install --upgrade pip` | diff --git a/fern/products/sdks/pages/guides/getting-started/overview.mdx b/fern/products/sdks/pages/guides/getting-started/overview.mdx index 5cc69f0ca..291826a90 100644 --- a/fern/products/sdks/pages/guides/getting-started/overview.mdx +++ b/fern/products/sdks/pages/guides/getting-started/overview.mdx @@ -36,9 +36,9 @@ Before starting, ensure you have the following: | Java | 21+ | Gradle/Maven | | Perl | 5.26+ | cpanm | | C++ | C++17 compiler | CMake | -| PHP | 8.1+ | Composer | | C# | .NET 8+ | NuGet/dotnet CLI | */} +| PHP | 8.1+ | Composer | You'll also need: @@ -106,7 +106,7 @@ An **Agent** is your voice AI application. It's a class that: ```python -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyAgent(AgentBase): def __init__(self): @@ -133,7 +133,7 @@ a := agent.NewAgentBase(agent.WithName("my-agent")) ```ruby -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::AgentBase.new(name: 'my-agent') # Configure your agent here @@ -164,15 +164,6 @@ agent::AgentBase agent("my-agent"); // Configure your agent here ``` - -```php -require 'vendor/autoload.php'; -use SignalWire\Agent\AgentBase; - -$agent = new AgentBase(name: 'my-agent'); -// Configure your agent here -``` - ```csharp using SignalWire.Agent; @@ -182,6 +173,15 @@ var agent = new AgentBase(new AgentOptions { Name = "my-agent" }); ``` */} + +```php +require 'vendor/autoload.php'; +use SignalWire\Agent\AgentBase; + +$agent = new AgentBase(name: 'my-agent'); +// Configure your agent here +``` + ### SWML (SignalWire Markup Language) @@ -212,7 +212,7 @@ var agent = new AgentBase(new AgentOptions { Name = "my-agent" }); def lookup_customer(args, raw_data=None): phone_number = args.get("phone_number", "") customer = database.find(phone_number) - return FunctionResult( + return SwaigFunctionResult( f"Customer: {customer.name}, Account: {customer.id}" ) ``` @@ -228,7 +228,7 @@ agent.defineTool({ }, handler: (args) => { const customer = database.find(args.phone_number); - return new FunctionResult( + return new SwaigFunctionResult( `Customer: ${customer.name}, Account: ${customer.id}` ); }, diff --git a/fern/products/sdks/pages/guides/getting-started/quickstart.mdx b/fern/products/sdks/pages/guides/getting-started/quickstart.mdx index b4b9f0e02..5aa2847c4 100644 --- a/fern/products/sdks/pages/guides/getting-started/quickstart.mdx +++ b/fern/products/sdks/pages/guides/getting-started/quickstart.mdx @@ -25,7 +25,7 @@ My First SignalWire Agent A simple voice AI agent that greets callers and has conversations. """ -from signalwire import AgentBase +from signalwire_agents import AgentBase class MyFirstAgent(AgentBase): def __init__(self): @@ -143,7 +143,7 @@ func main() { ```ruby #!/usr/bin/env ruby # my_first_agent.rb - A simple voice AI agent -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::AgentBase.new(name: 'my-first-agent') @@ -275,6 +275,39 @@ int main() { + + + +`my_first_agent.cs` + +```csharp +// my_first_agent.cs - A simple voice AI agent +using SignalWire.Agent; + +var agent = new AgentBase(new AgentOptions { Name = "my-first-agent" }); + +agent.AddLanguage("English", "en-US", "rime.spore"); + +agent.PromptAddSection("Role", + "You are a friendly and helpful assistant. Greet the caller warmly " + + "and help them with any questions they have. Keep responses concise " + + "and conversational."); + +agent.PromptAddSection("Guidelines", "Follow these rules:", new List +{ + "Be friendly and professional", + "Keep responses brief (1-2 sentences when possible)", + "If you don't know something, say so honestly", + "End conversations politely when the caller is done", +}); + +Console.WriteLine("Starting My First Agent..."); +Console.WriteLine("Server running at: http://localhost:3000"); +agent.Run(); +``` + + +*/} `my_first_agent.php` @@ -310,39 +343,6 @@ $agent->run(); - - -`my_first_agent.cs` - -```csharp -// my_first_agent.cs - A simple voice AI agent -using SignalWire.Agent; - -var agent = new AgentBase(new AgentOptions { Name = "my-first-agent" }); - -agent.AddLanguage("English", "en-US", "rime.spore"); - -agent.PromptAddSection("Role", - "You are a friendly and helpful assistant. Greet the caller warmly " - + "and help them with any questions they have. Keep responses concise " - + "and conversational."); - -agent.PromptAddSection("Guidelines", "Follow these rules:", new List -{ - "Be friendly and professional", - "Keep responses brief (1-2 sentences when possible)", - "If you don't know something, say so honestly", - "End conversations politely when the caller is done", -}); - -Console.WriteLine("Starting My First Agent..."); -Console.WriteLine("Server running at: http://localhost:3000"); -agent.Run(); -``` - - -*/} - ### Run the Agent | Language | Command | @@ -354,10 +354,10 @@ agent.Run(); | Ruby | `ruby my_first_agent.rb` | | Java | `javac MyFirstAgent.java && java MyFirstAgent` | | Perl | `perl my_first_agent.pl` | -| C++ | `g++ -std=c++17 my_first_agent.cpp -lsignalwire -o my_first_agent && ./my_first_agent` | -| PHP | `php my_first_agent.php` | +| C++ | `g++ -std=c++17 my_first_agent.cpp -lsignalwire_agents -o my_first_agent && ./my_first_agent` | | C# | `dotnet run` | */} +| PHP | `php my_first_agent.php` | You'll see output like: @@ -449,7 +449,7 @@ Let's add a function the AI can call: My First SignalWire Agent - With Custom Function """ -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class MyFirstAgent(AgentBase): def __init__(self): @@ -482,7 +482,7 @@ class MyFirstAgent(AgentBase): "What's a programmer's favorite hangout spot? Foo Bar!", ] joke = random.choice(jokes) - return FunctionResult(f"Here's a joke: {joke}") + return SwaigFunctionResult(f"Here's a joke: {joke}") if __name__ == "__main__": agent = MyFirstAgent() @@ -498,7 +498,7 @@ if __name__ == "__main__": ```typescript #!/usr/bin/env npx tsx // my_first_agent_with_function.ts - Agent with custom function -import { AgentBase, FunctionResult } from 'signalwire-agents'; +import { AgentBase, SwaigFunctionResult } from 'signalwire-agents'; const agent = new AgentBase({ name: 'my-first-agent' }); agent.addLanguage({ name: 'English', code: 'en-US', voice: 'rime.spore' }); @@ -518,7 +518,7 @@ agent.defineTool({ 'Why did the Python programmer need glasses? Because they couldn\'t C!', 'What\'s a programmer\'s favorite hangout spot? Foo Bar!', ]; - return new FunctionResult(`Here's a joke: ${jokes[Math.floor(Math.random() * jokes.length)]}`); + return new SwaigFunctionResult(`Here's a joke: ${jokes[Math.floor(Math.random() * jokes.length)]}`); }, }); @@ -573,7 +573,7 @@ func main() { ```ruby #!/usr/bin/env ruby # my_first_agent_with_function.rb - Agent with custom function -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::AgentBase.new(name: 'my-first-agent') agent.add_language(name: 'English', code: 'en-US', voice: 'rime.spore') @@ -712,38 +712,6 @@ int main() { - - -```php -addLanguage('English', 'en-US', 'rime.spore'); - -$agent->promptAddSection('Role', - 'You are a friendly assistant who can tell jokes. ' - . 'When someone asks for a joke, use your tell_joke function.'); - -$agent->defineTool('tell_joke', 'Tell a joke to the caller', - ['type' => 'object', 'properties' => new \stdClass()], - function ($args, $raw) { - $jokes = [ - 'Why do programmers prefer dark mode? Because light attracts bugs!', - "Why did the Python programmer need glasses? Because they couldn't C!", - "What's a programmer's favorite hangout spot? Foo Bar!", - ]; - return new FunctionResult("Here's a joke: " . $jokes[array_rand($jokes)]); - }); - -echo "Starting My First Agent (with jokes!)...\n"; -$agent->run(); -``` - - @@ -780,6 +748,38 @@ agent.Run(); */} + + +```php +addLanguage('English', 'en-US', 'rime.spore'); + +$agent->promptAddSection('Role', + 'You are a friendly assistant who can tell jokes. ' + . 'When someone asks for a joke, use your tell_joke function.'); + +$agent->defineTool('tell_joke', 'Tell a joke to the caller', + ['type' => 'object', 'properties' => new \stdClass()], + function ($args, $raw) { + $jokes = [ + 'Why do programmers prefer dark mode? Because light attracts bugs!', + "Why did the Python programmer need glasses? Because they couldn't C!", + "What's a programmer's favorite hangout spot? Foo Bar!", + ]; + return new FunctionResult("Here's a joke: " . $jokes[array_rand($jokes)]); + }); + +echo "Starting My First Agent (with jokes!)...\n"; +$agent->run(); +``` + + Now when a caller asks for a joke, the AI will call your `tell_joke` function! @@ -830,7 +830,7 @@ Complete First Agent Example Demonstrates: voice config, AI parameters, prompt sections, custom functions, speech hints. """ -from signalwire import AgentBase, FunctionResult +from signalwire_agents import AgentBase, SwaigFunctionResult class CompleteFirstAgent(AgentBase): def __init__(self): @@ -897,7 +897,7 @@ class CompleteFirstAgent(AgentBase): """Return the current time.""" from datetime import datetime now = datetime.now() - return FunctionResult(f"The current time is {now.strftime('%I:%M %p')}") + return SwaigFunctionResult(f"The current time is {now.strftime('%I:%M %p')}") def tell_joke(self, args, raw_data): """Return a random joke.""" @@ -907,7 +907,7 @@ class CompleteFirstAgent(AgentBase): "Why did the developer go broke? Because they used up all their cache!", "There are only 10 types of people: those who understand binary and those who don't.", ] - return FunctionResult(random.choice(jokes)) + return SwaigFunctionResult(random.choice(jokes)) if __name__ == "__main__": agent = CompleteFirstAgent() @@ -922,7 +922,7 @@ if __name__ == "__main__": ```typescript #!/usr/bin/env npx tsx // complete_first_agent.ts - Complete agent example with multiple features -import { AgentBase, FunctionResult } from 'signalwire-agents'; +import { AgentBase, SwaigFunctionResult } from 'signalwire-agents'; const agent = new AgentBase({ name: 'complete-agent', autoAnswer: true, recordCall: false }); @@ -945,7 +945,7 @@ agent.defineTool({ name: 'get_current_time', description: 'Get the current time', parameters: {}, - handler: () => new FunctionResult(`The current time is ${new Date().toLocaleTimeString()}`), + handler: () => new SwaigFunctionResult(`The current time is ${new Date().toLocaleTimeString()}`), }); agent.defineTool({ @@ -958,7 +958,7 @@ agent.defineTool({ 'Why did the developer go broke? Because they used up all their cache!', 'There are only 10 types of people: those who understand binary and those who don\'t.', ]; - return new FunctionResult(jokes[Math.floor(Math.random() * jokes.length)]); + return new SwaigFunctionResult(jokes[Math.floor(Math.random() * jokes.length)]); }, }); @@ -1029,7 +1029,7 @@ func main() { ```ruby #!/usr/bin/env ruby # complete_first_agent.rb - Complete agent example with multiple features -require 'signalwire' +require 'signalwire_agents' agent = SignalWireAgents::AgentBase.new(name: 'complete-agent', auto_answer: true, record_call: false) @@ -1207,49 +1207,6 @@ int main() { - - -```php -addLanguage('English', 'en-US', 'rime.spore'); -$agent->setParams(['end_of_speech_timeout' => 500, 'attention_timeout' => 15000]); -$agent->addHints(['SignalWire', 'SWML', 'AI agent']); - -$agent->promptAddSection('Identity', 'You are Alex, a helpful AI assistant created by SignalWire.'); -$agent->promptAddSection('Capabilities', 'You can help callers with:', bullets: [ - 'Answering general questions', 'Telling jokes', 'Providing the current time', 'Basic conversation', -]); -$agent->promptAddSection('Style', 'Keep responses brief and friendly. Use a conversational tone.'); - -$agent->defineTool('get_current_time', 'Get the current time', - ['type' => 'object', 'properties' => new \stdClass()], - function ($args, $raw) { - return new FunctionResult('The current time is ' . date('g:i A')); - }); - -$agent->defineTool('tell_joke', 'Tell a random joke', - ['type' => 'object', 'properties' => new \stdClass()], - function ($args, $raw) { - $jokes = [ - 'Why do programmers prefer dark mode? Because light attracts bugs!', - 'Why did the developer go broke? Because they used up all their cache!', - "There are only 10 types of people: those who understand binary and those who don't.", - ]; - return new FunctionResult($jokes[array_rand($jokes)]); - }); - -echo "Complete First Agent running at http://localhost:3000\n"; -$agent->run(); -``` - - @@ -1310,6 +1267,49 @@ agent.Run(); */} + + +```php +addLanguage('English', 'en-US', 'rime.spore'); +$agent->setParams(['end_of_speech_timeout' => 500, 'attention_timeout' => 15000]); +$agent->addHints(['SignalWire', 'SWML', 'AI agent']); + +$agent->promptAddSection('Identity', 'You are Alex, a helpful AI assistant created by SignalWire.'); +$agent->promptAddSection('Capabilities', 'You can help callers with:', bullets: [ + 'Answering general questions', 'Telling jokes', 'Providing the current time', 'Basic conversation', +]); +$agent->promptAddSection('Style', 'Keep responses brief and friendly. Use a conversational tone.'); + +$agent->defineTool('get_current_time', 'Get the current time', + ['type' => 'object', 'properties' => new \stdClass()], + function ($args, $raw) { + return new FunctionResult('The current time is ' . date('g:i A')); + }); + +$agent->defineTool('tell_joke', 'Tell a random joke', + ['type' => 'object', 'properties' => new \stdClass()], + function ($args, $raw) { + $jokes = [ + 'Why do programmers prefer dark mode? Because light attracts bugs!', + 'Why did the developer go broke? Because they used up all their cache!', + "There are only 10 types of people: those who understand binary and those who don't.", + ]; + return new FunctionResult($jokes[array_rand($jokes)]); + }); + +echo "Complete First Agent running at http://localhost:3000\n"; +$agent->run(); +``` + + ### Next Steps diff --git a/fern/products/sdks/pages/guides/make-and-receive-calls/overview.mdx b/fern/products/sdks/pages/guides/make-and-receive-calls/overview.mdx index 243500eae..4671c9410 100644 --- a/fern/products/sdks/pages/guides/make-and-receive-calls/overview.mdx +++ b/fern/products/sdks/pages/guides/make-and-receive-calls/overview.mdx @@ -46,7 +46,7 @@ It requires the `websockets` library (installed automatically as a dependency). #!/usr/bin/env python3 """Minimal RELAY example: answer and play a greeting.""" -from signalwire.relay import RelayClient +from signalwire_agents.relay import RelayClient client = RelayClient( project="your-project-id", @@ -114,7 +114,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' client = RelayClient.new( project_id: 'your-project-id', @@ -200,27 +200,6 @@ int main() { } ``` - -```php -onCall(function ($call) { - $call->answer(); - $call->play('https://example.com/hello.mp3'); - $call->hangup(); -}); - -$client->run(); -``` - ```csharp using SignalWire.Relay; @@ -244,6 +223,27 @@ await client.Connect(); ``` */} + +```php +onCall(function ($call) { + $call->answer(); + $call->play('https://example.com/hello.mp3'); + $call->hangup(); +}); + +$client->run(); +``` + ### Authentication @@ -261,9 +261,9 @@ The RELAY client supports two authentication methods: | Java | `RelayClient.builder().projectId("...").apiToken("...").host("...").build()` | | Perl | `RelayClient->new(project_id => '...', api_token => '...', host => '...')` | | C++ | `relay::Client client("project_id", "api_token", "host")` | -| PHP | `new Client(project: '...', token: '...', host: '...')` | | C# | `new RelayClient(new RelayClientOptions { Project = "...", Token = "...", Host = "..." })` | */} +| PHP | `new Client(project: '...', token: '...', host: '...')` | ```python client = RelayClient( @@ -342,7 +342,7 @@ Register a handler with the `@client.on_call` decorator: #!/usr/bin/env python3 """Handle inbound calls with RELAY.""" -from signalwire.relay import RelayClient +from signalwire_agents.relay import RelayClient client = RelayClient(contexts=["ivr"]) @@ -400,7 +400,7 @@ Use `client.dial()` to initiate outbound calls: """Make an outbound call with RELAY.""" import asyncio -from signalwire.relay import RelayClient +from signalwire_agents.relay import RelayClient client = RelayClient(contexts=["default"]) @@ -458,7 +458,6 @@ Key call control methods across languages: | Connect | `await call.connect(devices)` | {/* -| Method | Ruby | Java | Perl | C++ | PHP | C# | |--------|------|------|------|-----|-----|-----| | Answer | `call.answer` | `call.answer()` | `$call->answer` | `call.answer()` | `$call->answer()` | `await call.Answer()` | | Play TTS | `call.play([{type: 'tts', text: 'Hello'}])` | `call.play(List.of(...))` | `$call->play([{type=>'tts',text=>'Hello'}])` | `call.play({{"type","tts"},{"text","Hello"}})` | `$call->play('https://...')` | `await call.PlayTts("Hello")` | @@ -466,6 +465,7 @@ Key call control methods across languages: | Hang up | `call.hangup` | `call.hangup()` | `$call->hangup` | `call.hangup()` | `$call->hangup()` | `await call.Hangup()` | | Connect | `call.connect(devices)` | `call.connect(devices)` | `$call->connect($devices)` | `call.connect(devices)` | `$call->connect($devices)` | `await call.Connect(devices)` | */} +| Method | Ruby | Java | Perl | C++ | PHP | C# | #### Audio Playback @@ -646,9 +646,9 @@ The RELAY client supports sending and receiving SMS/MMS messages. | Java | `client.sendMessage("+155...", "+155...", "Hello")` | | Perl | `$client->send_message(to_number => '+155...', from_number => '+155...', body => 'Hello')` | | C++ | `client.send_message("+155...", "+155...", "Hello")` | -| PHP | `$client->sendMessage(toNumber: '+155...', fromNumber: '+155...', body: 'Hello')` | | C# | `await client.SendMessage(toNumber: "+155...", fromNumber: "+155...", body: "Hello")` | */} +| PHP | `$client->sendMessage(toNumber: '+155...', fromNumber: '+155...', body: 'Hello')` | #### Sending Messages @@ -706,7 +706,7 @@ The [`Message`][ref-message] object provides: Register per-call event listeners for fine-grained control: ```python -from signalwire.relay import EVENT_CALL_STATE, EVENT_CALL_PLAY +from signalwire_agents.relay import EVENT_CALL_STATE, EVENT_CALL_PLAY @client.on_call async def handle_call(call): @@ -758,7 +758,7 @@ The client handles errors gracefully — server errors from call methods return For explicit error handling: ```python -from signalwire.relay import RelayClient, RelayError +from signalwire_agents.relay import RelayClient, RelayError try: call = await client.dial(devices=[[{...}]]) @@ -774,7 +774,7 @@ except RelayError as e: #!/usr/bin/env python3 """Complete IVR system with RELAY.""" -from signalwire.relay import RelayClient, EVENT_CALL_STATE +from signalwire_agents.relay import RelayClient, EVENT_CALL_STATE client = RelayClient(contexts=["main-ivr"]) diff --git a/fern/products/sdks/pages/guides/manage-resources/mapping-numbers.mdx b/fern/products/sdks/pages/guides/manage-resources/mapping-numbers.mdx index b8cc7d387..f13460640 100644 --- a/fern/products/sdks/pages/guides/manage-resources/mapping-numbers.mdx +++ b/fern/products/sdks/pages/guides/manage-resources/mapping-numbers.mdx @@ -138,11 +138,11 @@ Run multiple agents on one server: | Java | `server.register(new SupportAgent(), "/support")` | | Perl | `$server->register(SupportAgent->new, "/support")` | | C++ | `server.registerAgent(SupportAgent(), "/support")` | -| PHP | `$server->register(new SupportAgent(), '/support')` | */} +| PHP | `$server->register(new SupportAgent(), '/support')` | ```python -from signalwire import AgentServer +from signalwire_agents import AgentServer server = AgentServer() diff --git a/fern/products/sdks/pages/guides/manage-resources/overview.mdx b/fern/products/sdks/pages/guides/manage-resources/overview.mdx index 09d4f1f0e..eb246743b 100644 --- a/fern/products/sdks/pages/guides/manage-resources/overview.mdx +++ b/fern/products/sdks/pages/guides/manage-resources/overview.mdx @@ -10,7 +10,7 @@ max-toc-depth: 3 ### What Is the REST Client? -The `RestClient` provides a synchronous Python interface to all SignalWire REST APIs. It organizes the platform's HTTP endpoints into namespaced resource objects with standard CRUD operations. +The `SignalWireClient` provides a synchronous Python interface to all SignalWire REST APIs. It organizes the platform's HTTP endpoints into namespaced resource objects with standard CRUD operations. #### When to Use REST vs RELAY vs Agents @@ -29,9 +29,9 @@ Use the REST client for tasks like purchasing phone numbers, managing fabric res #!/usr/bin/env python3 """REST client quick start.""" -from signalwire.rest import RestClient +from signalwire_agents.rest import SignalWireClient -client = RestClient( +client = SignalWireClient( project="your-project-id", token="your-api-token", host="your-space.signalwire.com", @@ -92,7 +92,7 @@ func main() { ```ruby -require 'signalwire' +require 'signalwire_agents' client = RestClient.new( project_id: 'your-project-id', @@ -151,33 +151,13 @@ print $available; using namespace signalwire::rest; int main() { - RestClient client("your-project-id", "your-api-token", "your-space.signalwire.com"); + SignalWireClient client("your-project-id", "your-api-token", "your-space.signalwire.com"); auto agents = client.fabric().ai_agents().list(); auto available = client.phone_numbers().search("512"); } ``` - -```php -fabric->aiAgents->list(); -print_r($agents); - -// Search for available phone numbers -$available = $client->phoneNumbers->search(['area_code' => '512']); -print_r($available); -``` - ```csharp using SignalWire.REST; @@ -199,6 +179,26 @@ Console.WriteLine(available); ``` */} + +```php +fabric->aiAgents->list(); +print_r($agents); + +// Search for available phone numbers +$available = $client->phoneNumbers->search(['area_code' => '512']); +print_r($available); +``` + ### Authentication @@ -206,20 +206,20 @@ Console.WriteLine(available); | Language | Syntax | |----------|--------| -| Python | `RestClient(project="...", token="...", host="...")` | +| Python | `SignalWireClient(project="...", token="...", host="...")` | {/* | TypeScript | `new RestClient({ projectId: '...', apiToken: '...', spaceName: '...' })` | | Go | `rest.NewClient(rest.WithProjectID("..."), rest.WithAPIToken("..."), rest.WithSpaceName("..."))` | | Ruby | `RestClient.new(project_id: '...', api_token: '...', space_name: '...')` | | Java | `RestClient.builder().projectId("...").apiToken("...").spaceName("...").build()` | | Perl | `RestClient->new(project_id => '...', api_token => '...', space_name => '...')` | -| C++ | `rest::RestClient client("project_id", "api_token", "space_name")` | -| PHP | `new RestClient(project: '...', token: '...', host: '...')` | +| C++ | `rest::SignalWireClient client("project_id", "api_token", "space_name")` | | C# | `new RestClient(new RestClientOptions { ProjectId = "...", ApiToken = "...", Host = "..." })` | */} +| PHP | `new RestClient(project: '...', token: '...', host: '...')` | ```python -client = RestClient( +client = SignalWireClient( project="your-project-id", token="your-api-token", host="your-space.signalwire.com", @@ -238,7 +238,7 @@ All credentials can be provided via environment variables: ```python # With env vars set, no arguments needed -client = RestClient() +client = SignalWireClient() ``` ### Namespaced Resources @@ -276,13 +276,13 @@ Most resources follow a standard CRUD pattern: | Delete | `client.fabric.ai_agents.delete("id")` | {/* -| Operation | Ruby | Java | Perl | C++ | PHP | C# | |-----------|------|------|------|-----|-----|-----| | List | `client.phone_numbers.list` | `client.phoneNumbers().list()` | `$client->phone_numbers->list` | `client.phone_numbers().list()` | `$client->phoneNumbers->list()` | `client.PhoneNumbers.List()` | | Create | `client.fabric.ai_agents.create(name: 'x')` | `client.fabric().aiAgents().create("x")` | `$client->fabric->ai_agents->create(name=>'x')` | `client.fabric().ai_agents().create("x")` | `$client->fabric->aiAgents->create([...])` | `client.Fabric.AiAgents.Create("x")` | | Get | `client.fabric.ai_agents.get('id')` | `client.fabric().aiAgents().get("id")` | `$client->fabric->ai_agents->get('id')` | `client.fabric().ai_agents().get("id")` | `$client->fabric->aiAgents->fetch($id)` | `client.Fabric.AiAgents.Get("id")` | | Delete | `client.fabric.ai_agents.delete('id')` | `client.fabric().aiAgents().delete("id")` | `$client->fabric->ai_agents->delete('id')` | `client.fabric().ai_agents().del("id")` | `$client->fabric->aiAgents->delete($id)` | `client.Fabric.AiAgents.Delete("id")` | */} +| Operation | Ruby | Java | Perl | C++ | PHP | C# | ```python # List resources @@ -532,7 +532,7 @@ callers = client.verified_callers.list() For endpoints that return paginated results, use `PaginatedIterator`: ```python -from signalwire.rest._pagination import PaginatedIterator +from signalwire_agents.rest._pagination import PaginatedIterator # Iterate all phone numbers across pages for number in PaginatedIterator( @@ -550,9 +550,9 @@ The iterator automatically follows `links.next` URLs to fetch subsequent pages. REST errors raise `SignalWireRestError`: ```python -from signalwire.rest import RestClient, SignalWireRestError +from signalwire_agents.rest import SignalWireClient, SignalWireRestError -client = RestClient() +client = SignalWireClient() try: client.phone_numbers.get("nonexistent-id") @@ -567,9 +567,9 @@ except SignalWireRestError as e: #!/usr/bin/env python3 """Provision a phone number and assign it to an AI agent.""" -from signalwire.rest import RestClient, SignalWireRestError +from signalwire_agents.rest import SignalWireClient, SignalWireRestError -client = RestClient() +client = SignalWireClient() # Search for a local number available = client.phone_numbers.search(area_code="512", quantity=1) diff --git a/fern/products/sdks/pages/guides/manage-resources/phone-numbers.mdx b/fern/products/sdks/pages/guides/manage-resources/phone-numbers.mdx index ffd125b2f..f19660477 100644 --- a/fern/products/sdks/pages/guides/manage-resources/phone-numbers.mdx +++ b/fern/products/sdks/pages/guides/manage-resources/phone-numbers.mdx @@ -124,8 +124,8 @@ You can have multiple numbers pointing to: | Java | `String calledNumber = rawData.get("called_id_num").toString();` | | Perl | `my $called_number = $raw_data->{called_id_num};` | | C++ | `auto calledNumber = rawData["called_id_num"].get();` | -| PHP | `$calledNumber = $rawData['called_id_num'];` | */} +| PHP | `$calledNumber = $rawData['called_id_num'];` | ```python # Agent can check which number was called @@ -133,7 +133,7 @@ def my_handler(self, args, raw_data): called_number = raw_data.get("called_id_num") if called_number == "+15551234567": - return FunctionResult("Sales line") + return SwaigFunctionResult("Sales line") else: - return FunctionResult("Support line") + return SwaigFunctionResult("Support line") ``` diff --git a/fern/products/sdks/pages/guides/manage-resources/testing.mdx b/fern/products/sdks/pages/guides/manage-resources/testing.mdx index d58dd090c..1124563e2 100644 --- a/fern/products/sdks/pages/guides/manage-resources/testing.mdx +++ b/fern/products/sdks/pages/guides/manage-resources/testing.mdx @@ -57,8 +57,8 @@ Run your agent locally using the appropriate command for your language: | Java | `java -jar my-agent.jar` | | Perl | `perl my_agent.pl` | | C++ | `./my_agent` | -| PHP | `php my_agent.php` | */} +| PHP | `php my_agent.php` | Then test the endpoint (the HTTP interface is identical regardless of language): @@ -144,25 +144,25 @@ class MyAgent(AgentBase): result = "Some result" self.log.info(f"Returning: {result}") - return FunctionResult(result) + return SwaigFunctionResult(result) ``` ### Testing Transfers -Test call transfers carefully. The transfer API is the same across languages via `FunctionResult`: +Test call transfers carefully. The transfer API is the same across languages via `SwaigFunctionResult`: | Language | Transfer Call | |----------|-------------| -| Python | `FunctionResult("Transferring").connect(number, final=True)` | +| Python | `SwaigFunctionResult("Transferring").connect(number, final=True)` | {/* -| TypeScript | `new FunctionResult("Transferring").connect(number, { final: true })` | -| Go | `agent.NewFunctionResult("Transferring").Connect(number, true)` | -| Ruby | `FunctionResult.new("Transferring").connect(number, final: true)` | -| Java | `new FunctionResult("Transferring").connect(number, true)` | -| Perl | `FunctionResult->new("Transferring")->connect($number, final => 1)` | -| C++ | `FunctionResult("Transferring").connect(number, true)` | -| PHP | `(new FunctionResult('Transferring'))->connect($number, final: true)` | +| TypeScript | `new SwaigFunctionResult("Transferring").connect(number, { final: true })` | +| Go | `agent.NewSwaigFunctionResult("Transferring").Connect(number, true)` | +| Ruby | `SwaigFunctionResult.new("Transferring").connect(number, final: true)` | +| Java | `new SwaigFunctionResult("Transferring").connect(number, true)` | +| Perl | `SwaigFunctionResult->new("Transferring")->connect($number, final => 1)` | +| C++ | `SwaigFunctionResult("Transferring").connect(number, true)` | */} +| PHP | `(new SwaigFunctionResult('Transferring'))->connect($number, final: true)` | ```python def test_transfer(self, args, raw_data): @@ -170,7 +170,7 @@ def test_transfer(self, args, raw_data): test_number = "+15551234567" return ( - FunctionResult("Transferring now") + SwaigFunctionResult("Transferring now") .connect(test_number, final=True) ) ``` @@ -181,22 +181,22 @@ Test SMS sending. The SMS API follows the same pattern across languages: | Language | Send SMS | |----------|---------| -| Python | `FunctionResult("Sent").send_sms(to_number=to, from_number=from_, body=msg)` | +| Python | `SwaigFunctionResult("Sent").send_sms(to_number=to, from_number=from_, body=msg)` | {/* -| TypeScript | `new FunctionResult("Sent").sendSms({ toNumber: to, fromNumber: from, body: msg })` | -| Go | `agent.NewFunctionResult("Sent").SendSMS(to, from, msg)` | -| Ruby | `FunctionResult.new("Sent").send_sms(to_number: to, from_number: from, body: msg)` | -| Java | `new FunctionResult("Sent").sendSms(to, from, msg)` | -| Perl | `FunctionResult->new("Sent")->send_sms(to_number => $to, from_number => $from, body => $msg)` | -| C++ | `FunctionResult("Sent").sendSms(to, from, msg)` | -| PHP | `(new FunctionResult('Sent'))->sendSms(toNumber: $to, fromNumber: $from, body: $msg)` | +| TypeScript | `new SwaigFunctionResult("Sent").sendSms({ toNumber: to, fromNumber: from, body: msg })` | +| Go | `agent.NewSwaigFunctionResult("Sent").SendSMS(to, from, msg)` | +| Ruby | `SwaigFunctionResult.new("Sent").send_sms(to_number: to, from_number: from, body: msg)` | +| Java | `new SwaigFunctionResult("Sent").sendSms(to, from, msg)` | +| Perl | `SwaigFunctionResult->new("Sent")->send_sms(to_number => $to, from_number => $from, body => $msg)` | +| C++ | `SwaigFunctionResult("Sent").sendSms(to, from, msg)` | */} +| PHP | `(new SwaigFunctionResult('Sent'))->sendSms(toNumber: $to, fromNumber: $from, body: $msg)` | ```python def test_sms(self, args, raw_data): # Send to your own phone for testing return ( - FunctionResult("Sent test SMS") + SwaigFunctionResult("Sent test SMS") .send_sms( to_number="+15551234567", # Your test phone from_number="+15559876543", # Your SignalWire number diff --git a/fern/products/sdks/pages/guides/manage-resources/troubleshooting.mdx b/fern/products/sdks/pages/guides/manage-resources/troubleshooting.mdx index 477d67cc0..9a8c4a9ea 100644 --- a/fern/products/sdks/pages/guides/manage-resources/troubleshooting.mdx +++ b/fern/products/sdks/pages/guides/manage-resources/troubleshooting.mdx @@ -94,17 +94,17 @@ swaig-test my_agent.py --exec function_name --param value **Check:** - Are all required parameters provided? -- Is the handler returning FunctionResult? +- Is the handler returning SwaigFunctionResult? - Are there exceptions in the handler? **Add error handling:** ```python try: result = do_something() - return FunctionResult(result) + return SwaigFunctionResult(result) except Exception as e: self.log.error(f"Error: {e}") - return FunctionResult("Sorry, an error occurred") + return SwaigFunctionResult("Sorry, an error occurred") ``` ### SSL Certificate Issues diff --git a/fern/products/sdks/pages/reference/core/overview.mdx b/fern/products/sdks/pages/reference/core/overview.mdx index 60f825cda..95687e834 100644 --- a/fern/products/sdks/pages/reference/core/overview.mdx +++ b/fern/products/sdks/pages/reference/core/overview.mdx @@ -15,16 +15,10 @@ position: 0 [ref-agentbase]: /docs/sdks/reference/python/agents/agent-base [ref-restclient]: /docs/sdks/reference/python/rest/client -The SignalWire Python SDK provides three namespaces, each designed for a different +The SignalWire SDK provides three namespaces, each designed for a different interaction pattern with the SignalWire platform. You can use one or combine all three in a single application. -```python -from signalwire import AgentBase # AI voice agents (SWML) -from signalwire.relay import RelayClient # Real-time call control (WebSocket) -from signalwire.rest import RestClient # Resource management (HTTP) -``` - ## Namespaces | | Agents | RELAY | REST | @@ -114,25 +108,9 @@ All three namespaces authenticate with the same core credentials: | `SIGNALWIRE_API_TOKEN` | API token for your project | | `SIGNALWIRE_SPACE` | Your SignalWire space hostname (e.g., `your-space.signalwire.com`) | -Set these once and all three clients can authenticate without explicit arguments: - -```python -# With environment variables set, no arguments needed: -agent = AgentBase(name="my-agent") -relay = RelayClient(contexts=["default"]) -rest = RestClient() -``` - -Or pass credentials explicitly: - -```python -# Explicit credentials -rest = RestClient( - project="your-project-id", - token="your-api-token", - host="your-space.signalwire.com", -) -``` +Set these once and all three clients can authenticate without explicit arguments. +Or pass credentials explicitly when constructing a client. See the reference page +for each namespace for language-specific examples. ### Namespace-specific authentication @@ -154,17 +132,8 @@ the password. All requests go over HTTPS to `https://{SIGNALWIRE_SPACE}`. ## Installation -```bash -pip install signalwire -``` - -Optional extras for additional capabilities: - -| Extra | Install Command | Enables | -|-------|----------------|---------| -| `search` | `pip install "signalwire[search]"` | Vector search index building | -| `search-full` | `pip install "signalwire[search-full]"` | PDF and DOCX document processing | -| `pgvector` | `pip install "signalwire[pgvector]"` | PostgreSQL vector storage backend | +See the installation instructions in each namespace's overview page for your +selected SDK language variant. --- diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/add-answer-verb.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/add-answer-verb.mdx new file mode 100644 index 000000000..301f4d17a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/add-answer-verb.mdx @@ -0,0 +1,35 @@ +--- +title: "addAnswerVerb" +slug: /reference/php/agents/agent-base/add-answer-verb +description: Configure the answer verb that connects the call. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Configure the answer verb that connects the call. Use this to customize answer +behavior such as setting a maximum call duration. + +## **Parameters** + + + Answer verb configuration (e.g., `{"max_duration": 3600}`). + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->addAnswerVerb(["max_duration" => 3600]) # 1 $hour $max $call $duration; +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/add-function-include.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/add-function-include.mdx new file mode 100644 index 000000000..6dbf23b02 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/add-function-include.mdx @@ -0,0 +1,56 @@ +--- +title: "addFunctionInclude" +slug: /reference/php/agents/agent-base/add-function-include +description: Add a remote function include to the SWAIG configuration. +max-toc-depth: 3 +--- + +[ai-swaig-includes]: /docs/swml/reference/ai/swaig/includes +[swml-swaig-includes-reference]: /docs/swml/reference/ai/swaig/includes +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Add a remote SWAIG function include so the agent can call tools hosted on an external +server. The remote endpoint is contacted at session start and the listed functions +become available to the AI just like locally defined tools. + + +This maps to the SWML [`ai.swaig.includes`][ai-swaig-includes] array. +See the [SWML SWAIG includes reference][swml-swaig-includes-reference] for details. + + +## **Parameters** + + + URL of the remote SWAIG server that hosts the functions. + + + + List of function names to include from the remote server. + + + + Optional metadata dictionary passed along with the function include. Can be used + to provide authentication tokens or context to the remote server. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->addFunctionInclude( + url: "https://tools.example.com/swaig", + functions: ["lookup_order", "cancel_order"], + meta_data: ["auth_token" => "secret-token"] +); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/add-hint.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/add-hint.mdx new file mode 100644 index 000000000..621eb8803 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/add-hint.mdx @@ -0,0 +1,36 @@ +--- +title: "addHint" +slug: /reference/php/agents/agent-base/add-hint +description: Add a single speech recognition hint to improve transcription accuracy. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Add a single speech recognition hint. Hints boost the automatic speech recognition +(ASR) engine's accuracy for specific words or phrases that may otherwise be +misrecognized -- such as product names, technical jargon, or uncommon proper nouns. + +## **Parameters** + + + A word or phrase to boost recognition accuracy. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->addHint("SignalWire"); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/add-hints.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/add-hints.mdx new file mode 100644 index 000000000..114520ba2 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/add-hints.mdx @@ -0,0 +1,34 @@ +--- +title: "addHints" +slug: /reference/php/agents/agent-base/add-hints +description: Add multiple speech recognition hints at once. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Add multiple speech recognition hints at once. + +## **Parameters** + + + A list of words or phrases. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->addHints(["SWML", "SWAIG", "FreeSWITCH"]); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/add-internal-filler.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/add-internal-filler.mdx new file mode 100644 index 000000000..1247a18cf --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/add-internal-filler.mdx @@ -0,0 +1,50 @@ +--- +title: "addInternalFiller" +slug: /reference/php/agents/agent-base/add-internal-filler +description: Add filler phrases for a specific native function and language. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Add filler phrases for a specific native function and language. + +## **Parameters** + + + Name of the native function (e.g., `"next_step"`, `"check_time"`). + + + + Language code (e.g., `"en-US"`, `"es"`, `"fr"`). + + + + List of filler phrases for this function and language. The AI randomly selects + from this list each time the function is invoked. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5,9} +setPromptText("You are a helpful assistant."); +$agent->addInternalFiller( + "next_step", "en-US", + ["Moving to the next step...", "Great, let's continue..."] +); +$agent->addInternalFiller( + "next_step", "es", + ["Pasando al siguiente paso...", "Continuemos..."] +); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/add-language.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/add-language.mdx new file mode 100644 index 000000000..545c4d306 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/add-language.mdx @@ -0,0 +1,115 @@ +--- +title: "addLanguage" +slug: /reference/php/agents/agent-base/add-language +description: Add a language configuration with voice settings for multilingual conversations. +max-toc-depth: 3 +--- + +[ai-languages]: /docs/swml/reference/ai/languages +[swml-languages-reference]: /docs/swml/reference/ai/languages +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Add a language configuration with voice settings. The agent uses these configurations +to support multilingual conversations with appropriate TTS voices. + + +Language configurations map to the SWML [`ai.languages`][ai-languages] array. +See the [SWML languages reference][swml-languages-reference] for the full specification. + + + +The `voice` parameter supports three formats: a simple voice name, an explicit +engine/model via separate parameters, or a combined `"engine.voice:model"` string. + + +## **Parameters** + + + Human-readable language name (e.g., `"English"`, `"French"`, `"Spanish"`). + + + + Language code (e.g., `"en-US"`, `"fr-FR"`, `"es-MX"`). + + + + TTS voice identifier. Accepts one of three formats: + - Simple name: `"en-US-Neural2-F"` + - Combined format: `"elevenlabs.josh:eleven_turbo_v2_5"` + - Short name with explicit `engine`/`model`: `"josh"` + + + + Filler phrases used during natural speech pauses (e.g., `["Um...", "Let me see..."]`). + + + + Filler phrases spoken while executing SWAIG functions + (e.g., `["One moment please...", "Looking that up..."]`). + + + + Explicit TTS engine name (e.g., `"elevenlabs"`, `"rime"`). Overrides the + combined string format if provided. + + + + Explicit TTS model name (e.g., `"eleven_turbo_v2_5"`, `"arcana"`). Overrides the + combined string format if provided. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Examples** + +### Simple voice + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->addLanguage("English", "en-US", "rime.spore"); +$agent->serve(); + + +``` + +### Explicit engine and model + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->addLanguage( + "English", "en-US", "josh", + engine: "elevenlabs", + model: "eleven_turbo_v2_5" +); +$agent->serve(); + + +``` + +### With fillers + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->addLanguage( + "English", "en-US", "rime.spore", + speech_fillers: ["Um...", "Let me think..."], + function_fillers: ["One moment please...", "Looking that up..."] +); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/add-pattern-hint.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/add-pattern-hint.mdx new file mode 100644 index 000000000..aa1254530 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/add-pattern-hint.mdx @@ -0,0 +1,54 @@ +--- +title: "addPatternHint" +slug: /reference/php/agents/agent-base/add-pattern-hint +description: Add a speech recognition hint with pattern matching and replacement. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Add a hint with pattern matching and replacement. This allows you to intercept +specific ASR output and rewrite it before it reaches the AI -- useful for correcting +consistent misrecognitions or normalizing variations. + +## **Parameters** + + + The hint string to match against ASR output. + + + + Regular expression pattern to match. + + + + Replacement text to substitute when the pattern matches. + + + + Whether to ignore case when matching the pattern. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {6} +setPromptText("You are a helpful assistant."); +// Correct common ASR misrecognition +$agent->addPatternHint( + hint: "SignalWire", + pattern: $r"signal\s*wire|signal\s*wired", + replace: "SignalWire", + ignore_case: true +); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/add-post-ai-verb.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/add-post-ai-verb.mdx new file mode 100644 index 000000000..3cf912a54 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/add-post-ai-verb.mdx @@ -0,0 +1,43 @@ +--- +title: "addPostAiVerb" +slug: /reference/php/agents/agent-base/add-post-ai-verb +description: Add a SWML verb to run after the AI conversation ends. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Add a verb to run after the AI conversation ends. Common uses include logging, +cleanup transfers, and explicit hangup. + +## **Parameters** + + + SWML verb name (e.g., `"hangup"`, `"transfer"`, `"request"`). + + + + Verb configuration dictionary. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5,9} +setPromptText("You are a helpful assistant."); +$agent->addPostAiVerb("request", { + "url": "https://api.example.com/call-complete", + "method": "POST" +}); +$agent->addPostAiVerb("hangup", {}); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/add-post-answer-verb.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/add-post-answer-verb.mdx new file mode 100644 index 000000000..5dba983b4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/add-post-answer-verb.mdx @@ -0,0 +1,42 @@ +--- +title: "addPostAnswerVerb" +slug: /reference/php/agents/agent-base/add-post-answer-verb +description: Add a SWML verb to run after the call is answered but before the AI starts. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Add a verb to run after the call is answered but before the AI starts. Common uses +include welcome messages, legal disclaimers, and brief pauses. + +## **Parameters** + + + SWML verb name (e.g., `"play"`, `"sleep"`). + + + + Verb configuration dictionary. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5,8} +setPromptText("You are a helpful assistant."); +$agent->addPostAnswerVerb("play", { + "url": "say:Welcome to Acme Corporation. This call may be recorded." +}); +$agent->addPostAnswerVerb("sleep", ["time" => 500]); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/add-pre-answer-verb.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/add-pre-answer-verb.mdx new file mode 100644 index 000000000..9d0ebc53c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/add-pre-answer-verb.mdx @@ -0,0 +1,54 @@ +--- +title: "addPreAnswerVerb" +slug: /reference/php/agents/agent-base/add-pre-answer-verb +description: Add a SWML verb to run before the call is answered. +max-toc-depth: 3 +--- + +[swml-reference]: /docs/swml/reference +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Add a verb to run before the call is answered. Pre-answer verbs execute while the +call is still ringing. + + +Only certain verbs are safe before answering. Using an unsafe verb raises +`ValueError`. Verbs with `auto_answer` capability (like `play` and `connect`) must +include `"auto_answer": False` in their config to prevent automatic answering. + + +Safe pre-answer verbs: `transfer`, `execute`, `return`, `label`, `goto`, `request`, +`switch`, `cond`, `if`, `eval`, `set`, `unset`, `hangup`, `sendSms`, `sleep`, +`stopRecordCall`, `stop_denoise`, `stop_tap`. + +## **Parameters** + + + SWML verb name (e.g., `"play"`, `"sleep"`, `"request"`). + + + + Verb configuration dictionary. See the + [SWML reference][swml-reference] for verb-specific parameters. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->addPreAnswerVerb("play", { + "urls": ["ring:us"], + "auto_answer": false +}); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/add-pronunciation.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/add-pronunciation.mdx new file mode 100644 index 000000000..4d7a5a54d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/add-pronunciation.mdx @@ -0,0 +1,45 @@ +--- +title: "addPronunciation" +slug: /reference/php/agents/agent-base/add-pronunciation +description: Add a pronunciation rule to correct how the AI speaks a specific word or phrase. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Add a pronunciation rule that tells the TTS engine how to speak a specific word or +phrase. Useful for brand names, acronyms, and technical terms that are commonly +mispronounced by text-to-speech engines. + +## **Parameters** + + + The expression to match in the AI's output text. + + + + The phonetic spelling or alternative text the TTS engine should speak instead. + + + + Whether to ignore case when matching the `replace` expression. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5-6} +setPromptText("You are a helpful assistant."); +$agent->addPronunciation("SQL", "sequel"); +$agent->addPronunciation("SWAIG", "swig", ignore_case: true); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/add-skill.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/add-skill.mdx new file mode 100644 index 000000000..25add8531 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/add-skill.mdx @@ -0,0 +1,69 @@ +--- +title: "addSkill" +slug: /reference/php/agents/agent-base/add-skill +description: Load and activate a skill on the agent. +max-toc-depth: 3 +--- + +[list-skills]: /docs/sdks/reference/php/agents/agent-base/list-skills +[skills-catalog]: /docs/sdks/reference/php/agents/skills +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Load and activate a skill on this agent. Skills are pluggable capability modules that +register their own tools, prompts, and configuration. The SDK ships with built-in +skills for common tasks like `datetime`, `web_search`, and `math`. + + +Raises `ValueError` if the skill is not found or fails to load. Check available +skills with [`listSkills()`][list-skills] or consult the +[skills catalog][skills-catalog]. + + +## **Parameters** + + + Registered skill name (e.g., `"datetime"`, `"web_search"`, `"math"`). + + + + Skill-specific configuration parameters. Each skill documents its own supported + parameters. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Examples** + +### Add built-in skills + +```php {5-6} +setPromptText("You are a helpful assistant."); +$agent->addSkill("datetime"); +$agent->addSkill("math"); +$agent->serve(); + + +``` + +### Skill with configuration + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->addSkill("web_search", params: { + "api_key": "your-search-api-key", + "max_results": 5 +}); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/add-swaig-query-params.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/add-swaig-query-params.mdx new file mode 100644 index 000000000..a31cac66e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/add-swaig-query-params.mdx @@ -0,0 +1,72 @@ +--- +title: "addSwaigQueryParams" +slug: /reference/php/agents/agent-base/add-swaig-query-params +description: Append query parameters to all SWAIG webhook URLs. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Add query parameters that will be included in all SWAIG webhook URLs generated by +this agent. This is particularly useful for preserving dynamic configuration state +across SWAIG callbacks -- for example, passing a tenant identifier or feature tier +so the same configuration is applied when SignalWire invokes tool webhooks. + +## **Parameters** + + + Dictionary of query parameters to merge into every SWAIG URL. Subsequent calls + merge into (not replace) the existing set. Pass the same key again to overwrite + its value. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Examples** + +### Preserve tier in dynamic config + +```php {10} +setPromptText("You are a helpful assistant."); + +function dynamicConfig($query_params, $body_params, $headers, $agent) +{ + $tier = $query_params["tier"] ?? "free"; + if ($tier == "premium") { + $agent->addSkill("advanced_search"); + } + $agent->addSwaigQueryParams(["tier" => tier]); +} + +$agent->setDynamicConfigCallback($dynamic_config); +$agent->serve(); + + +``` + +### Multi-tenant routing + +```php {8} +setPromptText("You are a helpful assistant."); + +function dynamicConfig($query_params, $body_params, $headers, $agent) +{ + $tenant_id = $query_params["tenant_id"] ?? "default"; + $agent->addSwaigQueryParams(["tenant_id" => tenant_id]); +} + +$agent->setDynamicConfigCallback($dynamic_config); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/build-ai-verb.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/build-ai-verb.mdx new file mode 100644 index 000000000..c2f030e38 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/build-ai-verb.mdx @@ -0,0 +1,32 @@ +--- +title: "buildAiVerb" +slug: /reference/php/agents/agent-base/build-ai-verb +description: Build the AI verb configuration array. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-base + +Build the AI verb configuration array. + +## **Parameters** + + + HTTP headers to include. + Defaults to `[]`. + + +## **Returns** + +`array` -- The result array. + +## **Example** + +```php +buildAiVerb(["Content-Type" => "application/json"]); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/clear-post-ai-verbs.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/clear-post-ai-verbs.mdx new file mode 100644 index 000000000..0a71eba09 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/clear-post-ai-verbs.mdx @@ -0,0 +1,29 @@ +--- +title: "clearPostAiVerbs" +slug: /reference/php/agents/agent-base/clear-post-ai-verbs +description: Remove all post-AI verbs from the call flow. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Remove all post-AI verbs. + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {6} +setPromptText("You are a helpful assistant."); +$agent->addPostAiVerb("hangup", {}); +$agent->clearPostAiVerbs(); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/clear-post-answer-verbs.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/clear-post-answer-verbs.mdx new file mode 100644 index 000000000..aafb2c507 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/clear-post-answer-verbs.mdx @@ -0,0 +1,31 @@ +--- +title: "clearPostAnswerVerbs" +slug: /reference/php/agents/agent-base/clear-post-answer-verbs +description: Remove all post-answer verbs from the call flow. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Remove all post-answer verbs. + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {8} +setPromptText("You are a helpful assistant."); +$agent->addPostAnswerVerb("play", { + "url": "say:Welcome to Acme Corporation." +}); +$agent->clearPostAnswerVerbs(); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/clear-pre-answer-verbs.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/clear-pre-answer-verbs.mdx new file mode 100644 index 000000000..91ceb38c6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/clear-pre-answer-verbs.mdx @@ -0,0 +1,31 @@ +--- +title: "clearPreAnswerVerbs" +slug: /reference/php/agents/agent-base/clear-pre-answer-verbs +description: Remove all pre-answer verbs from the call flow. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Remove all pre-answer verbs. + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {8} +setPromptText("You are a helpful assistant."); +$agent->addPreAnswerVerb("play", { + "urls": ["ring:us"], "auto_answer": false +}); +$agent->clearPreAnswerVerbs(); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/clear-swaig-query-params.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/clear-swaig-query-params.mdx new file mode 100644 index 000000000..7cd89b6d4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/clear-swaig-query-params.mdx @@ -0,0 +1,47 @@ +--- +title: "clearSwaigQueryParams" +slug: /reference/php/agents/agent-base/clear-swaig-query-params +description: Remove all SWAIG query parameters from the agent. +max-toc-depth: 3 +--- + +[add-swaig-query-params]: /docs/sdks/reference/php/agents/agent-base/add-swaig-query-params +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Clear all query parameters previously added with +[`addSwaigQueryParams()`][add-swaig-query-params]. +After calling this method, SWAIG webhook URLs will no longer include any extra +query parameters. + +## **Parameters** + +None. + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Examples** + +### Reset params in dynamic config + +```php {8} +setPromptText("You are a helpful assistant."); + +function dynamicConfig($query_params, $body_params, $headers, $agent) +{ + // Start fresh each request to avoid stale params + $agent->clearSwaigQueryParams(); + $tier = $query_params["tier"] ?? "free"; + $agent->addSwaigQueryParams(["tier" => tier]); +} + +$agent->setDynamicConfigCallback($dynamic_config); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/clone-for-request.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/clone-for-request.mdx new file mode 100644 index 000000000..bdbe40357 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/clone-for-request.mdx @@ -0,0 +1,29 @@ +--- +title: "cloneForRequest" +slug: /reference/php/agents/agent-base/clone-for-request +description: Clone the agent for processing a single request. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-base + +Clone the agent for processing a single request. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`static` -- A new AgentBase instance. + +## **Example** + +```php +cloneForRequest(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/contexts.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/contexts.mdx new file mode 100644 index 000000000..df0beb4e5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/contexts.mdx @@ -0,0 +1,29 @@ +--- +title: "contexts" +slug: /reference/php/agents/agent-base/contexts +description: Access the context builder for defining conversation contexts. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-base + +Access the context builder for defining conversation contexts. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`ContextBuilder` -- The context builder instance. + +## **Example** + +```php +contexts(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/define-contexts.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/define-contexts.mdx new file mode 100644 index 000000000..dd7eb72c9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/define-contexts.mdx @@ -0,0 +1,92 @@ +--- +title: "defineContexts" +slug: /reference/php/agents/agent-base/define-contexts +description: Define multi-step conversation contexts and workflows for complex agent interactions. +max-toc-depth: 3 +--- + +[contextbuilder]: /docs/sdks/reference/php/agents/context-builder +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Define contexts and steps for multi-step conversation workflows. Contexts allow an +agent to guide the caller through a structured sequence of interactions -- such as +gathering information, verifying identity, and then performing an action. + +When called with an argument, sets the context configuration directly and returns +`self`. When called without arguments, returns a +[`ContextBuilder`][contextbuilder] for fluent +context definition. + + +Contexts can coexist with traditional prompts. The only restriction is that POM +sections and raw text cannot be mixed in the main prompt. + + +## **Parameters** + + + Context configuration. Pass a dictionary or `ContextBuilder` to set contexts + directly. Omit to receive a `ContextBuilder` for fluent definition. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- When `contexts` is provided. + +[`ContextBuilder`][contextbuilder] -- When called +with no arguments. + +## **Examples** + +### Fluent ContextBuilder + +```php {4} +defineContexts() + .addContext("default") + .addStep("greeting") + .setText("Greet the caller and ask for their name.") + .setStepCriteria("The caller has provided their name.") + .setFunctions(["lookup_account"]) + .setValidSteps(["verify"]) + .addStep("verify") + .setText("Verify the caller's identity.") + .setStepCriteria("Identity verified.") + .setValidSteps(["assist"]) + .addStep("assist") + .setText("Help the caller with their request.") + .setFunctions(["search_orders", "process_return"]) +); +$agent->serve(); + + +``` + +### Direct dict configuration + +```php {4} +defineContexts({ + "default": { + "steps": { + "greeting": { + "text": "Greet the caller.", + "valid_steps": ["verify"] + }, + "verify": { + "text": "Verify identity.", + "valid_steps": ["assist"] + } + } + } +}); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/define-tool.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/define-tool.mdx new file mode 100644 index 000000000..6a128b3de --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/define-tool.mdx @@ -0,0 +1,119 @@ +--- +title: "defineTool" +slug: /reference/php/agents/agent-base/define-tool +description: Programmatically define a SWAIG tool that the AI can invoke during conversations. +max-toc-depth: 3 +--- + +[tool-decorator]: /docs/sdks/reference/php/agents/agent-base#tool +[swaig-function]: /docs/swml/reference/ai/swaig/functions +[swml-swaig-functions-reference]: /docs/swml/reference/ai/swaig/functions +[functionresult]: /docs/sdks/reference/php/agents/function-result +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Programmatically define a SWAIG function (tool) that the AI can invoke during a +conversation. This is the imperative alternative to the +[`@tool` decorator][tool-decorator]. + + +Tool definitions map to SWML [SWAIG function][swaig-function] +entries. See the [SWML SWAIG functions reference][swml-swaig-functions-reference] +for the full specification. + + + +For most cases, the [`@tool` decorator][tool-decorator] +is simpler and supports automatic parameter inference from type hints. Use +`defineTool()` when you need dynamic tool registration or when the tool definition +comes from external configuration. + + +## **Parameters** + + + Function name. Must be unique within the agent. The AI uses this name to invoke the + function. + + + + Human-readable description of what the function does. The AI reads this to decide + when to call the function. + + + + JSON Schema describing the function's parameters. The AI generates arguments + conforming to this schema. + + + + Python function to call when the AI invokes this tool. Receives `(args: dict, raw_data: dict)` + and should return a [`FunctionResult`][functionresult]. + + + + Whether to require token validation on tool calls. Recommended for production. + + + + Language-specific filler phrases spoken while the function executes. + Format: `{"en-US": ["Looking that up...", "One moment..."]}`. + + + + External URL to forward the tool call to instead of executing locally. + + + + List of required parameter names from the JSON Schema. + + + + Set to `True` if the handler uses type-hinted parameters instead of the standard + `(args, raw_data)` signature. + + + + Additional SWAIG fields to include in the function definition + (e.g., `wait_file`, `meta_data`). + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +function getWeather($args, raw_data: null) +{ + $city = $args["city"] ?? "unknown"; + return new FunctionResult("The weather in {$city} is 72F and sunny."); +} + +$agent->defineTool( + name: "get_weather", + description: "Get the current weather for a city", + parameters: { + "type": "object", + "properties": { + "city": { + "type": "string", + "description": "City name" + } + } + }, + handler: $get_weather, + required: ["city"], + fillers: ["en-US" => ["Checking the weather...", "Let me look that up..."]] +); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/define-tools.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/define-tools.mdx new file mode 100644 index 000000000..c2030d0ee --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/define-tools.mdx @@ -0,0 +1,31 @@ +--- +title: "defineTools" +slug: /reference/php/agents/agent-base/define-tools +description: Define multiple tools at once. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-base + +Define multiple tools at once. + +## **Parameters** + + + Array of tool definition arrays. + + +## **Returns** + +`self` -- The the AI agent instance for method chaining. + +## **Example** + +```php +defineTools([]); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/enable-debug-events.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/enable-debug-events.mdx new file mode 100644 index 000000000..bb997b1bb --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/enable-debug-events.mdx @@ -0,0 +1,42 @@ +--- +title: "enableDebugEvents" +slug: /reference/php/agents/agent-base/enable-debug-events +description: Enable real-time debug event webhooks from the AI module during calls. +max-toc-depth: 3 +--- + +[on-debug-event]: /docs/sdks/reference/php/agents/agent-base/on-debug-event +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Enable real-time debug event webhooks from the AI module during calls. When enabled, +the SDK automatically wires a `debug_webhook_url` into the AI parameters and registers +a `/debug_events` endpoint that receives event POSTs from the SignalWire platform. + +Events are logged via the agent's structured logger. Optionally, register a custom +handler with [`onDebugEvent()`][on-debug-event] to react to events programmatically. + +## **Parameters** + + + Debug event verbosity level. + - `1` -- High-level events: barge, errors, session start/end, step changes + - `2+` -- Adds high-volume events: every LLM request/response, `conversation_add` + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->enableDebugEvents(level: 1); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/enable-sip-routing.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/enable-sip-routing.mdx new file mode 100644 index 000000000..b4928ce51 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/enable-sip-routing.mdx @@ -0,0 +1,43 @@ +--- +title: "enableSipRouting" +slug: /reference/php/agents/agent-base/enable-sip-routing +description: Enable SIP-based call routing for this agent. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Enable SIP-based routing for this agent. When enabled, a routing callback endpoint +is registered at the specified path. Incoming SIP calls are matched against registered +usernames and directed to this agent. + +When `auto_map` is `True`, common SIP usernames are automatically registered based +on the agent's name and route path. + +## **Parameters** + + + Automatically register SIP usernames derived from the agent name and route. + + + + URL path for the SIP routing endpoint. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->enableSipRouting(); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/get-basic-auth-credentials.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/get-basic-auth-credentials.mdx new file mode 100644 index 000000000..839de1f2a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/get-basic-auth-credentials.mdx @@ -0,0 +1,60 @@ +--- +title: "getBasicAuthCredentials" +slug: /reference/php/agents/agent-base/get-basic-auth-credentials +description: Retrieve the agent's Basic Auth credentials and their origin. +max-toc-depth: 3 +--- + +Retrieve the username and password used for HTTP Basic Auth on this agent. Optionally +includes a source label indicating where the credentials came from. + +## **Parameters** + + + When `True`, the returned tuple includes a third element indicating the credential + source: `"provided"` (set explicitly), `"environment"` (from `SWML_BASIC_AUTH_USER` + / `SWML_BASIC_AUTH_PASSWORD` environment variables), or `"generated"` (auto-generated + at startup). + + +## **Returns** + +`tuple[string, string]` -- `(username, password)` when `include_source` is `False`. + +`tuple[string, string, string]` -- `(username, password, source)` when `include_source` is +`True`. + +## **Examples** + +### Log credentials at startup + +```php {5} +setPromptText("You are a helpful assistant."); +$user, $password = $agent->getBasicAuthCredentials(); +echo "Auth: {$user}:{$password}"; +$agent->serve(); + + +``` + +### Check credential source + +```php {5} +setPromptText("You are a helpful assistant."); +$user, $password, $source = $agent->getBasicAuthCredentials(include_source: true); +if ($source == "generated") { + echo "Auto-generated credentials: {$user}:{$password}"; + echo "Set SWML_BASIC_AUTH_USER and SWML_BASIC_AUTH_PASSWORD to use your own."; +} +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/get-full-url.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/get-full-url.mdx new file mode 100644 index 000000000..9badb9b92 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/get-full-url.mdx @@ -0,0 +1,43 @@ +--- +title: "getFullUrl" +slug: /reference/php/agents/agent-base/get-full-url +description: Get the full URL for this agent's endpoint, including host, port, and route. +max-toc-depth: 3 +--- + +[manual-set-proxy-url]: /docs/sdks/reference/php/agents/agent-base/manual-set-proxy-url + +Get the full URL for this agent's endpoint. The URL is constructed from the agent's +host, port, and route. In serverless environments, the URL is derived from +platform-specific environment variables. When behind a proxy, the +`SWML_PROXY_URL_BASE` environment variable or +[`manualSetProxyUrl()`][manual-set-proxy-url] +takes precedence. + +## **Parameters** + + + Whether to embed Basic Auth credentials in the URL (e.g., + `https://user:pass@host:port/route`). + + +## **Returns** + +`string` -- The fully constructed URL string. + +## **Example** + +```php {5,8} +setPromptText("You are a helpful assistant."); +$url = $agent->getFullUrl(); +echo $url; + +$url_with_auth = $agent->getFullUrl(include_auth: true); +echo $url_with_auth; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/get-name.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/get-name.mdx new file mode 100644 index 000000000..e1891267e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/get-name.mdx @@ -0,0 +1,28 @@ +--- +title: "getName" +slug: /reference/php/agents/agent-base/get-name +description: Get the agent's display name. +max-toc-depth: 3 +--- + +Get the agent's display name as set at construction time. + +## **Parameters** + +None. + +## **Returns** + +`string` -- The agent name. + +## **Example** + +```php {4} +getName(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/get-prompt.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/get-prompt.mdx new file mode 100644 index 000000000..15496f8a9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/get-prompt.mdx @@ -0,0 +1,31 @@ +--- +title: "getPrompt" +slug: /reference/php/agents/agent-base/get-prompt +description: Retrieve the current prompt configured on the agent. +max-toc-depth: 3 +--- + +[set-prompt-text]: /docs/sdks/reference/php/agents/agent-base/set-prompt-text + +Retrieve the current prompt. Returns a string if +[`setPromptText()`][set-prompt-text] was used, or a +POM structure (list of dictionaries) if prompt sections were used. If neither was +explicitly set, returns a default prompt: `"You are {name}, a helpful AI assistant."`. + +## **Returns** + +`string | list[dict[string, mixed]]` -- The current prompt in whatever format was configured. + +## **Example** + +```php {5} +setPromptText("You are a customer support agent for Acme Corp."); +$prompt = $agent->getPrompt(); +echo $prompt; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/has-skill.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/has-skill.mdx new file mode 100644 index 000000000..36015df2f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/has-skill.mdx @@ -0,0 +1,32 @@ +--- +title: "hasSkill" +slug: /reference/php/agents/agent-base/has-skill +description: Check whether a specific skill is currently loaded on the agent. +max-toc-depth: 3 +--- + +Check whether a specific skill is currently loaded. + +## **Parameters** + + + Skill name to check. + + +## **Returns** + +`bool` -- `True` if the skill is loaded, `False` otherwise. + +## **Example** + +```php {5-6} +addSkill("datetime"); +echo $agent->hasSkill("datetime"); +echo $agent->hasSkill("web_search"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/index.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/index.mdx new file mode 100644 index 000000000..4f802fc4f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/index.mdx @@ -0,0 +1,573 @@ +--- +title: "AgentBase" +slug: /reference/php/agents/agent-base +description: The central class for building AI-powered voice agents with SignalWire. +max-toc-depth: 3 +--- + +[swmlservice]: /docs/sdks/reference/php/agents/swml-service +[ai]: /docs/swml/reference/ai +[swml-reference]: /docs/swml/reference/ai +[agentserver]: /docs/sdks/reference/php/agents/agent-server +[add-skill]: /docs/sdks/reference/php/agents/agent-base/add-skill +[list-skills]: /docs/sdks/reference/php/agents/agent-base/list-skills +[configloader]: /docs/sdks/reference/php/agents/configuration/config-loader +[addanswerverb]: /docs/sdks/reference/php/agents/agent-base/add-answer-verb +[addfunctioninclude]: /docs/sdks/reference/php/agents/agent-base/add-function-include +[addhint]: /docs/sdks/reference/php/agents/agent-base/add-hint +[addhints]: /docs/sdks/reference/php/agents/agent-base/add-hints +[addinternalfiller]: /docs/sdks/reference/php/agents/agent-base/add-internal-filler +[addlanguage]: /docs/sdks/reference/php/agents/agent-base/add-language +[addpatternhint]: /docs/sdks/reference/php/agents/agent-base/add-pattern-hint +[addpostaiverb]: /docs/sdks/reference/php/agents/agent-base/add-post-ai-verb +[addpostanswerverb]: /docs/sdks/reference/php/agents/agent-base/add-post-answer-verb +[addpreanswerverb]: /docs/sdks/reference/php/agents/agent-base/add-pre-answer-verb +[addpronunciation]: /docs/sdks/reference/php/agents/agent-base/add-pronunciation +[addskill]: /docs/sdks/reference/php/agents/agent-base/add-skill +[addswaigqueryparams]: /docs/sdks/reference/php/agents/agent-base/add-swaig-query-params +[clearpostaiverbs]: /docs/sdks/reference/php/agents/agent-base/clear-post-ai-verbs +[clearpostanswerverbs]: /docs/sdks/reference/php/agents/agent-base/clear-post-answer-verbs +[clearpreanswerverbs]: /docs/sdks/reference/php/agents/agent-base/clear-pre-answer-verbs +[clearswaigqueryparams]: /docs/sdks/reference/php/agents/agent-base/clear-swaig-query-params +[definecontexts]: /docs/sdks/reference/php/agents/agent-base/define-contexts +[definetool]: /docs/sdks/reference/php/agents/agent-base/define-tool +[enabledebugevents]: /docs/sdks/reference/php/agents/agent-base/enable-debug-events +[enablesiprouting]: /docs/sdks/reference/php/agents/agent-base/enable-sip-routing +[getbasicauthcredentials]: /docs/sdks/reference/php/agents/agent-base/get-basic-auth-credentials +[getfullurl]: /docs/sdks/reference/php/agents/agent-base/get-full-url +[getname]: /docs/sdks/reference/php/agents/agent-base/get-name +[getprompt]: /docs/sdks/reference/php/agents/agent-base/get-prompt +[hasskill]: /docs/sdks/reference/php/agents/agent-base/has-skill +[listskills]: /docs/sdks/reference/php/agents/agent-base/list-skills +[manualsetproxyurl]: /docs/sdks/reference/php/agents/agent-base/manual-set-proxy-url +[ondebugevent]: /docs/sdks/reference/php/agents/agent-base/on-debug-event +[onsummary]: /docs/sdks/reference/php/agents/agent-base/on-summary +[promptaddsection]: /docs/sdks/reference/php/agents/agent-base/prompt-add-section +[promptaddsubsection]: /docs/sdks/reference/php/agents/agent-base/prompt-add-subsection +[promptaddtosection]: /docs/sdks/reference/php/agents/agent-base/prompt-add-to-section +[prompthassection]: /docs/sdks/reference/php/agents/agent-base/prompt-has-section +[registersipusername]: /docs/sdks/reference/php/agents/agent-base/register-sip-username +[registerswaigfunction]: /docs/sdks/reference/php/agents/agent-base/register-swaig-function +[removeskill]: /docs/sdks/reference/php/agents/agent-base/remove-skill +[run]: /docs/sdks/reference/php/agents/agent-base/run +[serve]: /docs/sdks/reference/php/agents/agent-base/serve +[setdynamicconfigcallback]: /docs/sdks/reference/php/agents/agent-base/set-dynamic-config-callback +[setfunctionincludes]: /docs/sdks/reference/php/agents/agent-base/set-function-includes +[setglobaldata]: /docs/sdks/reference/php/agents/agent-base/set-global-data +[setinternalfillers]: /docs/sdks/reference/php/agents/agent-base/set-internal-fillers +[setlanguages]: /docs/sdks/reference/php/agents/agent-base/set-languages +[setparam]: /docs/sdks/reference/php/agents/agent-base/set-param +[setparams]: /docs/sdks/reference/php/agents/agent-base/set-params +[setpostprompt]: /docs/sdks/reference/php/agents/agent-base/set-post-prompt +[setpostpromptllmparams]: /docs/sdks/reference/php/agents/agent-base/set-post-prompt-llm-params +[setpostprompturl]: /docs/sdks/reference/php/agents/agent-base/set-post-prompt-url +[setpromptllmparams]: /docs/sdks/reference/php/agents/agent-base/set-prompt-llm-params +[setprompttext]: /docs/sdks/reference/php/agents/agent-base/set-prompt-text +[setpronunciations]: /docs/sdks/reference/php/agents/agent-base/set-pronunciations +[setwebhookurl]: /docs/sdks/reference/php/agents/agent-base/set-web-hook-url +[updateglobaldata]: /docs/sdks/reference/php/agents/agent-base/update-global-data +[ref-datamap]: /docs/sdks/reference/php/agents/data-map + +`AgentBase` is the central class in the SignalWire AI Agents SDK. It provides a +complete framework for building AI-powered voice agents, combining prompt management, +tool definitions, skill loading, speech configuration, and web serving into a single +composable interface. + +Extends [`Service`][swmlservice] and composes +functionality from nine mixins: `PromptMixin`, `ToolMixin`, `SkillMixin`, `AIConfigMixin`, +`WebMixin`, `AuthMixin`, `ServerlessMixin`, `StateMixin`, and `MCPServerMixin`. + +All setter methods return `self` for fluent method chaining. + + +AgentBase generates a SWML document with the [`ai`][ai] verb. +See the [SWML reference][swml-reference] for the full specification of all +supported parameters and behaviors. + + +## **Properties** + + + The agent's display name. Set at construction time. Used in logging, SIP username + mapping, and the default prompt fallback. + + + + HTTP route path where this agent is served. Used by + [`AgentServer`][agentserver] when hosting + multiple agents on one process. + + + + Network interface the web server binds to. + + + + Port the web server listens on. Defaults to the `PORT` environment variable, falling + back to `3000`. + + + + Unique identifier for this agent instance. Auto-generated as a UUID if not provided. + + + + The Prompt Object Model instance used for structured prompt building. `null` when + `use_pom=False`. + + + + Manager instance for loading and unloading skills. Access via + [`addSkill()`][add-skill] and + [`listSkills()`][list-skills] rather + than directly. + + + + Class-level attribute. Subclasses can set this to declaratively define prompt sections + instead of calling `promptAddSection()` in the constructor. + + + + Explicit `(username, password)` for HTTP Basic Auth on all endpoints. If not set, + credentials are read from `SWML_BASIC_AUTH_USER` / `SWML_BASIC_AUTH_PASSWORD` env vars, + or auto-generated on startup. + + + + Enable Prompt Object Model for structured prompt building. Set to `False` to use + plain text prompts only. + + + + Expiration time in seconds for SWAIG function authentication tokens. + + + + Automatically add an `answer` verb before the AI verb in the SWML document. + + + + Enable call recording. When `True`, a `recordCall` verb is added to the SWML document. + + + + Recording file format. Common values: `"mp4"`, `"wav"`. + + + + Record in stereo (separate channels for each party) when `True`. + + + + Base URL for SWAIG function webhooks. If not set, the SDK auto-detects from the + incoming request or uses `SWML_PROXY_URL_BASE`. + + + + Suppress SDK log output. Useful in testing or when integrating with external logging. + + + + Allow dynamic per-request override of the post-prompt configuration. + + + + Allow dynamic per-request override of input checking behavior. + + + + Path to a JSON config file. If not provided, the SDK searches default paths. + See [`ConfigLoader`][configloader]. + + + + List of native SWAIG function names to enable at construction time (e.g., + `["check_time", "waitForUser"]`). Can also be set later via + [`setNativeFunctions()`][set-native-functions]. + + + + Path to a custom SWML schema file for validation. If not provided, the SDK searches + default paths automatically. + + + + Enable SWML schema validation. Disable with `False` or `SWML_SKIP_SCHEMA_VALIDATION=1` + env var. + + +## **Decorators** + +### tool + +```php +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name=None, description=None, parameters=None, secure=True, fillers=None, webhook_url=None, required=None, **swaig_fields) +function myTool($args, raw_data: null) +{ + return new FunctionResult("Done."); +} + +$agent->serve(); + +``` + +The `@tool` decorator is the recommended way to define SWAIG functions. Use +`@agent.tool()` on a standalone function, or `@AgentBase.tool()` on a method +inside a subclass. Both forms accept the same parameters. + +When parameters are not explicitly provided, the decorator automatically infers the +JSON Schema from PHP type hints on the function signature. + +#### Parameters + + + Function name exposed to the AI. Defaults to the decorated function's `__name__`. + + + + What the function does. The AI reads this to decide when to call it. Defaults to the + function's docstring, or `"Function {name}"` as a fallback. + + + + Explicit JSON Schema for function parameters. If omitted, the schema is + automatically inferred from PHP type hints on the decorated function. + + + + Require token validation on tool calls. + + + + Filler phrases by language code, spoken while the function runs. + + + + External webhook URL. If set, SignalWire calls this URL instead of executing locally. + + + + Required parameter names. Auto-inferred from type hints when not specified. + + + + Additional SWAIG fields (e.g., `wait_file`, `meta_data`). + + +## **Examples** + +### Instance decorator with type inference + +```php {4} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(description="Look up a customer's order status") +function checkOrder($args, raw_data: null) +{ + $order_id = $args["order_id"] ?? null; + return new FunctionResult("Order {$order_id} shipped March 28."); +} + +$agent->serve(); + +``` + +### With explicit parameters + +```php +setPromptText("You are a helpful assistant."); + +// @agent.tool( + name: "search_products", + description: "Search the product catalog", + parameters: { + "type": "object", + "properties": { + "query": ["type" => "string", "description": "Search query"], + "category": ["type" => "string", "description": "Product category"] + } + }, + required: ["query"], + fillers: ["en-US" => ["Searching...", "Let me find that..."]] +); +function searchProducts($args, raw_data: null) +{ + $query = $args["query"] ?? null; + return new FunctionResult("Found 3 results for '{$query}'."); +} + +$agent->serve(); + +``` + +### Class decorator (subclass) + +```php +serve(); + +``` + +### Typed parameters (auto-inferred schema) + +```php +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(description="Calculate shipping cost") +function calculateShipping(float $weight_kg, string $destination, bool express: false) +{ + $cost = $weight_kg * 2.50 if !$express else $weight_kg * 5.00; + return new FunctionResult("Shipping to {$destination}: ${$cost:.2f}"); +} + +$agent->serve(); + +``` + +### Basic agent with a tool + +```php {4} +addLanguage("English", "en-US", "rime.spore"); +$agent->setPromptText("You are a friendly customer support agent."); +$agent->addHints(["SignalWire", "SWML", "SWAIG"]); +$agent->setParams(["temperature" => 0.7, "end_of_speech_timeout": 1000]); + +// Tool decorator: @agent.tool(description="Look up an order by ID") +function lookupOrder($args, raw_data: null) +{ + $order_id = $args["order_id"] ?? null; + return new FunctionResult("Order {$order_id} shipped on March 28."); +} + +$agent->run(); + +``` + +## **Methods** + + + + Configure the answer verb that connects the call. + + + Add a remote function include to the SWAIG configuration. + + + Add a single speech recognition hint to improve transcription accuracy. + + + Add multiple speech recognition hints at once. + + + Add filler phrases for a specific native function and language. + + + Add a language configuration with voice settings for multilingual conversations. + + + Add a speech recognition hint with pattern matching and replacement. + + + Add a SWML verb to run after the AI conversation ends. + + + Add a SWML verb to run after the call is answered but before the AI starts. + + + Add a SWML verb to run before the call is answered. + + + Add a pronunciation rule to correct how the AI speaks a specific word or phrase. + + + Load and activate a skill on the agent. + + + Append query parameters to all SWAIG webhook URLs. + + + Remove all post-AI verbs from the call flow. + + + Remove all post-answer verbs from the call flow. + + + Remove all pre-answer verbs from the call flow. + + + Remove all SWAIG query parameters from the agent. + + + Define multi-step conversation contexts and workflows for complex agent interactions. + + + Programmatically define a SWAIG tool that the AI can invoke during conversations. + + + Enable real-time debug event webhooks from the AI module during calls. + + + Enable SIP-based call routing for this agent. + + + Retrieve the agent's Basic Auth credentials and their origin. + + + Get the full URL for this agent's endpoint, including host, port, and route. + + + Get the agent's display name. + + + Retrieve the current prompt configured on the agent. + + + Check whether a specific skill is currently loaded on the agent. + + + List the names of all currently loaded skills on the agent. + + + Manually set the proxy URL base for webhook callbacks. + + + Register a callback for debug events received at the /debug_events endpoint. + + + Handle post-prompt summaries generated after a conversation ends. + + + Add a new section to the agent's structured prompt. + + + Add a subsection to an existing prompt section. + + + Append content to an existing prompt section or create it if it does not exist. + + + Check whether a named section exists in the agent's prompt. + + + Register a specific SIP username to route calls to this agent. + + + Register a raw SWAIG function dictionary, typically from a DataMap. + + + Unload a skill from the agent. + + + Smart entry point that auto-detects the runtime environment and starts the agent accordingly. + + + Start a FastAPI/uvicorn web server to serve this agent's SWML and SWAIG endpoints. + + + Set a callback for per-request dynamic agent configuration. + + + Set the complete list of remote function includes. + + + Merge data into the global data dictionary available to the AI throughout a conversation. + + + Set filler phrases for native SWAIG functions. + + + Replace all language configurations at once with a list of raw language dictionaries. + + + Set a single AI parameter by key. + + + Configure AI model parameters such as temperature, timeouts, and speech recognition settings. + + + Set the post-prompt used for generating call summaries after a conversation ends. + + + Set LLM parameters specifically for the post-prompt. + + + Override the default URL where post-prompt summaries are delivered. + + + Set LLM parameters specifically for the main prompt. + + + Set the agent's system prompt as a raw text string. + + + Replace all pronunciation rules at once with a list of raw rule dictionaries. + + + Override the default webhook URL used for SWAIG function calls in the SWML document. + + + Update the global data dictionary with new values. + + + Build the AI verb configuration for the SWML document. + + + Clone the agent instance for a specific request context. + + + Get the conversation contexts defined on the agent. + + + Define multiple tools at once for the AI agent. + + + Register a callback for SWAIG function calls. + + + Render the complete SWML document for this agent. + + + Set the list of native SWAIG functions to enable. + + diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/list-skills.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/list-skills.mdx new file mode 100644 index 000000000..a4c61fc82 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/list-skills.mdx @@ -0,0 +1,26 @@ +--- +title: "listSkills" +slug: /reference/php/agents/agent-base/list-skills +description: List the names of all currently loaded skills on the agent. +max-toc-depth: 3 +--- + +List the names of all currently loaded skills on this agent. + +## **Returns** + +`list[string]` -- List of loaded skill names. + +## **Example** + +```php {6} +addSkill("datetime"); +$agent->addSkill("math"); +echo $agent->listSkills(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/manual-set-proxy-url.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/manual-set-proxy-url.mdx new file mode 100644 index 000000000..4ffd2ab02 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/manual-set-proxy-url.mdx @@ -0,0 +1,42 @@ +--- +title: "manualSetProxyUrl" +slug: /reference/php/agents/agent-base/manual-set-proxy-url +description: Manually set the proxy URL base for webhook callbacks. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Manually set the proxy URL base used when constructing webhook callback URLs in the +SWML document. Use this when your agent is behind a reverse proxy, tunnel, or load +balancer and the auto-detected URL is incorrect. + + +You can also set the `SWML_PROXY_URL_BASE` environment variable for the same effect +without calling this method. + + +## **Parameters** + + + The base URL to use for webhooks (e.g., `"https://abc123.ngrok.io"`). Trailing + slashes are automatically stripped. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->manualSetProxyUrl("https://abc123.ngrok.io"); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/on-debug-event.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/on-debug-event.mdx new file mode 100644 index 000000000..9908405d3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/on-debug-event.mdx @@ -0,0 +1,57 @@ +--- +title: "onDebugEvent" +slug: /reference/php/agents/agent-base/on-debug-event +description: Register a callback for debug events received at the /debug_events endpoint. +max-toc-depth: 3 +--- + +[enable-debug-events]: /docs/sdks/reference/php/agents/agent-base/enable-debug-events + +Register a callback for debug events received at the `/debug_events` endpoint. +Use as a decorator. Both sync and async handlers are supported. + + +[`enableDebugEvents()`][enable-debug-events] must be called before events will be delivered. + + +## **Parameters** + + + Callback function with signature `(event_type: string, data: dict)`. + + - `event_type` -- Event label string (e.g., `"barge"`, `"llm_error"`, `"session_start"`, `"step_change"`) + - `data` -- Full event payload including `call_id`, `label`, and event-specific fields + + +## **Returns** + +`callable` -- The handler function, unchanged. This allows `onDebugEvent` to be used as a +decorator. + +## **Example** + +```php {7} +setPromptText("You are a helpful assistant."); +$agent->enableDebugEvents(level: 1); + +// Handler: $agent->onDebugEvent() +function handleDebug($event_type, $data) +{ + if ($event_type == "llm_error") { + echo "LLM error: {$data}"; + } + } elseif ($event_type == "barge") { + echo "Barge detected: {$data['barge_elapsed_ms'] ?? null}ms"; + } + } elseif ($event_type == "step_change") { + echo "Step changed to: {$data['step'] ?? null}"; + } + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/on-function-call.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/on-function-call.mdx new file mode 100644 index 000000000..fec0fb215 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/on-function-call.mdx @@ -0,0 +1,43 @@ +--- +title: "onFunctionCall" +slug: /reference/php/agents/agent-base/on-function-call +description: Handle an incoming SWAIG function call. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-base + +Handle an incoming SWAIG function call. + +## **Parameters** + + + The name identifier. + + + + The function call arguments. + + + + The raw SWAIG request data. + + +## **Returns** + +`?FunctionResult` -- The value, or `null` if not set. + +## **Example** + +```php +onFunctionCall( + name: "plant-lookup", + args: [], + rawData: [] +); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/on-summary.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/on-summary.mdx new file mode 100644 index 000000000..6b22600f7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/on-summary.mdx @@ -0,0 +1,73 @@ +--- +title: "onSummary" +slug: /reference/php/agents/agent-base/on-summary +description: Handle post-prompt summaries generated after a conversation ends. +max-toc-depth: 3 +--- + +[set-post-prompt]: /docs/sdks/reference/php/agents/agent-base/set-post-prompt +[set-post-prompt-url]: /docs/sdks/reference/php/agents/agent-base/set-post-prompt-url + +Callback method invoked when a post-prompt summary is received after a conversation +ends. Override this method in a subclass to process summaries -- for example, saving +them to a CRM, triggering follow-up workflows, or logging call outcomes. + +A post-prompt must be configured via +[`setPostPrompt()`][set-post-prompt] +for summaries to be generated. + + +The default implementation does nothing. You must override it in a subclass or set a +[`setPostPromptUrl()`][set-post-prompt-url] +to receive summaries at an external endpoint. + + +## **Parameters** + + + The summary object generated by the AI based on your post-prompt instructions. + `null` if no summary could be extracted from the response. + + + + The complete raw POST data from the post-prompt request, including metadata + like `call_id` and the full AI response. + + +## **Returns** + +`null` + +## **Example** + +```php {14} +setPromptText("You are a helpful customer support agent."); + self->setPostPrompt(""" + $Summarize $this $call as $JSON:; + - intent: caller's primary intent; + - resolved: yes/$no/$partial; + - sentiment: positive/$neutral/$negative; + """); + } + + public function onSummary($summary, raw_data: null) + { + if ($summary) { + $call_id = $raw_data["call_id"] ?? null if $raw_data else "unknown"; + echo "Call {$call_id} summary: {$summary}"; + // save_to_database(call_id, summary) + } + +$agent = $SupportAgent(); +$agent->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/prompt-add-section.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/prompt-add-section.mdx new file mode 100644 index 000000000..e326a8235 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/prompt-add-section.mdx @@ -0,0 +1,67 @@ +--- +title: "promptAddSection" +slug: /reference/php/agents/agent-base/prompt-add-section +description: Add a new section to the agent's structured prompt. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Add a new section to the prompt. Sections give the AI structured instructions that +are easier to follow than a single block of text. Each section has a title and +optional body text, bullet points, and subsections. + + +POM sections cannot be mixed with `setPromptText()` in the same agent. Use one +approach or the other. + + +## **Parameters** + + + Section heading displayed to the AI. + + + + Section body text. + + + + List of bullet point strings. + + + + Whether the section itself should be numbered. + + + + Whether bullet points should be numbered instead of bulleted. + + + + List of subsection dictionaries, each with `title`, `body`, and optional `bullets`. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {4,7} +promptAddSection("Role", + body: "You are a customer support agent for Acme Corp."); + +$agent->promptAddSection("Guidelines", bullets: [; + "Always greet the caller by name if available", + "Never share internal pricing details", + "Escalate to a human if the caller asks" +]); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/prompt-add-subsection.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/prompt-add-subsection.mdx new file mode 100644 index 000000000..1038d6350 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/prompt-add-subsection.mdx @@ -0,0 +1,51 @@ +--- +title: "promptAddSubsection" +slug: /reference/php/agents/agent-base/prompt-add-subsection +description: Add a subsection to an existing prompt section. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Add a subsection to an existing section. If the parent section does not exist, it is +created automatically. + +## **Parameters** + + + Title of the parent section. + + + + Subsection heading. + + + + Subsection body text. + + + + Subsection bullet points. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {6,8} +promptAddSection("Capabilities", + body: "You can help with the following:"); +$agent->promptAddSubsection("Capabilities", "Orders", + body: "Look up order status, process returns and exchanges."); +$agent->promptAddSubsection("Capabilities", "Billing", + body: "Check account balances and explain recent charges."); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/prompt-add-to-section.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/prompt-add-to-section.mdx new file mode 100644 index 000000000..40e594635 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/prompt-add-to-section.mdx @@ -0,0 +1,51 @@ +--- +title: "promptAddToSection" +slug: /reference/php/agents/agent-base/prompt-add-to-section +description: Append content to an existing prompt section or create it if it does not exist. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Append content to an existing section. If the section does not exist, it is created +automatically. + +## **Parameters** + + + Title of the section to update (or create). + + + + Text to append to the section body. + + + + A single bullet point to add. + + + + Multiple bullet points to add. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5-6} +promptAddSection("Rules", bullets: ["Be polite"]); +$agent->promptAddToSection("Rules", bullet: "Never lie"); +$agent->promptAddToSection("Rules", bullets: [; + "Keep responses concise", + "Ask clarifying questions when needed" +]); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/prompt-has-section.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/prompt-has-section.mdx new file mode 100644 index 000000000..baf82d74a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/prompt-has-section.mdx @@ -0,0 +1,67 @@ +--- +title: "promptHasSection" +slug: /reference/php/agents/agent-base/prompt-has-section +description: Check whether a named section exists in the agent's prompt. +max-toc-depth: 3 +--- + +[prompt-add-section]: /docs/sdks/reference/php/agents/agent-base/prompt-add-section + +Check whether a named section already exists in the agent's POM (Prompt Object Model) +prompt. Useful for conditionally adding content to avoid duplicate sections. + +## **Parameters** + + + The section title to look up. Must match the title passed to + [`promptAddSection()`][prompt-add-section]. + + +## **Returns** + +`bool` -- `True` if a section with the given title exists, `False` otherwise. + +## **Examples** + +### Guard against duplicate sections + +```php {5} +promptAddSection("Greeting", body: "Always greet the caller by name."); +if (!$agent->promptHasSection("Policies")) { + $agent->promptAddSection("Policies", body: "Follow company guidelines."); +} +$agent->serve(); + + +``` + +### Conditional prompt assembly in a subclass + +```php {9} +promptAddSection("Tone", body: "Be empathetic and professional."); + } + + public function addEscalationRules() + { + if (!self->promptHasSection("Escalation")) { + self->promptAddSection("Escalation", bullets: [ + "Transfer to a human if the caller asks three times.", + "Always confirm before transferring." + ]); + } +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/register-sip-username.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/register-sip-username.mdx new file mode 100644 index 000000000..9432a23de --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/register-sip-username.mdx @@ -0,0 +1,37 @@ +--- +title: "registerSipUsername" +slug: /reference/php/agents/agent-base/register-sip-username +description: Register a specific SIP username to route calls to this agent. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Register a specific SIP username that should be routed to this agent. Usernames are +matched case-insensitively. + +## **Parameters** + + + SIP username to register for this agent. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {6-7} +setPromptText("You are a helpful assistant."); +$agent->enableSipRouting(); +$agent->registerSipUsername("help-desk"); +$agent->registerSipUsername("customer-service"); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/register-swaig-function.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/register-swaig-function.mdx new file mode 100644 index 000000000..5fe7bd2e0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/register-swaig-function.mdx @@ -0,0 +1,59 @@ +--- +title: "registerSwaigFunction" +slug: /reference/php/agents/agent-base/register-swaig-function +description: Register a raw SWAIG function dictionary, typically from a DataMap. +max-toc-depth: 3 +--- + +[datamap]: /docs/sdks/reference/php/agents/data-map +[define-tool]: /docs/sdks/reference/php/agents/agent-base/define-tool +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Register a raw SWAIG function definition dictionary. This is the primary way to +register server-side functions created by +[`DataMap`][datamap], which generates complete +SWAIG function definitions including URL mappings, expressions, and output templates. + +Unlike [`defineTool()`][define-tool], +this method does not take a Python handler -- the function executes on the SignalWire +server (for DataMap functions) or at an external webhook URL. + +## **Parameters** + + + Complete SWAIG function definition dictionary. Must follow the SWAIG function + schema, typically generated by `DataMap.toSwaigFunction()`. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {20} +setPromptText("You are a helpful assistant."); + +// Create a DataMap that calls a weather API server-side +$weather_tool = ( + new DataMap("get_weather") + .$description("Get the current weather") + .$parameter("city", type: "string", description: "City name", required: true) + .$webhook("GET", "https://api.weather.example.com/current?city: ${args.city}") + .$output( + response: "The weather in ${args.city} is ${response.temp}F.", + action: [["say" => "Here is the weather information."]] + ) +); + +// Register the DataMap as a SWAIG function +$agent->registerSwaigFunction($weather_tool->toSwaigFunction()); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/remove-skill.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/remove-skill.mdx new file mode 100644 index 000000000..1b905e3d5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/remove-skill.mdx @@ -0,0 +1,35 @@ +--- +title: "removeSkill" +slug: /reference/php/agents/agent-base/remove-skill +description: Unload a skill from the agent. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Unload a skill from this agent. The skill's tools and configuration are removed. + +## **Parameters** + + + Name of the skill to remove. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {6} +addSkill("datetime"); +$agent->addSkill("math"); +$agent->removeSkill("math"); +echo $agent->listSkills(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/render-swml.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/render-swml.mdx new file mode 100644 index 000000000..2e1b9af89 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/render-swml.mdx @@ -0,0 +1,40 @@ +--- +title: "renderSwml" +slug: /reference/php/agents/agent-base/render-swml +description: Render the complete SWML response for a request. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-base + +Render the complete SWML response for a request. + +## **Parameters** + + + The incoming HTTP request body. + Defaults to `null`. + + + + HTTP headers to include. + Defaults to `[]`. + + +## **Returns** + +`array` -- The result array. + +## **Example** + +```php +renderSwml( + requestBody: [], + headers: ["Content-Type" => "application/json"] +); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/run.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/run.mdx new file mode 100644 index 000000000..560b423ad --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/run.mdx @@ -0,0 +1,100 @@ +--- +title: "run" +slug: /reference/php/agents/agent-base/run +description: Smart entry point that auto-detects the runtime environment and starts the agent accordingly. +max-toc-depth: 3 +--- + +[serve]: /docs/sdks/reference/php/agents/agent-base/serve + +Universal entry point that automatically detects the execution environment and starts +the agent in the appropriate mode. In server environments it calls +[`serve()`][serve]. + + +Use `run()` as your default entry point. It makes your agent code portable across +development, Docker, and serverless deployments without changes. + + +## **Parameters** + + + Serverless event object. Pass the Lambda event, Cloud Functions request, or + Azure Functions HttpRequest here. + + + + Serverless context object (Lambda context, etc.). + + + + Override automatic environment detection. Valid values: + - `"server"` -- Force web server mode + - `"lambda"` -- Force AWS Lambda mode + - `"cgi"` -- Force CGI mode + - `"google_cloud_function"` -- Force Google Cloud Functions mode + - `"azure_function"` -- Force Azure Functions mode + + + + Host override for server mode. + + + + Port override for server mode. + + +## **Returns** + +`?array` -- In serverless modes, returns the platform-specific response object. +In server mode, blocks until shutdown and returns `null`. + +## **Examples** + +### Standard entry point + +```php {7} +setPromptText("You are a helpful assistant."); + + $agent->run(); + + +``` + +### AWS Lambda handler + +```php {7} +setPromptText("You are a helpful assistant."); + +function handler($event, $context) +{ + return $agent->run(event: event, context: context); +} + + +``` + +### Google Cloud Function + +```php {7} +setPromptText("You are a helpful assistant."); + +function main($request) +{ + return $agent->run(event: request); +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/serve.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/serve.mdx new file mode 100644 index 000000000..2e5ae7769 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/serve.mdx @@ -0,0 +1,54 @@ +--- +title: "serve" +slug: /reference/php/agents/agent-base/serve +description: Start a FastAPI/uvicorn web server to serve this agent's SWML and SWAIG endpoints. +max-toc-depth: 3 +--- + +[run]: /docs/sdks/reference/php/agents/agent-base/run + +Start a FastAPI web server powered by uvicorn to serve this agent. The server +exposes endpoints for SWML document delivery, SWAIG function execution, +post-prompt summary handling, and health checks. + +This method blocks until the server is shut down (e.g., via SIGINT). + + +For most cases, use [`run()`][run] +instead -- it auto-detects the environment and calls `serve()` in server mode or +dispatches to the appropriate serverless handler. + + +The server automatically includes: +- SWML document endpoint at the agent's route +- SWAIG function endpoints for each registered tool +- `/health` and `/ready` health check endpoints +- Security headers middleware +- SSL support when configured via environment variables + +## **Parameters** + + + Host override. Defaults to the value set in the constructor. + + + + Port override. Defaults to the value set in the constructor. + + +## **Returns** + +`null` -- This method blocks and does not return until the server is stopped. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->serve() # $Blocks $here, $serving $at $http://0.0.0.0:3000/; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-dynamic-config-callback.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-dynamic-config-callback.mdx new file mode 100644 index 000000000..67f2da270 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-dynamic-config-callback.mdx @@ -0,0 +1,57 @@ +--- +title: "setDynamicConfigCallback" +slug: /reference/php/agents/agent-base/set-dynamic-config-callback +description: Set a callback for per-request dynamic agent configuration. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Set a callback function that runs on every incoming request, receiving the actual agent +instance so you can dynamically configure **any** aspect of it -- skills, prompts, +parameters, languages, tools, global data, etc. -- based on the request's query +parameters, body, or headers. + +This is the primary mechanism for multi-tenant or per-caller customization. + +## **Parameters** + + + A function with the signature `(query_params, body_params, headers, agent)`. + Use the `agent` argument to call any configuration method: + - `agent.addSkill(...)` + - `agent.addLanguage(...)` + - `agent.promptAddSection(...)` + - `agent.setParams(...)` + - `agent.setGlobalData(...)` + - `agent.defineTool(...)` + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {13} +setPromptText("You are a helpful assistant."); + +function configurePerRequest($query_params, $body_params, $headers, $agent) +{ + $tier = $query_params["tier"] ?? "standard"; + if ($tier == "premium") { + $agent->addSkill("web_search"); + $agent->setParams(["end_of_speech_timeout" => 500]); + } + $agent->setGlobalData(["tier" => tier]); +} + +$agent->setDynamicConfigCallback($configure_per_request); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-function-includes.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-function-includes.mdx new file mode 100644 index 000000000..e4b8d6c07 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-function-includes.mdx @@ -0,0 +1,56 @@ +--- +title: "setFunctionIncludes" +slug: /reference/php/agents/agent-base/set-function-includes +description: Set the complete list of remote function includes. +max-toc-depth: 3 +--- + +[ai-swaig-includes]: /docs/swml/reference/ai/swaig/includes +[swml-swaig-includes-reference]: /docs/swml/reference/ai/swaig/includes +[add-function-include]: /docs/sdks/reference/php/agents/agent-base/add-function-include +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Replace the entire list of remote SWAIG function includes at once. Each entry must +contain a `url` and a `functions` list. Invalid entries (missing required keys or +non-list `functions`) are silently dropped. + + +This maps to the SWML [`ai.swaig.includes`][ai-swaig-includes] array. +See the [SWML SWAIG includes reference][swml-swaig-includes-reference] for details. + + + +Use [`addFunctionInclude()`][add-function-include] +to append a single include without replacing existing ones. + + +## **Parameters** + + + List of include objects. Each object must have: + - `url` (`string`) -- Remote SWAIG server URL + - `functions` (`list[string]`) -- Function names to include + + Optional keys like `meta_data` are passed through unchanged. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->setFunctionIncludes([; + ["url" => "https://tools.example.com/swaig", "functions": ["lookup_order"]], + ["url" => "https://billing.example.com/swaig", "functions": ["get_invoice", "process_refund"]], +]); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-global-data.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-global-data.mdx new file mode 100644 index 000000000..b0e4c1da0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-global-data.mdx @@ -0,0 +1,46 @@ +--- +title: "setGlobalData" +slug: /reference/php/agents/agent-base/set-global-data +description: Merge data into the global data dictionary available to the AI throughout a conversation. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Merge data into the global data dictionary available to the AI throughout the +conversation. This method merges rather than replaces, so multiple callers (skills, +dynamic config callbacks, etc.) can each contribute keys without overwriting each other. + + +This method is thread-safe. Concurrent calls from different threads or async contexts +are serialized via an internal lock. + + +## **Parameters** + + + Dictionary of key/value pairs to merge into global data. Values can be any + JSON-serializable type. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->setGlobalData({ + "company_name": "Acme Corp", + "support_hours": "9am-5pm EST", + "user_tier": "standard" +}); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-internal-fillers.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-internal-fillers.mdx new file mode 100644 index 000000000..0e3107441 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-internal-fillers.mdx @@ -0,0 +1,46 @@ +--- +title: "setInternalFillers" +slug: /reference/php/agents/agent-base/set-internal-fillers +description: Set filler phrases for native SWAIG functions. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Set filler phrases for native SWAIG functions. Internal fillers are phrases the AI +speaks while executing built-in functions like `check_time`, `next_step`, or +`waitForUser`. They prevent silence during processing and make the conversation +feel more natural. + +## **Parameters** + + + Nested dictionary mapping function names to language-specific filler phrases. + Format: `{"function_name": {"language_code": ["phrase1", "phrase2"]}}`. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->setInternalFillers({ + "next_step": { + "en-US": ["Moving on...", "Great, let's continue..."], + "es": ["Pasando al siguiente paso...", "Continuemos..."] + }, + "check_time": { + "en-US": ["Let me check the time...", "One moment..."] + } +}); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-languages.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-languages.mdx new file mode 100644 index 000000000..2eef76db0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-languages.mdx @@ -0,0 +1,40 @@ +--- +title: "setLanguages" +slug: /reference/php/agents/agent-base/set-languages +description: Replace all language configurations at once with a list of raw language dictionaries. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Replace all language configurations at once with a list of raw language dictionaries. + +## **Parameters** + + + List of language configuration dictionaries. Each dictionary should include `name`, + `code`, and `voice` keys, and optionally `engine`, `model`, `speech_fillers`, + and `function_fillers`. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->setLanguages([; + ["name" => "English", "code": "en-US", "voice": "rime.spore"], + ["name" => "Spanish", "code": "es-MX", "voice": "rime.luna"], + ["name" => "French", "code": "fr-FR", "voice": "rime.soleil"] +]); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-native-functions.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-native-functions.mdx new file mode 100644 index 000000000..e49ad4298 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-native-functions.mdx @@ -0,0 +1,31 @@ +--- +title: "setNativeFunctions" +slug: /reference/php/agents/agent-base/set-native-functions +description: Set the native functions for the AI agent. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-base + +Set the native functions for the AI agent. + +## **Parameters** + + + Array of function definitions. + + +## **Returns** + +`self` -- The the AI agent instance for method chaining. + +## **Example** + +```php +setNativeFunctions([]); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-param.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-param.mdx new file mode 100644 index 000000000..4b528a8d0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-param.mdx @@ -0,0 +1,38 @@ +--- +title: "setParam" +slug: /reference/php/agents/agent-base/set-param +description: Set a single AI parameter by key. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Set a single AI parameter by key. + +## **Parameters** + + + Parameter name (e.g., `"temperature"`, `"end_of_speech_timeout"`). + + + + Parameter value. Type depends on the parameter being set. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->setParam("temperature", 0.5); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-params.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-params.mdx new file mode 100644 index 000000000..4965624ba --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-params.mdx @@ -0,0 +1,136 @@ +--- +title: "setParams" +slug: /reference/php/agents/agent-base/set-params +description: Configure AI model parameters such as temperature, timeouts, and speech recognition settings. +max-toc-depth: 3 +--- + +[ai-params]: /docs/swml/reference/ai/params +[swml-ai-params-reference]: /docs/swml/reference/ai/params +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Set multiple AI parameters at once. Merges into any previously set parameters. + + +These parameters map to the SWML [`ai.params`][ai-params] object. +See the [SWML AI params reference][swml-ai-params-reference] for the full list of +supported fields. + + +## **Parameters** + + + Dictionary of parameter name/value pairs. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +--- + +## AI Parameter Reference + +Parameters set via `setParams()` control the AI model, speech recognition, timing, +and agent behavior. The fields below list commonly used parameters by category. + + +Default values shown below are **server-side defaults** applied by the SignalWire +platform. The SDK itself sends no defaults -- only parameters you explicitly set +are included in the SWML document. + + +### LLM Parameters + + + Output randomness. Range: `0.0` -- `2.0`. Lower values produce more deterministic responses. + + + + Nucleus sampling threshold. Range: `0.0` -- `1.0`. Alternative to temperature for controlling randomness. + + + + Repetition penalty. Range: `-2.0` -- `2.0`. Positive values reduce repetition of token sequences. + + + + Topic diversity. Range: `-2.0` -- `2.0`. Positive values encourage the model to explore new topics. + + + + Maximum response tokens. Range: `1` -- `16385`. + + + + AI model to use (e.g., `"gpt-4o-mini"`, `"gpt-4.1-mini"`, `"nova-micro"`, `"nova-lite"`). + + +### Timing Parameters + + + Silence duration in milliseconds to detect end of speech. Range: `250` -- `10000`. + + + + Idle delay in milliseconds before the AI re-prompts the caller. Range: `0` -- `600000`. + + + + Inactivity delay in milliseconds before the call is automatically disconnected. Range: `10000` -- `3600000`. + + + + Maximum speech duration in milliseconds before the input is finalized. + + +### Behavior Parameters + + + Wait for the caller to speak first before the AI begins talking. + + + + Safety enforcement. When enabled, the AI applies content safety filters. + + + + Transparent barge-in mode. When enabled, caller speech interrupts the AI naturally without discarding context. + + + + Persist the conversation summary after the call ends. + + +### Audio Parameters + + + AI voice volume adjustment. Range: `-50` -- `50`. + + + + URL of an audio file to play as background audio during the conversation. + + + + URL of hold music or a tone string (e.g., `"tone:440"`). + + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->setParams({ + "temperature": 0.7, + "end_of_speech_timeout": 1000, + "attention_timeout": 10000, + "waitForUser": true +}); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-post-prompt-llm-params.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-post-prompt-llm-params.mdx new file mode 100644 index 000000000..4963d5054 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-post-prompt-llm-params.mdx @@ -0,0 +1,38 @@ +--- +title: "setPostPromptLlmParams" +slug: /reference/php/agents/agent-base/set-post-prompt-llm-params +description: Set LLM parameters specifically for the post-prompt. +max-toc-depth: 3 +--- + +[set-prompt-llm-params]: /docs/sdks/reference/php/agents/agent-base/set-prompt-llm-params +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Set LLM parameters specifically for the post-prompt. Accepts the same parameters as +[`setPromptLlmParams()`][set-prompt-llm-params] except `barge_confidence`, which does not apply to post-prompts. + +## **Parameters** + +Same keyword arguments as [`setPromptLlmParams()`][set-prompt-llm-params] (excluding `barge_confidence`). + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {6} +setPromptText("You are a helpful customer support agent."); +$agent->setPostPrompt("Summarize this call as JSON with intent and resolution."); +$agent->setPostPromptLlmParams( + model: "gpt-4o-mini", + temperature: 0.3 +); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-post-prompt-url.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-post-prompt-url.mdx new file mode 100644 index 000000000..bf380b631 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-post-prompt-url.mdx @@ -0,0 +1,37 @@ +--- +title: "setPostPromptUrl" +slug: /reference/php/agents/agent-base/set-post-prompt-url +description: Override the default URL where post-prompt summaries are delivered. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Override the default URL where post-prompt summaries are delivered. By default, +summaries are sent to the agent's own `/post_prompt` endpoint. Use this method to +redirect summaries to an external service. + +## **Parameters** + + + The URL where post-prompt summaries should be POSTed. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {6} +setPromptText("You are a helpful customer support agent."); +$agent->setPostPrompt("Summarize this call as JSON with intent and resolution."); +$agent->setPostPromptUrl("https://analytics.example.com/call-summaries"); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-post-prompt.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-post-prompt.mdx new file mode 100644 index 000000000..6c018b00a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-post-prompt.mdx @@ -0,0 +1,46 @@ +--- +title: "setPostPrompt" +slug: /reference/php/agents/agent-base/set-post-prompt +description: Set the post-prompt used for generating call summaries after a conversation ends. +max-toc-depth: 3 +--- + +[on-summary]: /docs/sdks/reference/php/agents/agent-base/on-summary +[set-post-prompt-url]: /docs/sdks/reference/php/agents/agent-base/set-post-prompt-url +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Set the post-prompt text for summary generation. After a conversation ends, the AI +uses this prompt to analyze the conversation and generate a structured summary. The +summary is delivered to your [`onSummary()`][on-summary] callback or +the [`setPostPromptUrl()`][set-post-prompt-url] endpoint. + +## **Parameters** + + + Instructions for summary generation. Tell the AI what to extract from the + conversation -- for example, caller intent, resolution status, or action items. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a customer support agent for Acme Corp."); +$agent->setPostPrompt("""; +$Summarize $this $conversation as $JSON $with $the $following $fields:; +- caller_intent: What $the $caller $wanted; +- resolution: Whether $their $issue $was $resolved ($yes/$no/$partial); +- action_items: List $of $follow-$up $actions $needed; +- sentiment: Overall $caller $sentiment ($positive/$neutral/$negative); +"""); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-prompt-llm-params.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-prompt-llm-params.mdx new file mode 100644 index 000000000..6f152c9a3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-prompt-llm-params.mdx @@ -0,0 +1,62 @@ +--- +title: "setPromptLlmParams" +slug: /reference/php/agents/agent-base/set-prompt-llm-params +description: Set LLM parameters specifically for the main prompt. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Set LLM parameters specifically for the main prompt. Parameters are passed through +to the SignalWire server and validated against the target model's capabilities. + +## **Parameters** + +Parameters are passed as keyword arguments. Common options: + + + AI model to use (e.g., `"gpt-4o-mini"`, `"gpt-4.1-mini"`, `"nova-micro"`, `"nova-lite"`). + + + + Output randomness. Range: `0.0` -- `2.0`. Default: `0.3`. Lower values produce more + deterministic responses. + + + + Nucleus sampling threshold. Range: `0.0` -- `1.0`. Default: `1.0`. Alternative to temperature. + + + + ASR confidence threshold for barge-in. Higher values make it harder for callers to interrupt. + + + + Topic diversity. Range: `-2.0` -- `2.0`. Default: `0.1`. Positive values encourage new topics. + + + + Repetition control. Range: `-2.0` -- `2.0`. Default: `0.1`. Positive values reduce repetition. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->setPromptLlmParams( + model: "gpt-4.1-mini", + temperature: 0.7, + top_p: 0.9 +); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-prompt-text.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-prompt-text.mdx new file mode 100644 index 000000000..5e0579936 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-prompt-text.mdx @@ -0,0 +1,51 @@ +--- +title: "setPromptText" +slug: /reference/php/agents/agent-base/set-prompt-text +description: Set the agent's system prompt as a raw text string. +max-toc-depth: 3 +--- + +[ai-prompt]: /docs/swml/reference/ai/prompt +[swml-prompt-reference]: /docs/swml/reference/ai/prompt +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Set the agent's system prompt as a raw text string. This is the simplest way to +configure what the AI knows and how it behaves. + + +This sets the SWML [`ai.prompt`][ai-prompt] field. See the +[SWML prompt reference][swml-prompt-reference] for details on prompt behavior. + + + +Cannot be mixed with POM-based prompt sections (`promptAddSection()`) in the same +agent. Use one approach or the other for the main prompt. Contexts can still be used +alongside either approach. + + +## **Parameters** + + + The complete system prompt text. Supports multi-line strings. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {4} +setPromptText("""; +$You $are $a $customer $support $agent for $Acme $Corp.; +$You $help $customers $with $billing $questions, $order $tracking, and $returns.; +$Always $be $polite and $professional.; +"""); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-pronunciations.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-pronunciations.mdx new file mode 100644 index 000000000..40a639a28 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-pronunciations.mdx @@ -0,0 +1,39 @@ +--- +title: "setPronunciations" +slug: /reference/php/agents/agent-base/set-pronunciations +description: Replace all pronunciation rules at once with a list of raw rule dictionaries. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Replace all pronunciation rules at once with a list of raw rule dictionaries. + +## **Parameters** + + + List of pronunciation rule dictionaries. Each dictionary must contain `replace` and + `with` keys, and optionally `ignore_case`. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->setPronunciations([; + ["replace" => "SQL", "with": "sequel"], + ["replace" => "SWML", "with": "swimmel", "ignore_case": true], + ["replace" => "IEEE", "with": "I triple E"] +]); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/set-web-hook-url.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/set-web-hook-url.mdx new file mode 100644 index 000000000..fc0c07c67 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/set-web-hook-url.mdx @@ -0,0 +1,43 @@ +--- +title: "setWebHookUrl" +slug: /reference/php/agents/agent-base/set-web-hook-url +description: Override the default webhook URL used for SWAIG function calls in the SWML document. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Override the default webhook URL used for SWAIG function calls in the generated SWML +document. By default, the SDK computes this URL from the agent's host, port, and +route. Use this method when your agent is behind a reverse proxy, load balancer, or +tunnel (e.g., ngrok) and the auto-detected URL does not match the external address. + + +You can also set the `SWML_PROXY_URL_BASE` environment variable to override the base +URL globally without calling this method. + + +## **Parameters** + + + The full URL that SignalWire should use to reach this agent's SWAIG endpoints. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {6} +setPromptText("You are a helpful assistant."); +// Agent is behind ngrok +$agent->setWebHookUrl("https://abc123.ngrok.io/support"); +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-base/update-global-data.mdx b/fern/products/sdks/pages/reference/php/agents/agent-base/update-global-data.mdx new file mode 100644 index 000000000..4a52c3b24 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-base/update-global-data.mdx @@ -0,0 +1,50 @@ +--- +title: "updateGlobalData" +slug: /reference/php/agents/agent-base/update-global-data +description: Update the global data dictionary with new values. +max-toc-depth: 3 +--- + +[set-global-data]: /docs/sdks/reference/php/agents/agent-base/set-global-data +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +Update the global data with new values. Functionally identical to +[`setGlobalData()`][set-global-data] -- +both merge the provided dictionary into the existing global data. + +## **Parameters** + + + Dictionary of key/value pairs to merge into global data. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns self for method chaining. + +## **Example** + +```php {10} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(description="Authenticate the caller") +function authenticate($args, raw_data: null) +{ + $user = ["name" => "Alice", "tier": "gold"] # $Replace $with $your $user $lookup; + $agent->updateGlobalData({ + "authenticated": true, + "user_name": user["name"], + "user_tier": user["tier"] + }); + return new FunctionResult("Welcome back, {$user['name']}."); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/get-agent.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/get-agent.mdx new file mode 100644 index 000000000..e10536a40 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/get-agent.mdx @@ -0,0 +1,45 @@ +--- +title: "getAgent" +slug: /reference/php/agents/agent-server/get-agent +description: "Retrieve a specific registered agent by its route." +max-toc-depth: 3 +--- + +[agentbase]: /docs/sdks/reference/php/agents/agent-base + +Retrieve a specific agent by its route. Returns `null` if no agent is registered at +the given path. + +## **Parameters** + + + The route to look up (e.g., `"/sales"`). Leading slashes are added and trailing slashes + are stripped automatically for matching. + + +## **Returns** + +[`AgentBase`][agentbase] | `null` -- The agent instance +registered at the route, or `null` if not found. + +## **Example** + +```php {8} +register($agent1); +$agent = $server->getAgent("/sales"); +if ($agent) { + echo "Found: {$agent->getName()}"; +} +} else { + echo "No agent at /sales"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/get-agents.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/get-agents.mdx new file mode 100644 index 000000000..58537d99a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/get-agents.mdx @@ -0,0 +1,36 @@ +--- +title: "getAgents" +slug: /reference/php/agents/agent-server/get-agents +description: "Return all registered agents as a list of route/agent tuples." +max-toc-depth: 3 +--- + +[agentbase]: /docs/sdks/reference/php/agents/agent-base + +Return all registered agents as a list of `(route, agent)` tuples. Useful for introspection, +logging, or building admin interfaces. + +## **Returns** + +`list[tuple[string, AgentBase]]` -- A list of tuples where the first element is the route string +(e.g., `"/sales"`) and the second is the [`AgentBase`][agentbase] instance. + +## **Example** + +```php {9} +register($agent1); +$server->register($agent2); +for $route, $agent $in $server->getAgents():; + echo "{$route}: {$agent->getName()}"; +// /sales: sales +// /support: support + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/get-host.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/get-host.mdx new file mode 100644 index 000000000..544d49884 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/get-host.mdx @@ -0,0 +1,29 @@ +--- +title: "getHost" +slug: /reference/php/agents/agent-server/get-host +description: Get the host of the agent server. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-server + +Get the host of the agent server. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- The host value. + +## **Example** + +```php +getHost(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/get-port.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/get-port.mdx new file mode 100644 index 000000000..74fddec44 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/get-port.mdx @@ -0,0 +1,29 @@ +--- +title: "getPort" +slug: /reference/php/agents/agent-server/get-port +description: Get the port of the agent server. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-server + +Get the port of the agent server. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`int` -- The integer value. + +## **Example** + +```php +getPort(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/get-sip-username-mapping.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/get-sip-username-mapping.mdx new file mode 100644 index 000000000..869ea4fb1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/get-sip-username-mapping.mdx @@ -0,0 +1,29 @@ +--- +title: "getSipUsernameMapping" +slug: /reference/php/agents/agent-server/get-sip-username-mapping +description: Get the sip username mapping of the agent server. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-server + +Get the sip username mapping of the agent server. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`array` -- The result array. + +## **Example** + +```php +getSipUsernameMapping(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/handle-request.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/handle-request.mdx new file mode 100644 index 000000000..f4d05dd8e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/handle-request.mdx @@ -0,0 +1,50 @@ +--- +title: "handleRequest" +slug: /reference/php/agents/agent-server/handle-request +description: Handle an incoming request. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-server + +Handle an incoming request. + +## **Parameters** + + + The HTTP method. + + + + The request path. + + + + HTTP headers to include. + Defaults to `[]`. + + + + The request body. + Defaults to `null`. + + +## **Returns** + +`array` -- The result array. + +## **Example** + +```php +handleRequest( + method: "GET", + path: "/plants", + headers: ["Content-Type" => "application/json"], + body: "Hello" +); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/index.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/index.mdx new file mode 100644 index 000000000..d66273e1c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/index.mdx @@ -0,0 +1,116 @@ +--- +title: "AgentServer" +slug: /reference/php/agents/agent-server +description: Host multiple AI agents on a single FastAPI server with shared routing and health checks. +max-toc-depth: 3 +--- + +[agentbase]: /docs/sdks/reference/php/agents/agent-base +[agentbase-serve]: /docs/sdks/reference/php/agents/agent-base/serve +[agentbase-run]: /docs/sdks/reference/php/agents/agent-base/run +[getagent]: /docs/sdks/reference/php/agents/agent-server/get-agent +[getagents]: /docs/sdks/reference/php/agents/agent-server/get-agents +[register]: /docs/sdks/reference/php/agents/agent-server/register +[run]: /docs/sdks/reference/php/agents/agent-server/run +[unregister]: /docs/sdks/reference/php/agents/agent-server/unregister + +AgentServer hosts multiple [`AgentBase`][agentbase] instances +on a single FastAPI process. Each agent registers at its own URL route, and the server provides +unified health monitoring, SIP-based routing, and static file serving. Use AgentServer when you +have several related agents (sales, support, billing) that share the same deployment environment. + +For a single agent, use [`AgentBase.serve()`][agentbase-serve] +or [`AgentBase.run()`][agentbase-run] instead. + +## **Properties** + + + The underlying FastAPI application. Use this to add custom routes, middleware, or to run + the server with an external ASGI server like gunicorn. + + + + Dictionary mapping route strings to registered [`AgentBase`][agentbase] instances. + + + + The host address the server binds to. + + + + The port the server listens on. + + + + The logging level for the server. + + +## **Methods** + + + + Retrieve a specific registered agent by its route. + + + Return all registered agents as a list of route/agent tuples. + + + Register an agent at a URL route on the server. + + + Start the multi-agent server with automatic environment detection. + + + Remove an agent from the server's registry by route. + + + +## **Example** + +```php {17} +addLanguage("English", "en-US", "rime.spore"); + self->promptAddSection("Role", "You are a sales representative."); + } + +class SupportAgent extends AgentBase +{ + public function __construct() + { + $super().$__init__(name: "support-agent", route: "/support"); + self->addLanguage("English", "en-US", "rime.spore"); + self->promptAddSection("Role", "You are a support specialist."); + } + + $server = new AgentServer(host: "0.0.0.0", port: 3000); + $server->register($SalesAgent(), "/sales"); + $server->register($SupportAgent(), "/support"); + $server->run(); + +``` + +After starting, agents are available at: + +| Endpoint | Description | +|----------|-------------| +| `http://localhost:3000/sales` | Sales agent | +| `http://localhost:3000/support` | Support agent | +| `http://localhost:3000/health` | Health check | +| `http://localhost:3000/ready` | Readiness check | +| [`getHost()`](/docs/sdks/reference/php/agents/agent-server/get-host) | Get the host. | +| [`getPort()`](/docs/sdks/reference/php/agents/agent-server/get-port) | Get the port. | +| [`getSipUsernameMapping()`](/docs/sdks/reference/php/agents/agent-server/get-sip-username-mapping) | Get the sip username mapping. | +| [`handleRequest()`](/docs/sdks/reference/php/agents/agent-server/handle-request) | Handle request. | +| [`isSipRoutingEnabled()`](/docs/sdks/reference/php/agents/agent-server/is-sip-routing-enabled) | Check if sip routing enabled. | +| [`registerSipUsername()`](/docs/sdks/reference/php/agents/agent-server/register-sip-username) | Register sip username. | +| [`serve()`](/docs/sdks/reference/php/agents/agent-server/serve) | Start the HTTP server. | +| [`serveStatic()`](/docs/sdks/reference/php/agents/agent-server/serve-static) | Serve static files. | +| [`setupSipRouting()`](/docs/sdks/reference/php/agents/agent-server/setup-sip-routing) | Set the up sip routing. | diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/is-sip-routing-enabled.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/is-sip-routing-enabled.mdx new file mode 100644 index 000000000..960078d77 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/is-sip-routing-enabled.mdx @@ -0,0 +1,29 @@ +--- +title: "isSipRoutingEnabled" +slug: /reference/php/agents/agent-server/is-sip-routing-enabled +description: Check whether sip routing enabled is enabled. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-server + +Check whether sip routing enabled is enabled. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`bool` -- Whether the condition is true. + +## **Example** + +```php +isSipRoutingEnabled(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/register-sip-username.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/register-sip-username.mdx new file mode 100644 index 000000000..63da1d682 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/register-sip-username.mdx @@ -0,0 +1,38 @@ +--- +title: "registerSipUsername" +slug: /reference/php/agents/agent-server/register-sip-username +description: Register a sip username. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-server + +Register a sip username. + +## **Parameters** + + + The SIP username. + + + + The route path. + + +## **Returns** + +`self` -- The the agent server instance for method chaining. + +## **Example** + +```php +registerSipUsername( + username: "sip-user", + route: "/plants" +); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/register.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/register.mdx new file mode 100644 index 000000000..977e0a547 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/register.mdx @@ -0,0 +1,54 @@ +--- +title: "register" +slug: /reference/php/agents/agent-server/register +description: "Register an agent at a URL route on the server." +max-toc-depth: 3 +--- + +[agentbase]: /docs/sdks/reference/php/agents/agent-base + +Register an [`AgentBase`][agentbase] instance at a URL route +on the server. The agent's FastAPI router is mounted at the specified prefix so all of its +endpoints (SWML, SWAIG, debug, post-prompt) become available under that path. + + +Registering a duplicate route raises `ValueError`. Each route can only host one agent. + + +## **Parameters** + + + The agent instance to register. Must be an [`AgentBase`][agentbase] + subclass. + + + + URL path prefix for this agent (e.g., `"/sales"`). If omitted, the agent's own `route` + property is used. Leading slashes are added and trailing slashes are stripped automatically. + + +## **Returns** + +`null` + +## **Example** + +```php {10} +promptAddSection("Role", "You are a sales rep."); + } + +$server = new AgentServer(port: 3000); +$server->register($SalesAgent(), "/sales"); +$server->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/run.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/run.mdx new file mode 100644 index 000000000..e46b78792 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/run.mdx @@ -0,0 +1,105 @@ +--- +title: "run" +slug: /reference/php/agents/agent-server/run +description: Start the multi-agent server with automatic environment detection. +max-toc-depth: 3 +--- + +Universal entry point that detects the execution environment and starts the server +accordingly. In standard server mode it launches uvicorn; in serverless environments +(AWS Lambda, CGI) it processes the incoming request and returns a response. + + +This method blocks in server mode. For production deployments behind gunicorn or +another ASGI server, use `server.app` directly instead of calling `run()`. + + +## **Parameters** + + + Serverless event object (AWS Lambda, Google Cloud Functions). Pass the Lambda handler's + `event` parameter here. Ignored in server mode. + + + + Serverless context object (AWS Lambda, Google Cloud Functions). Pass the Lambda handler's + `context` parameter here. Ignored in server mode. + + + + Override the host set in the constructor. Only applies in server mode. + + + + Override the port set in the constructor. Only applies in server mode. + + +## **Returns** + +`null` in server mode (blocks until shutdown). In Lambda mode, returns a response `dict` +with `statusCode`, `headers`, and `body`. In CGI mode, returns the formatted response string. + +## **Examples** + +### Server Mode + +```php {9} +setPromptText("You are a helpful assistant."); + +$server = new AgentServer(host: "0.0.0.0", port: 3000); +$server->register($agent); +$server->run(); + + +``` + +### AWS Lambda + +```php {11} +setPromptText("You are a helpful assistant."); + +$server = new AgentServer(); +$server->register($agent); + +function lambdaHandler($event, $context) +{ + return $server->run($event, $context); +} + + +``` + +### Gunicorn (external ASGI server) + +```php +setPromptText("You are a helpful assistant."); + +$server = new AgentServer(); +$server->register($agent); + +// Expose the FastAPI app for gunicorn: +// gunicorn app:app -k uvicorn.workers.UvicornWorker +$app = $server->app; + + +``` + + +If `SWML_SSL_ENABLED` is set to `true` in the environment along with `SWML_SSL_CERT_PATH` +and `SWML_SSL_KEY_PATH`, the server starts with HTTPS automatically. + diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/serve-static.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/serve-static.mdx new file mode 100644 index 000000000..dc8dc81f9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/serve-static.mdx @@ -0,0 +1,38 @@ +--- +title: "serveStatic" +slug: /reference/php/agents/agent-server/serve-static +description: Serve static files from a directory. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-server + +Serve static files from a directory. + +## **Parameters** + + + The directory path. + + + + URL prefix for serving static files. + + +## **Returns** + +`self` -- The the agent server instance for method chaining. + +## **Example** + +```php +serveStatic( + directory: "/var/www/static", + urlPrefix: "/static" +); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/serve.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/serve.mdx new file mode 100644 index 000000000..f59043f99 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/serve.mdx @@ -0,0 +1,29 @@ +--- +title: "serve" +slug: /reference/php/agents/agent-server/serve +description: Start the HTTP server and listen for requests. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-server + +Start the HTTP server and listen for requests. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`void` -- + +## **Example** + +```php +serve(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/setup-sip-routing.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/setup-sip-routing.mdx new file mode 100644 index 000000000..a053b5d99 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/setup-sip-routing.mdx @@ -0,0 +1,29 @@ +--- +title: "setupSipRouting" +slug: /reference/php/agents/agent-server/setup-sip-routing +description: Set the up sip routing for the agent server. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/agent-server + +Set the up sip routing for the agent server. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`self` -- The the agent server instance for method chaining. + +## **Example** + +```php +setupSipRouting(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/agent-server/unregister.mdx b/fern/products/sdks/pages/reference/php/agents/agent-server/unregister.mdx new file mode 100644 index 000000000..b29fb1480 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/agent-server/unregister.mdx @@ -0,0 +1,41 @@ +--- +title: "unregister" +slug: /reference/php/agents/agent-server/unregister +description: "Remove an agent from the server's registry by route." +max-toc-depth: 3 +--- + +Remove an agent from the server's registry. The agent's routes are no longer tracked, +though FastAPI does not fully remove mounted routers at runtime. + + +Because FastAPI does not support unmounting routers, the agent's HTTP routes may still +respond until the server restarts. This method primarily removes the agent from the +internal registry used by `getAgents()`, SIP routing, and the health endpoint. + + +## **Parameters** + + + The route of the agent to remove (e.g., `"/sales"`). + + +## **Returns** + +`bool` -- `True` if the agent was found and removed, `False` if no agent exists at that route. + +## **Example** + +```php {7} +register(new AgentBase(name: "sales", route: "/sales")); + +$removed = $server->unregister("/sales"); +echo $removed; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/bedrock-agent/index.mdx b/fern/products/sdks/pages/reference/php/agents/bedrock-agent/index.mdx new file mode 100644 index 000000000..854d9d103 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/bedrock-agent/index.mdx @@ -0,0 +1,162 @@ +--- +title: "BedrockAgent" +slug: /reference/php/agents/bedrock-agent +description: "Amazon Bedrock voice-to-voice agent extending AgentBase." +max-toc-depth: 3 +--- + +[agentbase]: /docs/sdks/reference/php/agents/agent-base +[amazon-bedrock]: /docs/swml/reference/amazon-bedrock +[swml-bedrock-reference]: /docs/swml/reference/amazon-bedrock + +BedrockAgent extends [`AgentBase`][agentbase] +to use Amazon Bedrock's voice-to-voice model as the AI backend. It generates SWML +with the `amazon_bedrock` verb instead of `ai`, while maintaining full +compatibility with all standard agent features: prompts (text and POM), skills, +SWAIG functions, post-prompt, and dynamic configuration. + +Extends [`AgentBase`][agentbase] -- inherits +all parent properties and methods. + + +BedrockAgent generates SWML with the [`amazon_bedrock`][amazon-bedrock] verb +instead of `ai`. See the [SWML bedrock reference][swml-bedrock-reference] for the +full specification. + + +## **Properties** + + + Agent name. + + + + HTTP route for the agent endpoint. + + + + Initial system prompt. Can be overridden later with `setPromptText()`. + + + + Bedrock voice identifier (e.g., `"matthew"`, `"joanna"`). + + + + Generation temperature. Range: 0 to 1. + + + + Nucleus sampling parameter. Range: 0 to 1. + + + + Maximum tokens to generate per response. + + + + Additional arguments passed to the AgentBase constructor (e.g., `host`, + `port`). + + +## **Methods** + + + + +## **Overridden Behavior** + +BedrockAgent overrides several AgentBase methods to adapt for the Bedrock +voice-to-voice model: + +| Method | Behavior | +|--------|----------| +| `set_llm_model()` | Logs a warning and does nothing. Bedrock uses a fixed voice-to-voice model. | +| `set_llm_temperature()` | Redirects to `set_inference_params(temperature=...)`. | +| `setPromptLlmParams()` | Logs a warning. Use `set_inference_params()` instead. | +| `setPostPromptLlmParams()` | Logs a warning. Bedrock post-prompt uses OpenAI configured in the platform. | + + +Parameters specific to text-based LLMs (`barge_confidence`, `presence_penalty`, +`frequency_penalty`) are automatically filtered out during SWML rendering and +have no effect on Bedrock agents. + + +Prompt methods (`setPromptText()`, `setPromptPom()`, `promptAddSection()`, +etc.) work normally. The prompt structure is built the same way as AgentBase +and then included in the `amazon_bedrock` verb. + +--- + +## **Examples** + +### Basic Bedrock agent with a tool + +```php {4} +promptAddSection("Guidelines", "Be concise and professional."); +$agent->addLanguage("English", "en-US", "rime.spore"); + +// @agent.tool( + description: "Look up order status", + parameters: { + "type": "object", + "properties": { + "order_id": ["type" => "string", "description": "Order ID"] + }, + "required": ["order_id"] + } +); +function checkOrder($args, $raw_data) +{ + $order_id = $args["order_id"] ?? ""; + return new FunctionResult("Order {$order_id} is shipped and arriving tomorrow."); +} + +// Adjust inference parameters at runtime +$agent->set_voice("matthew"); +$agent->set_inference_params(temperature: 0.3, top_p: 0.95); + + $agent->run(); + +``` + +### Multi-agent server with Bedrock + +```php {8} +setPromptText("You are a general assistant."); + +// Bedrock voice-to-voice agent +$bedrock_agent = new BedrockAgent( + name: "bedrock", + route: "/bedrock", + system_prompt: "You are a voice-optimized assistant.", + voice_id: "matthew" +); + +$server = new AgentServer(); +$server->register($standard_agent); +$server->register($bedrock_agent); + + $server->run(); + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/cli/index.mdx b/fern/products/sdks/pages/reference/php/agents/cli/index.mdx new file mode 100644 index 000000000..14344b292 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/cli/index.mdx @@ -0,0 +1,104 @@ +--- +title: "CLI Tools" +slug: /reference/php/agents/cli +description: "Command-line tools for testing, searching, and scaffolding." +max-toc-depth: 3 +--- + +The SignalWire Agents SDK ships with command-line tools for local development, +testing, knowledge base management, project scaffolding, and deployment. All CLI +tools are installed automatically with the SDK package and available on your PATH +after installation. + +```bash +composer require signalwire/sdk +``` + +## Available Tools + +| Command | Purpose | +|---------|---------| +| [`swaig-test`][swaig-test] | Test SWAIG functions and generate SWML output locally | +| [`sw-search`][sw-search] | Build, search, and validate vector search indexes | +| [`sw-agent-init`][sw-agent-init] | Scaffold new agent projects with templates | +| [`sw-agent-dokku`][sw-agent-dokku] | Deploy agents to Dokku hosting | +| [`mcp-gateway`][mcp-gateway] | Bridge MCP servers to SWAIG functions | + +## Common Patterns + +### Local Development Workflow + +```bash +# 1. Create a new project +sw-agent-init my-agent + +# 2. Inspect the generated SWML +swaig-test agents/main_agent.py --dump-swml + +# 3. List available tools +swaig-test agents/main_agent.py --list-tools + +# 4. Test a specific function +swaig-test agents/main_agent.py --exec get_info --topic "SignalWire" +``` + +### Building a Knowledge Base + +```bash +# Build a search index from documentation +sw-search ./docs --output knowledge.swsearch + +# Verify the index +sw-search validate knowledge.swsearch + +# Test search queries +sw-search search knowledge.swsearch "how to create an agent" +``` + +### Deployment + +```bash +# Deploy to Dokku +sw-agent-dokku init my-agent --host dokku.example.com +sw-agent-dokku deploy +``` + +## Installation Extras + +Some CLI tools require optional dependencies: + +| Extra | Install Command | Required For | +|-------|-----------------|--------------| +| `search` | `composer require "signalwire[search]"` | `sw-search` build and query | +| `search-full` | `composer require "signalwire[search-full]"` | PDF and DOCX processing | +| `search-nlp` | `composer require "signalwire[search-nlp]"` | Advanced NLP features (spaCy) | +| `search-queryonly` | `composer require "signalwire[search-queryonly]"` | Query-only mode (smaller install) | +| `pgvector` | `composer require "signalwire[pgvector]"` | PostgreSQL vector storage | + + + + Test SWAIG functions, generate SWML, and simulate serverless environments. + + + Build, search, and validate vector search indexes for agent knowledge bases. + + + Scaffold new agent projects with configurable templates and platform targets. + + + Deploy and manage agents on Dokku with CI/CD support. + + + Bridge MCP protocol servers to SignalWire SWAIG functions. + + diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/flask-decorator.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/flask-decorator.mdx new file mode 100644 index 000000000..375051c6c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/flask-decorator.mdx @@ -0,0 +1,51 @@ +--- +title: "flaskDecorator" +slug: /reference/php/agents/configuration/auth-handler/flask-decorator +description: Flask decorator for protecting routes with authentication. +max-toc-depth: 3 +--- + +[mcp-gateway]: /docs/sdks/reference/php/agents/cli/mcp-gateway + +Flask decorator for protecting routes. Tries Bearer token, API key, and Basic Auth +in order. Returns a `401` response if all methods fail. + +## **Parameters** + + + The Flask view function to protect. + + +## **Returns** + +`callable` -- The wrapped function that checks authentication before calling the +original view. + +## **Example** + +```php {11} + "authenticated"]; +} + + +``` + + +The Flask decorator is used by the +[`mcp-gateway`][mcp-gateway] service. +For agent-based applications, use the FastAPI dependency instead. + diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/get-auth-info.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/get-auth-info.mdx new file mode 100644 index 000000000..7a09bf14b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/get-auth-info.mdx @@ -0,0 +1,35 @@ +--- +title: "getAuthInfo" +slug: /reference/php/agents/configuration/auth-handler/get-auth-info +description: Get a summary of configured authentication methods. +max-toc-depth: 3 +--- + +Get a summary of which authentication methods are configured and their settings. +Sensitive values (passwords, tokens, keys) are not included. + +## **Returns** + +`dict[string, mixed]` -- Dictionary with keys for each enabled method (`basic`, `bearer`, +`api_key`), each containing `enabled: True` and relevant non-sensitive metadata. + +## **Example** + +```php {6} +get_auth_info(); + +echo $info; +// { +// 'basic': {'enabled': True, 'username': 'signalwire'}, +// 'bearer': {'enabled': True, 'hint': 'Use Authorization: Bearer '}, +// 'api_key': {'enabled': True, 'header': 'X-API-Key', 'hint': 'Use X-API-Key: '} +// } + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/get-fastapi-dependency.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/get-fastapi-dependency.mdx new file mode 100644 index 000000000..90de43c59 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/get-fastapi-dependency.mdx @@ -0,0 +1,53 @@ +--- +title: "getFastapiDependency" +slug: /reference/php/agents/configuration/auth-handler/get-fastapi-dependency +description: Get a FastAPI dependency function for protecting routes. +max-toc-depth: 3 +--- + +Get a FastAPI dependency function that can be used with `Depends()` to protect +routes. The dependency tries each enabled auth method in order: Bearer token, +Basic Auth, API key. + +## **Parameters** + + + When `True`, unauthenticated requests pass through with + `{"authenticated": False}` instead of raising a 401 error. + + +## **Returns** + +`callable` -- An async function suitable for use as a FastAPI dependency. +Returns a dict with `authenticated` (bool) and `method` (str or None) keys. + +## **Example** + +```php {9,16} +get_fastapi_dependency(); + +// @app.get("/protected") +$async $def $protected_route(auth_result: Depends($auth_dep)):; + return ["method" => auth_result["method"]]; + +// Optional auth -- don't reject unauthenticated requests +$optional_dep = $auth->get_fastapi_dependency(optional: true); + +// @app.get("/public") +$async $def $public_route(auth_result: Depends($optional_dep)):; + if ($auth_result["authenticated"]) { + return ["user" => "authenticated"]; +} + return ["user" => "anonymous"]; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/index.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/index.mdx new file mode 100644 index 000000000..3ec5795c5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/index.mdx @@ -0,0 +1,83 @@ +--- +title: "AuthHandler" +slug: /reference/php/agents/configuration/auth-handler +description: "Unified authentication handler for Basic Auth, Bearer tokens, and API keys." +max-toc-depth: 3 +--- + +[mcp-gateway]: /docs/sdks/reference/php/agents/cli/mcp-gateway +[securityconfig]: /docs/sdks/reference/php/agents/configuration/security-config +[flaskdecorator]: /docs/sdks/reference/php/agents/configuration/auth-handler/flask-decorator +[getauthinfo]: /docs/sdks/reference/php/agents/configuration/auth-handler/get-auth-info +[getfastapidependency]: /docs/sdks/reference/php/agents/configuration/auth-handler/get-fastapi-dependency +[verifyapikey]: /docs/sdks/reference/php/agents/configuration/auth-handler/verify-api-key +[verifybasicauth]: /docs/sdks/reference/php/agents/configuration/auth-handler/verify-basic-auth +[verifybearertoken]: /docs/sdks/reference/php/agents/configuration/auth-handler/verify-bearer-token + +`AuthHandler` provides a unified authentication layer supporting HTTP Basic Auth, +Bearer tokens, and API keys. It integrates with both FastAPI (as a dependency) and +Flask (as a decorator), and is used internally by the +[`mcp-gateway`][mcp-gateway] and agent +webhook endpoints. + +```php + + A [`SecurityConfig`][securityconfig] + instance that provides the authentication credentials. The handler reads: + - Basic auth username/password from `get_basic_auth()` + - Bearer token from the `bearer_token` attribute (if set) + - API key and header name from the `api_key` and `api_key_header` attributes (if set) + + +## **Methods** + + + + Flask decorator for protecting routes with authentication. + + + Get a summary of configured authentication methods. + + + Get a FastAPI dependency function for protecting routes. + + + Verify an API key using constant-time comparison. + + + Verify HTTP Basic Auth credentials using constant-time comparison. + + + Verify a Bearer token using constant-time comparison. + + + +## **Example** + +```php {5} +get_auth_info(); +echo $info; +// {'basic': {'enabled': True, 'username': 'signalwire'}} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/verify-api-key.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/verify-api-key.mdx new file mode 100644 index 000000000..ed6252eed --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/verify-api-key.mdx @@ -0,0 +1,35 @@ +--- +title: "verifyApiKey" +slug: /reference/php/agents/configuration/auth-handler/verify-api-key +description: Verify an API key using constant-time comparison. +max-toc-depth: 3 +--- + +Verify an API key using constant-time comparison. + +## **Parameters** + + + The API key string to verify. + + +## **Returns** + +`bool` -- `True` if the key matches. Returns `False` if API key authentication +is not enabled. + +## **Example** + +```php {6} +verify_api_key("my-secret-api-key"); + +echo "API key valid: {$is_valid}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/verify-basic-auth.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/verify-basic-auth.mdx new file mode 100644 index 000000000..e70189906 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/verify-basic-auth.mdx @@ -0,0 +1,40 @@ +--- +title: "verifyBasicAuth" +slug: /reference/php/agents/configuration/auth-handler/verify-basic-auth +description: Verify HTTP Basic Auth credentials using constant-time comparison. +max-toc-depth: 3 +--- + +Verify HTTP Basic Auth credentials using constant-time comparison. + +## **Parameters** + + + FastAPI `HTTPBasicCredentials` object containing `username` and `password` attributes. + + +## **Returns** + +`bool` -- `True` if both username and password match the configured values. + +## **Example** + +```php {9} +security $import $HTTPBasicCredentials; +use SignalWire\Core\SecurityConfig\SecurityConfig; +use SignalWire\Core\AuthHandler\AuthHandler; + +$security = $SecurityConfig(); +$auth = $AuthHandler($security); + +$creds = $HTTPBasicCredentials(username: "signalwire", password: "secret"); +if ($auth->verify_basic_auth($creds)) { + echo "Authenticated"; +} +} else { + echo "Authentication failed"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/verify-bearer-token.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/verify-bearer-token.mdx new file mode 100644 index 000000000..d85fdde46 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/auth-handler/verify-bearer-token.mdx @@ -0,0 +1,46 @@ +--- +title: "verifyBearerToken" +slug: /reference/php/agents/configuration/auth-handler/verify-bearer-token +description: Verify a Bearer token using constant-time comparison. +max-toc-depth: 3 +--- + +[ref-securityconfig]: /docs/sdks/reference/php/agents/configuration/security-config + +Verify a Bearer token using constant-time comparison. + +## **Parameters** + + + FastAPI `HTTPAuthorizationCredentials` object containing the `credentials` + (token) attribute. + + +## **Returns** + +`bool` -- `True` if the token matches the configured bearer token. Returns `False` +if bearer authentication is not enabled. + +## **Example** + +```php {9} +security $import $HTTPAuthorizationCredentials; +use SignalWire\Core\SecurityConfig\SecurityConfig; +use SignalWire\Core\AuthHandler\AuthHandler; + +$security = $SecurityConfig(); +$auth = $AuthHandler($security); + +$creds = $HTTPAuthorizationCredentials(scheme: "Bearer", credentials: "my-token"); +$is_valid = $auth->verify_bearer_token($creds); + +echo "Bearer token valid: {$is_valid}"; + + +``` + + +Bearer token authentication is only available when the [`SecurityConfig`][ref-securityconfig] instance +has a `bearer_token` attribute set (typically via config file). + diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/find-config-file.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/find-config-file.mdx new file mode 100644 index 000000000..d02d18cd2 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/find-config-file.mdx @@ -0,0 +1,49 @@ +--- +title: "findConfigFile" +slug: /reference/php/agents/configuration/config-loader/find-config-file +description: Static method to locate a config file without loading it. +max-toc-depth: 3 +--- + +[ref-configloader]: /docs/sdks/reference/php/agents/configuration/config-loader + +### findConfigFile (static) + +**[ConfigLoader][ref-configloader].findConfigFile**(`serviceName: null`, `additionalPaths: null`) -> `?string` + +Static method to locate a config file without loading it. + +## **Parameters** + + + Optional service name. When provided, the method also checks for + `{service_name}_config.json` and `.swml/{service_name}_config.json`. + + + + Additional file paths to check before the default search paths. + + +## **Returns** + +`?string` -- Path to the first config file found, or `null`. + +## **Example** + +```php {4,9} +findConfigFile(service_name: "mcp"); +// Checks: mcp_config.json, .swml/mcp_config.json, config.json, ... +echo "Found: {$path}"; + +// Find with extra paths +$path = $ConfigLoader->findConfigFile( + additional_paths: ["/opt/myapp/config.json"] +); +echo "Found: {$path}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get-config-file.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get-config-file.mdx new file mode 100644 index 000000000..75fc1cb56 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get-config-file.mdx @@ -0,0 +1,31 @@ +--- +title: "getConfigFile" +slug: /reference/php/agents/configuration/config-loader/get-config-file +description: Get the path of the loaded config file. +max-toc-depth: 3 +--- + +Get the path of the loaded config file. + +## **Returns** + +`?string` -- The file path, or `null` if no config was loaded. + +## **Example** + +```php {4} +get_config_file(); + +if ($path) { + echo "Loaded config from: {$path}"; +} +} else { + echo "No config file found"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get-config.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get-config.mdx new file mode 100644 index 000000000..39d3ddce0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get-config.mdx @@ -0,0 +1,27 @@ +--- +title: "getConfig" +slug: /reference/php/agents/configuration/config-loader/get-config +description: Get the raw configuration dictionary before environment variable substitution. +max-toc-depth: 3 +--- + +Get the raw configuration dictionary before environment variable substitution. + +## **Returns** + +`dict[string, mixed]` -- The raw config, or an empty dict if no config is loaded. + +## **Example** + +```php {4} +get_config(); + +echo $raw; +// ["server" => {"port": 3000], "security": ["ssl_enabled" => "${SWML_SSL_ENABLED|false]"}} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get-section.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get-section.mdx new file mode 100644 index 000000000..20cf12018 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get-section.mdx @@ -0,0 +1,34 @@ +--- +title: "getSection" +slug: /reference/php/agents/configuration/config-loader/get-section +description: Get an entire configuration section with environment variables substituted. +max-toc-depth: 3 +--- + +Get an entire configuration section with all environment variables substituted. + +## **Parameters** + + + The top-level section name (e.g., `"security"`, `"server"`, `"session"`). + + +## **Returns** + +`dict[string, mixed]` -- The section contents with all variables substituted, or an +empty dict if the section does not exist. + +## **Example** + +```php {4} +get_section("security"); + +echo $security; +// ["ssl_enabled" => True, "cors_origins": ["https://app.example.com"], ...] + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get.mdx new file mode 100644 index 000000000..25b9158b5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/get.mdx @@ -0,0 +1,42 @@ +--- +title: "get" +slug: /reference/php/agents/configuration/config-loader/get +description: Get a configuration value by dot-notation path. +max-toc-depth: 3 +--- + +Get a configuration value by dot-notation path. Environment variables are +substituted in the returned value. + +## **Parameters** + + + Dot-separated path to the config value (e.g., `"security.ssl_enabled"`, + `"server.port"`). + + + + Default value if the path is not found. + + +## **Returns** + +`mixed` -- The configuration value with environment variables substituted, or the +default if not found. + +## **Example** + +```php {5-7} +has_config()) { + echo "Loaded config from: {$loader->get_config_file()}"; +} +} else { + echo "No config file found, using defaults"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/index.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/index.mdx new file mode 100644 index 000000000..b83226bc2 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/index.mdx @@ -0,0 +1,82 @@ +--- +title: "ConfigLoader" +slug: /reference/php/agents/configuration/config-loader +description: "JSON configuration loading with environment variable substitution." +max-toc-depth: 3 +--- + +[securityconfig]: /docs/sdks/reference/php/agents/configuration/security-config +[mcp-gateway]: /docs/sdks/reference/php/agents/cli/mcp-gateway +[findconfigfile]: /docs/sdks/reference/php/agents/configuration/config-loader/find-config-file +[get]: /docs/sdks/reference/php/agents/configuration/config-loader/get +[getconfig]: /docs/sdks/reference/php/agents/configuration/config-loader/get-config +[getconfigfile]: /docs/sdks/reference/php/agents/configuration/config-loader/get-config-file +[getsection]: /docs/sdks/reference/php/agents/configuration/config-loader/get-section +[hasconfig]: /docs/sdks/reference/php/agents/configuration/config-loader/has-config +[mergewithenv]: /docs/sdks/reference/php/agents/configuration/config-loader/merge-with-env +[substitutevars]: /docs/sdks/reference/php/agents/configuration/config-loader/substitute-vars + +`ConfigLoader` loads JSON configuration files and substitutes environment +variables using `${VAR|default}` syntax. It is used internally by +[`SecurityConfig`][securityconfig] +and the [`mcp-gateway`][mcp-gateway] service, +and can be used directly for custom configuration needs. + +```php + + List of file paths checked during initialization. The first existing file is loaded. + + +## **Methods** + + + + Static method to locate a config file without loading it. + + + Get a configuration value by dot-notation path. + + + Get the raw configuration dictionary before environment variable substitution. + + + Get the path of the loaded config file. + + + Get an entire configuration section with environment variables substituted. + + + Check whether a configuration file was successfully loaded. + + + Merge configuration with environment variables matching a prefix. + + + Recursively substitute environment variables in configuration values. + + + +## **Example** + +```php {4,8} +has_config()}"; + +// Explicit config file path +$loader = $ConfigLoader(["./my-config.json", "/etc/myapp/config.json"]); +echo "Config file: {$loader->get_config_file()}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/merge-with-env.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/merge-with-env.mdx new file mode 100644 index 000000000..55358fe17 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/merge-with-env.mdx @@ -0,0 +1,36 @@ +--- +title: "mergeWithEnv" +slug: /reference/php/agents/configuration/config-loader/merge-with-env +description: Merge configuration with environment variables matching a prefix. +max-toc-depth: 3 +--- + +Merge the config file with environment variables that match a prefix. Config +file values take precedence; environment variables fill in gaps. + +## **Parameters** + + + Prefix for environment variables to consider. The prefix is stripped and the + remainder is converted to a lowercase config key (e.g., `SWML_SSL_ENABLED` + becomes `ssl_enabled`). + + +## **Returns** + +`dict[string, mixed]` -- Merged configuration dictionary. + +## **Example** + +```php {4-5} +merge_with_env(); +$merged_custom = $loader->merge_with_env(env_prefix: "MYAPP_"); + +echo $merged; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/substitute-vars.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/substitute-vars.mdx new file mode 100644 index 000000000..f167bc6f4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/config-loader/substitute-vars.mdx @@ -0,0 +1,56 @@ +--- +title: "substituteVars" +slug: /reference/php/agents/configuration/config-loader/substitute-vars +description: Recursively substitute environment variables in configuration values. +max-toc-depth: 3 +--- + +Recursively substitute environment variables in a configuration value. Supports +`${VAR}` and `${VAR|default}` syntax. + +## **Parameters** + + + The value to process. Can be a string, dict, list, or any other type. + Strings are scanned for `${VAR|default}` patterns. Dicts and lists are + processed recursively. + + + + Maximum recursion depth to prevent infinite substitution loops. + + +## **Returns** + +`mixed` -- The value with all `${VAR|default}` patterns replaced by the corresponding +environment variable values. Strings that resolve to `"true"`/`"false"` are converted +to booleans. Numeric strings are converted to `int` or `float`. + +## **Example** + +```php {8,12,20} +environ["API_KEY"] = "secret123"; +$loader = $ConfigLoader(); + +// Simple substitution +$result = $loader->substitute_vars("${API_KEY}"); +echo $result; + +// With default value +$result = $loader->substitute_vars("${MISSING_VAR|fallback}"); +echo $result; + +// Nested structure +$config = {; + "auth": ["token" => "${API_KEY]"}, + "timeout": "${TIMEOUT|30}", +} +$result = $loader->substitute_vars($config); +echo $result; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/index.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/index.mdx new file mode 100644 index 000000000..f1bca06f9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/index.mdx @@ -0,0 +1,126 @@ +--- +title: "Configuration" +slug: /reference/php/agents/configuration +description: "Environment variables, config files, and security settings." +max-toc-depth: 3 +--- + +[configloader]: /docs/sdks/reference/php/agents/configuration/config-loader +[authhandler]: /docs/sdks/reference/php/agents/configuration/auth-handler +[securityconfig]: /docs/sdks/reference/php/agents/configuration/security-config +[config-loader]: /docs/sdks/reference/php/agents/configuration/config-loader +[security-config]: /docs/sdks/reference/php/agents/configuration/security-config +[auth-handler]: /docs/sdks/reference/php/agents/configuration/auth-handler + +The SignalWire Agents SDK uses a layered configuration system. Settings can come +from constructor parameters, environment variables, JSON config files, or +sensible defaults. The layers are resolved in priority order: + +1. **Constructor parameters** -- highest priority +2. **Environment variables** -- override config file values +3. **Config file values** -- loaded from JSON +4. **Defaults** -- built-in fallback values + +```php + + + Complete reference for all environment variables used by the SDK. + + + JSON config file loading with environment variable substitution. + + + SSL, CORS, host allowlists, rate limiting, and HSTS configuration. + + + HTTP Basic Auth, Bearer tokens, and API key authentication for FastAPI and Flask. + + diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-basic-auth.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-basic-auth.mdx new file mode 100644 index 000000000..7785d5df0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-basic-auth.mdx @@ -0,0 +1,34 @@ +--- +title: "getBasicAuth" +slug: /reference/php/agents/configuration/security-config/get-basic-auth +description: Get basic authentication credentials, generating a password if not set. +max-toc-depth: 3 +--- + +Get basic authentication credentials. If no password has been configured, a +random 32-character password is generated and stored on the instance. + +## **Returns** + +`tuple[string, string]` -- A tuple of `(username, password)`. The username defaults +to `"signalwire"` if not explicitly set. + + +Auto-generated passwords change on every instantiation. In production, always set +`SWML_BASIC_AUTH_PASSWORD` explicitly so webhook credentials remain stable across +restarts. + + +## **Example** + +```php {4} +get_basic_auth(); + +echo "Auth: {$username}:{$password}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-cors-config.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-cors-config.mdx new file mode 100644 index 000000000..db91d0139 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-cors-config.mdx @@ -0,0 +1,32 @@ +--- +title: "getCorsConfig" +slug: /reference/php/agents/configuration/security-config/get-cors-config +description: Get CORS configuration suitable for FastAPI's CORSMiddleware. +max-toc-depth: 3 +--- + +Get CORS configuration suitable for FastAPI's `CORSMiddleware`. + +## **Returns** + +`dict[string, mixed]` -- Dictionary with `allow_origins`, `allow_credentials`, +`allow_methods`, and `allow_headers` keys. + +## **Example** + +```php {6} +middleware->cors $import $CORSMiddleware; +use SignalWire\Core\SecurityConfig\SecurityConfig; + +$security = $SecurityConfig(); +$cors_config = $security->get_cors_config(); + +$app = $FastAPI(); +$app->add_middleware($CORSMiddleware, **$cors_config); +echo $cors_config; +// {'allow_origins': ['*'], 'allow_credentials': True, 'allow_methods': ['*'], 'allow_headers': ['*']} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-security-headers.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-security-headers.mdx new file mode 100644 index 000000000..63a2d4306 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-security-headers.mdx @@ -0,0 +1,39 @@ +--- +title: "getSecurityHeaders" +slug: /reference/php/agents/configuration/security-config/get-security-headers +description: Get security headers to add to HTTP responses. +max-toc-depth: 3 +--- + +Get security headers to add to HTTP responses. + +## **Parameters** + + + Whether the connection is over HTTPS. When `True` and `use_hsts` is enabled, + the `Strict-Transport-Security` header is included. + + +## **Returns** + +`dict[string, string]` -- Dictionary of security headers including `X-Content-Type-Options`, +`X-Frame-Options`, `X-XSS-Protection`, `Referrer-Policy`, and optionally +`Strict-Transport-Security`. + +## **Example** + +```php {4-5} +get_security_headers(is_https: false); +$https_headers = $security->get_security_headers(is_https: true); + +echo $headers; +// {'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'DENY', ...} +echo $https_headers; +// Includes 'Strict-Transport-Security' header when HSTS is enabled + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-ssl-context-kwargs.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-ssl-context-kwargs.mdx new file mode 100644 index 000000000..e7cee89be --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-ssl-context-kwargs.mdx @@ -0,0 +1,31 @@ +--- +title: "getSslContextKwargs" +slug: /reference/php/agents/configuration/security-config/get-ssl-context-kwargs +description: Get SSL parameters suitable for passing to uvicorn. +max-toc-depth: 3 +--- + +Get SSL parameters suitable for passing to uvicorn's `ssl_certfile` and +`ssl_keyfile` arguments. + +## **Returns** + +`dict[string, mixed]` -- A dictionary with `ssl_certfile` and `ssl_keyfile` keys when +SSL is enabled and valid. Returns an empty dict when SSL is disabled. + +## **Example** + +```php {6} +get_ssl_context_kwargs(); + +$app = $FastAPI(); +$uvicorn->run($app, host: "0.0.0.0", port: 443, **$ssl_kwargs); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-url-scheme.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-url-scheme.mdx new file mode 100644 index 000000000..ebc7c36e2 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/get-url-scheme.mdx @@ -0,0 +1,26 @@ +--- +title: "getUrlScheme" +slug: /reference/php/agents/configuration/security-config/get-url-scheme +description: Get the URL scheme based on SSL configuration. +max-toc-depth: 3 +--- + +Get the URL scheme based on SSL configuration. + +## **Returns** + +`string` -- `"https"` if SSL is enabled, `"http"` otherwise. + +## **Example** + +```php {4} +get_url_scheme(); + +echo "URL scheme: {$scheme}") # "http" (default; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/security-config/index.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/index.mdx new file mode 100644 index 000000000..f93cb49e7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/index.mdx @@ -0,0 +1,141 @@ +--- +title: "SecurityConfig" +slug: /reference/php/agents/configuration/security-config +description: "Unified security configuration for SSL, CORS, host allowlists, and rate limiting." +max-toc-depth: 3 +--- + +[getbasicauth]: /docs/sdks/reference/php/agents/configuration/security-config/get-basic-auth +[getcorsconfig]: /docs/sdks/reference/php/agents/configuration/security-config/get-cors-config +[getsecurityheaders]: /docs/sdks/reference/php/agents/configuration/security-config/get-security-headers +[getsslcontextkwargs]: /docs/sdks/reference/php/agents/configuration/security-config/get-ssl-context-kwargs +[geturlscheme]: /docs/sdks/reference/php/agents/configuration/security-config/get-url-scheme +[loadfromenv]: /docs/sdks/reference/php/agents/configuration/security-config/load-from-env +[logconfig]: /docs/sdks/reference/php/agents/configuration/security-config/log-config +[shouldallowhost]: /docs/sdks/reference/php/agents/configuration/security-config/should-allow-host +[validatesslconfig]: /docs/sdks/reference/php/agents/configuration/security-config/validate-ssl-config + +`SecurityConfig` provides centralized security settings for all SignalWire +services. It loads settings from environment variables and optional config files, +handling SSL/TLS, CORS, host allowlists, rate limiting, HSTS, and basic +authentication credentials. + +```php + + Whether HTTPS is enabled. + + + + Path to the SSL certificate file. Required when `ssl_enabled` is `True`. + + + + Path to the SSL private key file. Required when `ssl_enabled` is `True`. + + + + Domain name for SSL certificates and URL generation. + + + + SSL certificate verification mode. + + + + List of allowed hostnames. `["*"]` accepts all hosts. + + + + List of allowed CORS origins. `["*"]` accepts all origins. + + + + Maximum request body size in bytes (default 10 MB). + + + + Rate limit in requests per minute. + + + + Request timeout in seconds. + + + + Enable HTTP Strict Transport Security when serving over HTTPS. + + + + HSTS `max-age` in seconds (default 1 year). + + + + Basic auth username. Defaults to `"signalwire"` when accessed via `get_basic_auth()`. + + + + Basic auth password. Auto-generated if not set when accessed via `get_basic_auth()`. + + +## **Methods** + + + + Get basic authentication credentials, generating a password if not set. + + + Get CORS configuration suitable for FastAPI's CORSMiddleware. + + + Get security headers to add to HTTP responses. + + + Get SSL parameters suitable for passing to uvicorn. + + + Get the URL scheme based on SSL configuration. + + + Reload all settings from environment variables. + + + Log the current security configuration for debugging. + + + Check if a host is in the allowed hosts list. + + + Validate that SSL configuration is complete and certificate files exist. + + + +## **Example** + +```php {4,8,11} +ssl_enabled}, HSTS: {$security->use_hsts}"; + +// Explicit config file +$security = $SecurityConfig(config_file: "/etc/myapp/config.json"); + +// Service-specific config +$security = $SecurityConfig(service_name: "mcp"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/security-config/load-from-env.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/load-from-env.mdx new file mode 100644 index 000000000..0a60bd7c4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/load-from-env.mdx @@ -0,0 +1,30 @@ +--- +title: "loadFromEnv" +slug: /reference/php/agents/configuration/security-config/load-from-env +description: Reload all settings from environment variables. +max-toc-depth: 3 +--- + +Reload all settings from environment variables. This is called automatically +during construction but can be called again to pick up runtime changes. + +## **Returns** + +`null` + +## **Example** + +```php {7} +environ["SWML_SSL_ENABLED"] = "true"; +$security->load_from_env(); + +echo "SSL enabled: {$security->ssl_enabled}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/security-config/log-config.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/log-config.mdx new file mode 100644 index 000000000..5bdea57b3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/log-config.mdx @@ -0,0 +1,31 @@ +--- +title: "logConfig" +slug: /reference/php/agents/configuration/security-config/log-config +description: Log the current security configuration for debugging. +max-toc-depth: 3 +--- + +Log the current security configuration for debugging. + +## **Parameters** + + + Service name included in the log entry for identification. + + +## **Returns** + +`null` + +## **Example** + +```php {4} +log_config("my-agent"); +// Logs: ssl_enabled, domain, allowed_hosts, cors_origins, rate_limit, etc. + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/security-config/should-allow-host.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/should-allow-host.mdx new file mode 100644 index 000000000..e8ecdc300 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/should-allow-host.mdx @@ -0,0 +1,32 @@ +--- +title: "shouldAllowHost" +slug: /reference/php/agents/configuration/security-config/should-allow-host +description: Check if a host is in the allowed hosts list. +max-toc-depth: 3 +--- + +Check if a host is in the allowed hosts list. + +## **Parameters** + + + The hostname to check. + + +## **Returns** + +`bool` -- `True` if the host is allowed (or if `allowed_hosts` contains `"*"`). + +## **Example** + +```php {5-6} +allowed_hosts = ["agent.example.com", "api.example.com"]; +echo $security->should_allow_host("agent.example.com"); +echo $security->should_allow_host("evil.example.com"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/configuration/security-config/validate-ssl-config.mdx b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/validate-ssl-config.mdx new file mode 100644 index 000000000..2c6834e8a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/configuration/security-config/validate-ssl-config.mdx @@ -0,0 +1,32 @@ +--- +title: "validateSslConfig" +slug: /reference/php/agents/configuration/security-config/validate-ssl-config +description: Validate that SSL configuration is complete and certificate files exist. +max-toc-depth: 3 +--- + +Validate that SSL configuration is complete and the certificate files exist. + +## **Returns** + +`array{bool, ?string}` -- A tuple of `(is_valid, error_message)`. +Returns `(True, null)` when SSL is disabled or when all required files exist. + +## **Example** + +```php {4} +validate_ssl_config(); + +if (!$is_valid) { + echo "SSL configuration error: {$error}"; +} +} else { + echo "SSL configuration is valid"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/add-context.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/add-context.mdx new file mode 100644 index 000000000..5bd5e4757 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/add-context.mdx @@ -0,0 +1,68 @@ +--- +title: "addContext" +slug: /reference/php/agents/context-builder/add-context +description: Create a new named context and add it to the builder. +max-toc-depth: 3 +--- + +[context]: /docs/sdks/reference/php/agents/context-builder/context + +Create a new context and add it to the builder. Returns the Context object for +method chaining. + + +A single-context agent must name its context `"default"` or validation will fail. +Multi-context agents can use any names. + + +## **Parameters** + + + Unique context name. When using a single context, it **must** be named `"default"`. + + +## **Returns** + +[`Context`][context] -- The newly +created context, ready for adding steps. + +## **Examples** + +### Single context + +```php {6} +defineContexts(); +$default = $contexts->addContext("default"); +default->addStep("greet")->setText("Greet the caller and ask how you can help."); + +$agent->serve(); + + +``` + +### Multiple contexts + +```php {6-8} +defineContexts(); +$main = $contexts->addContext("default"); +$sales = $contexts->addContext("sales"); +$support = $contexts->addContext("support"); + +$main->addStep("menu")->setText("Ask whether the caller needs sales or support."); +$sales->addStep("qualify")->setText("Understand what product the caller wants."); +$support->addStep("diagnose")->setText("Understand the customer's issue."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-bullets.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-bullets.mdx new file mode 100644 index 000000000..6986a8a0e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-bullets.mdx @@ -0,0 +1,47 @@ +--- +title: "addBullets" +slug: /reference/php/agents/context-builder/context/add-bullets +description: Add a POM section with bullet points to the context prompt. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Add a POM section with bullet points to the context prompt. Cannot be used +together with `setPrompt()`. + +## **Parameters** + + + Section heading. + + + + List of bullet point strings. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {7} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->addBullets("Rules", [; + "Never share account numbers with the caller", + "Always confirm changes before applying", + "Escalate fraud concerns immediately" +]); +$ctx->addStep("greet")->setText("Greet the caller and ask how you can help."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-enter-filler.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-enter-filler.mdx new file mode 100644 index 000000000..94a24ab59 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-enter-filler.mdx @@ -0,0 +1,47 @@ +--- +title: "addEnterFiller" +slug: /reference/php/agents/context-builder/context/add-enter-filler +description: Add enter fillers for a specific language. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Add enter fillers for a specific language. + +## **Parameters** + + + Language code (e.g., `"en-US"`, `"es"`) or `"default"` for a catch-all. + + + + List of filler phrases. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$contexts->addContext("default")->addStep("menu")->setText("Ask what the caller needs."); + +$support = $contexts->addContext("support"); +$support->add_enter_filler("en-US", [; + "Let me connect you with support...", + "Transferring you now..." +]); +$support->addStep("diagnose")->setText("Understand the customer's issue."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-exit-filler.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-exit-filler.mdx new file mode 100644 index 000000000..38f0a8527 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-exit-filler.mdx @@ -0,0 +1,47 @@ +--- +title: "addExitFiller" +slug: /reference/php/agents/context-builder/context/add-exit-filler +description: Add exit fillers for a specific language. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Add exit fillers for a specific language. + +## **Parameters** + + + Language code (e.g., `"en-US"`, `"es"`) or `"default"` for a catch-all. + + + + List of filler phrases. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$contexts->addContext("default")->addStep("menu")->setText("Ask what the caller needs."); + +$support = $contexts->addContext("support"); +$support->add_exit_filler("en-US", [; + "Thank you for contacting support.", + "Glad I could help." +]); +$support->addStep("diagnose")->setText("Understand the customer's issue."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-section.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-section.mdx new file mode 100644 index 000000000..edeeb086e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-section.mdx @@ -0,0 +1,43 @@ +--- +title: "addSection" +slug: /reference/php/agents/context-builder/context/add-section +description: Add a POM section to the context prompt. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Add a POM section to the context prompt. Cannot be used together with `setPrompt()`. + +## **Parameters** + + + Section heading. + + + + Section body text. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {7-8} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->addSection("Role", "You are a billing specialist."); +$ctx->addSection("Guidelines", "Always verify account ownership first."); +$ctx->addStep("greet")->setText("Greet the caller and ask how you can help."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-step.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-step.mdx new file mode 100644 index 000000000..c8b5eb464 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-step.mdx @@ -0,0 +1,93 @@ +--- +title: "addStep" +slug: /reference/php/agents/context-builder/context/add-step +description: Add a new step to this context. +max-toc-depth: 3 +--- + +[step]: /docs/sdks/reference/php/agents/context-builder/step + +Add a new step to this context. When called with only `name`, the returned Step +can be configured via method chaining. When keyword arguments are provided, the +step is fully configured in one call. + +## **Parameters** + + + Step name. Must be unique within this context. + + + + Text for a "Task" POM section. Equivalent to calling `step.addSection("Task", task)`. + + + + List of bullet strings for a "Process" POM section. Equivalent to calling + `step.addBullets("Process", bullets)`. Requires `task` to also be set. + + + + Step-completion criteria. Equivalent to calling `step.setStepCriteria(criteria)`. + + + + Tool names the step may call, or `"none"` to disable all tools. + Equivalent to calling `step.setFunctions(functions)`. + + + + Names of steps the agent may transition to. Equivalent to calling + `step.setValidSteps(valid_steps)`. + + +## **Returns** + +[`Step`][step] -- The new step +for optional further chaining. + +## **Examples** + +### Compact syntax + +```php {8,13} +defineContexts(); +$ctx = $contexts->addContext("default"); + +$ctx->addStep("getName", + task: "Ask for the customer's full name.", + criteria: "Customer has provided their full name", + valid_steps: ["get_email"] +); +$ctx->addStep("get_email")->setText("Ask for the customer's email address."); + +$agent->serve(); + + +``` + +### Method chaining + +```php {8,12} +defineContexts(); +$ctx = $contexts->addContext("default"); + +$ctx->addStep("getName") \; + .addSection("Task", "Ask for the customer's full name.") \; + .setStepCriteria("Customer has provided their full name") \; + .setValidSteps(["get_email"]); +$ctx->addStep("get_email")->setText("Ask for the customer's email address."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-system-bullets.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-system-bullets.mdx new file mode 100644 index 000000000..888f7101c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-system-bullets.mdx @@ -0,0 +1,48 @@ +--- +title: "addSystemBullets" +slug: /reference/php/agents/context-builder/context/add-system-bullets +description: Add a POM section with bullets to the system prompt. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Add a POM section with bullets to the system prompt. Cannot be combined with +`setSystemPrompt()`. + +## **Parameters** + + + Section heading. + + + + List of bullet point strings. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$contexts->addContext("default")->addStep("menu")->setText("Ask what the caller needs."); + +$support = $contexts->addContext("support"); +$support->addSystemBullets("Guidelines", [; + "Verify identity before making changes", + "Offer to escalate if issue is unresolved after 5 minutes" +]); +$support->addStep("diagnose")->setText("Understand the customer's issue."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-system-section.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-system-section.mdx new file mode 100644 index 000000000..5270f304f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/add-system-section.mdx @@ -0,0 +1,45 @@ +--- +title: "addSystemSection" +slug: /reference/php/agents/context-builder/context/add-system-section +description: Add a POM section to the system prompt. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Add a POM section to the system prompt. Cannot be combined with `setSystemPrompt()`. + +## **Parameters** + + + Section heading. + + + + Section body text. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {9-10} +defineContexts(); +$contexts->addContext("default")->addStep("menu")->setText("Ask what the caller needs."); + +$billing = $contexts->addContext("billing"); +$billing->addSystemSection("Role", "You are a billing specialist."); +$billing->addSystemSection("Tone", "Be professional and empathetic."); +$billing->addStep("review")->setText("Review the caller's account and recent charges."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/get-step.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/get-step.mdx new file mode 100644 index 000000000..9a09fcf6b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/get-step.mdx @@ -0,0 +1,43 @@ +--- +title: "getStep" +slug: /reference/php/agents/context-builder/context/get-step +description: Get an existing step by name. +max-toc-depth: 3 +--- + +[step]: /docs/sdks/reference/php/agents/context-builder/step + +Get an existing step by name for inspection or modification. + +## **Parameters** + + + Step name to look up. + + +## **Returns** + +[`Step`][step] if found, `null` +otherwise. + +## **Example** + +```php {9} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->addStep("collect_info")->setText("Collect the caller's account information."); + +$step = $ctx->getStep("collect_info"); +if ($step $is !null) { + $step->setFunctions(["verify_identity"]); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/index.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/index.mdx new file mode 100644 index 000000000..cb00b1be5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/index.mdx @@ -0,0 +1,167 @@ +--- +title: "Context" +slug: /reference/php/agents/context-builder/context +description: "A named conversation workflow containing steps, prompts, and navigation rules." +max-toc-depth: 3 +--- + +[contextbuilder]: /docs/sdks/reference/php/agents/context-builder +[step]: /docs/sdks/reference/php/agents/context-builder/step +[addbullets]: /docs/sdks/reference/php/agents/context-builder/context/add-bullets +[addenterfiller]: /docs/sdks/reference/php/agents/context-builder/context/add-enter-filler +[addexitfiller]: /docs/sdks/reference/php/agents/context-builder/context/add-exit-filler +[addsection]: /docs/sdks/reference/php/agents/context-builder/context/add-section +[addstep]: /docs/sdks/reference/php/agents/context-builder/context/add-step +[addsystembullets]: /docs/sdks/reference/php/agents/context-builder/context/add-system-bullets +[addsystemsection]: /docs/sdks/reference/php/agents/context-builder/context/add-system-section +[getstep]: /docs/sdks/reference/php/agents/context-builder/context/get-step +[movestep]: /docs/sdks/reference/php/agents/context-builder/context/move-step +[removestep]: /docs/sdks/reference/php/agents/context-builder/context/remove-step +[setconsolidate]: /docs/sdks/reference/php/agents/context-builder/context/set-consolidate +[setenterfillers]: /docs/sdks/reference/php/agents/context-builder/context/set-enter-fillers +[setexitfillers]: /docs/sdks/reference/php/agents/context-builder/context/set-exit-fillers +[setfullreset]: /docs/sdks/reference/php/agents/context-builder/context/set-full-reset +[setisolated]: /docs/sdks/reference/php/agents/context-builder/context/set-isolated +[setpostprompt]: /docs/sdks/reference/php/agents/context-builder/context/set-post-prompt +[setprompt]: /docs/sdks/reference/php/agents/context-builder/context/set-prompt +[setsystemprompt]: /docs/sdks/reference/php/agents/context-builder/context/set-system-prompt +[setuserprompt]: /docs/sdks/reference/php/agents/context-builder/context/set-user-prompt +[setvalidcontexts]: /docs/sdks/reference/php/agents/context-builder/context/set-valid-contexts +[setvalidsteps]: /docs/sdks/reference/php/agents/context-builder/context/set-valid-steps + +A Context represents a distinct conversation mode -- like "sales", "support", or +"billing" -- within a [`ContextBuilder`][contextbuilder]. +Each context holds an ordered sequence of +[`Step`][step] objects and +configures its own prompt, system prompt, fillers, and navigation rules. + +You obtain a Context by calling `addContext()` on a ContextBuilder or by calling +`getContext()` to retrieve one that already exists. + +## **Properties** + + + Unique context name. When using a single context inside a ContextBuilder, this + must be `"default"`. + + +## **Methods** + + + + Add a POM section with bullet points to the context prompt. + + + Add enter fillers for a specific language. + + + Add exit fillers for a specific language. + + + Add a POM section to the context prompt. + + + Add a new step to this context. + + + Add a POM section with bullets to the system prompt. + + + Add a POM section to the system prompt. + + + Get an existing step by name. + + + Move an existing step to a specific position in the step order. + + + Remove a step from this context. + + + Set whether to consolidate conversation history when entering this context. + + + Set all enter fillers at once. + + + Set all exit fillers at once. + + + Set whether to completely replace the system prompt when entering this context. + + + Set whether to truncate conversation history when entering this context. + + + Override the post-prompt text while this context is active. + + + Set the context's prompt text directly. + + + Set a new system prompt that takes effect when this context is entered. + + + Inject a user message when entering this context. + + + Set which contexts the agent can navigate to from this context. + + + Set which steps can be navigated to from any step in this context. + + + +## **Example** + +```php +defineContexts(); +$main = $contexts->addContext("default"); +$main->addStep("menu")->setText("Ask whether the caller needs sales or support."); + +$support = $contexts->addContext("support"); + +// System prompt for this context +$support->setSystemPrompt("You are a patient technical support engineer."); +$support->setConsolidate(true); + +// Fillers for smooth transitions +$support->add_enter_filler("en-US", [; + "Let me connect you with support...", + "Transferring you now..." +]); +$support->add_exit_filler("en-US", [; + "Thank you for contacting support.", + "Glad I could help." +]); + +// Navigation +$support->setValidContexts(["default"]); + +// Steps +$support->addStep("diagnose", + task: "Understand the customer's issue and gather relevant details.", + criteria: "Issue is clearly identified", + functions: ["lookup_account", "check_status"], + valid_steps: ["resolve"] +); +$support->addStep("resolve", + task: "Resolve the issue or escalate to a specialist.", + functions: ["create_ticket", "transfer_call"], + valid_steps: ["farewell"] +); +$support->addStep("farewell") \; + .setText("Thank the caller and end the conversation.") \; + .setFunctions("none") \; + .setEnd(true); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/move-step.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/move-step.mdx new file mode 100644 index 000000000..7a033fedd --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/move-step.mdx @@ -0,0 +1,44 @@ +--- +title: "moveStep" +slug: /reference/php/agents/context-builder/context/move-step +description: Move an existing step to a specific position in the step order. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Move an existing step to a specific position in the step order. + +## **Parameters** + + + Name of the step to move. + + + + Target index in the step order. `0` places the step first. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. Raises `ValueError` if the step is not found. + +## **Example** + +```php {10} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->addStep("collect_info")->setText("Collect the caller's information."); +$ctx->addStep("confirm")->setText("Confirm the details with the caller."); + +$ctx->moveStep("confirm", 0); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/remove-step.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/remove-step.mdx new file mode 100644 index 000000000..57777eb9f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/remove-step.mdx @@ -0,0 +1,41 @@ +--- +title: "removeStep" +slug: /reference/php/agents/context-builder/context/remove-step +description: Remove a step from this context. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Remove a step from this context entirely. + +## **Parameters** + + + Name of the step to remove. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {11} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->addStep("greet")->setText("Greet the caller."); +$ctx->addStep("obsolete_step")->setText("This step is no longer needed."); +$ctx->addStep("farewell")->setText("Thank the caller and say goodbye."); + +$ctx->removeStep("obsolete_step"); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-consolidate.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-consolidate.mdx new file mode 100644 index 000000000..5fc453e03 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-consolidate.mdx @@ -0,0 +1,42 @@ +--- +title: "setConsolidate" +slug: /reference/php/agents/context-builder/context/set-consolidate +description: Set whether to consolidate conversation history when entering this context. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Set whether to consolidate (summarize) conversation history when entering this +context. Reduces token usage while preserving key information. + +## **Parameters** + + + Whether to consolidate previous conversation on entry. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$contexts->addContext("default")->addStep("menu")->setText("Ask what the caller needs."); + +$support = $contexts->addContext("support"); +$support->setConsolidate(true); +$support->setSystemPrompt("You are a patient technical support engineer."); +$support->addStep("diagnose")->setText("Understand the customer's issue."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-enter-fillers.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-enter-fillers.mdx new file mode 100644 index 000000000..8b320c317 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-enter-fillers.mdx @@ -0,0 +1,44 @@ +--- +title: "setEnterFillers" +slug: /reference/php/agents/context-builder/context/set-enter-fillers +description: Set all enter fillers at once. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Set all enter fillers at once. Fillers are short phrases the AI speaks when +entering a context, providing a natural transition for the caller. + +## **Parameters** + + + Dictionary mapping language codes (or `"default"`) to lists of filler phrases. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$contexts->addContext("default")->addStep("menu")->setText("Ask what the caller needs."); + +$support = $contexts->addContext("support"); +$support->setEnterFillers({ + "en-US": ["Let me transfer you...", "One moment please..."], + "es": ["Un momento por favor..."] +}); +$support->addStep("diagnose")->setText("Understand the customer's issue."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-exit-fillers.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-exit-fillers.mdx new file mode 100644 index 000000000..cf687e3f3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-exit-fillers.mdx @@ -0,0 +1,44 @@ +--- +title: "setExitFillers" +slug: /reference/php/agents/context-builder/context/set-exit-fillers +description: Set all exit fillers at once. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Set all exit fillers at once. Exit fillers are spoken when the AI navigates away +from this context. + +## **Parameters** + + + Dictionary mapping language codes (or `"default"`) to lists of filler phrases. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$contexts->addContext("default")->addStep("menu")->setText("Ask what the caller needs."); + +$support = $contexts->addContext("support"); +$support->setExitFillers({ + "en-US": ["Thank you for contacting support.", "Glad I could help."], + "default": ["Thank you."] +}); +$support->addStep("diagnose")->setText("Understand the customer's issue."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-full-reset.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-full-reset.mdx new file mode 100644 index 000000000..15bf33dd3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-full-reset.mdx @@ -0,0 +1,42 @@ +--- +title: "setFullReset" +slug: /reference/php/agents/context-builder/context/set-full-reset +description: Set whether to completely replace the system prompt when entering this context. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Set whether to completely replace the system prompt when entering this context +(rather than injecting additional instructions). + +## **Parameters** + + + Whether to fully rewrite the system prompt on entry. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$contexts->addContext("default")->addStep("menu")->setText("Ask what the caller needs."); + +$escalation = $contexts->addContext("escalation"); +$escalation->setFullReset(true); +$escalation->setSystemPrompt("You are a senior escalation specialist."); +$escalation->addStep("investigate")->setText("Investigate the escalated issue in detail."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-isolated.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-isolated.mdx new file mode 100644 index 000000000..308aaae0a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-isolated.mdx @@ -0,0 +1,42 @@ +--- +title: "setIsolated" +slug: /reference/php/agents/context-builder/context/set-isolated +description: Set whether to truncate conversation history when entering this context. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Set whether to truncate conversation history when entering this context. Creates +a clean slate for the new context. + +## **Parameters** + + + Whether to truncate conversation history on entry. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$contexts->addContext("default")->addStep("menu")->setText("Ask what the caller needs."); + +$secure = $contexts->addContext("secure"); +$secure->setIsolated(true); +$secure->setSystemPrompt("You are verifying the caller's identity."); +$secure->addStep("verify")->setText("Ask for the caller's account PIN."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-post-prompt.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-post-prompt.mdx new file mode 100644 index 000000000..d41a8a4aa --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-post-prompt.mdx @@ -0,0 +1,40 @@ +--- +title: "setPostPrompt" +slug: /reference/php/agents/context-builder/context/set-post-prompt +description: Override the post-prompt text while this context is active. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Override the post-prompt text while this context is active. + +## **Parameters** + + + Post-prompt text for this context. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$contexts->addContext("default")->addStep("menu")->setText("Ask what the caller needs."); + +$billing = $contexts->addContext("billing"); +$billing->setPostPrompt("Summarize the billing issue and resolution."); +$billing->addStep("review")->setText("Review the caller's account and recent charges."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-prompt.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-prompt.mdx new file mode 100644 index 000000000..5bf99b0a5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-prompt.mdx @@ -0,0 +1,39 @@ +--- +title: "setPrompt" +slug: /reference/php/agents/context-builder/context/set-prompt +description: Set the context's prompt text directly. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Set the context's prompt text directly. Cannot be used together with `addSection()` +or `addBullets()`. + +## **Parameters** + + + Plain-text prompt for this context. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {7} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->setPrompt("You are handling billing inquiries. Be concise and accurate."); +$ctx->addStep("greet")->setText("Greet the caller and ask how you can help."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-system-prompt.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-system-prompt.mdx new file mode 100644 index 000000000..e9ff16218 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-system-prompt.mdx @@ -0,0 +1,39 @@ +--- +title: "setSystemPrompt" +slug: /reference/php/agents/context-builder/context/set-system-prompt +description: Set a new system prompt that takes effect when this context is entered. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Set a new system prompt that takes effect when this context is entered. Triggers +a context reset. Cannot be combined with `addSystemSection()` / `addSystemBullets()`. + +## **Parameters** + + + New system prompt for this context. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {7} +defineContexts(); +$support = $contexts->addContext("default"); +$support->setSystemPrompt("You are a patient technical support engineer."); +$support->addStep("greet")->setText("Greet the caller and ask about their issue."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-user-prompt.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-user-prompt.mdx new file mode 100644 index 000000000..407dc0477 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-user-prompt.mdx @@ -0,0 +1,39 @@ +--- +title: "setUserPrompt" +slug: /reference/php/agents/context-builder/context/set-user-prompt +description: Inject a user message when entering this context. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Inject a user message when entering this context. Useful for triggering the AI to +speak first after a context switch. + +## **Parameters** + + + User message to inject. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {7} +defineContexts(); +$sales = $contexts->addContext("default"); +$sales->setUserPrompt("I'd like to learn about your products."); +$sales->addStep("pitch")->setText("Present our product lineup to the caller."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-valid-contexts.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-valid-contexts.mdx new file mode 100644 index 000000000..ac2146c8a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-valid-contexts.mdx @@ -0,0 +1,44 @@ +--- +title: "setValidContexts" +slug: /reference/php/agents/context-builder/context/set-valid-contexts +description: Set which contexts the agent can navigate to from this context. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Set which contexts the agent can navigate to from this context. Acts as a +context-level default; step-level `setValidContexts()` can further restrict or +expand navigation for individual steps. + +## **Parameters** + + + List of context names that are reachable from this context. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$default = $contexts->addContext("default"); +default->addStep("greet")->setText("Welcome the caller."); +$support = $contexts->addContext("support"); +$support->setValidContexts(["default", "billing"]); +$support->addStep("help")->setText("Help the caller with their issue."); +$billing = $contexts->addContext("billing"); +$billing->addStep("invoice")->setText("Help with billing inquiries."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-valid-steps.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-valid-steps.mdx new file mode 100644 index 000000000..45482fedd --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/context/set-valid-steps.mdx @@ -0,0 +1,41 @@ +--- +title: "setValidSteps" +slug: /reference/php/agents/context-builder/context/set-valid-steps +description: Set which steps can be navigated to from any step in this context. +max-toc-depth: 3 +--- + +[ref-context]: /docs/sdks/reference/php/agents/context-builder/context + +Set which steps can be navigated to from **any** step in this context. Acts as a +context-level default; step-level `setValidSteps()` takes precedence when set. + +## **Parameters** + + + List of step names. Include `"next"` to allow sequential advancement. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. + +## **Example** + +```php {7} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->setValidSteps(["next", "cancel"]); +$ctx->addStep("greet")->setText("Welcome the caller."); +$ctx->addStep("collect")->setText("Collect information."); +$ctx->addStep("cancel")->setText("Cancel the process and say goodbye."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/get-context.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/get-context.mdx new file mode 100644 index 000000000..781fec7b9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/get-context.mdx @@ -0,0 +1,43 @@ +--- +title: "getContext" +slug: /reference/php/agents/context-builder/get-context +description: Retrieve an existing context by name. +max-toc-depth: 3 +--- + +[context]: /docs/sdks/reference/php/agents/context-builder/context + +Retrieve an existing context by name for inspection or modification. + +## **Parameters** + + + Name of the context to retrieve. + + +## **Returns** + +[`Context`][context] if found, +`null` otherwise. + +## **Example** + +```php {9} +defineContexts(); +$default = $contexts->addContext("default"); +default->addStep("greet")->setText("Greet the caller."); + +$ctx = $contexts->getContext("default"); +if ($ctx $is !null) { + $ctx->addStep("followup")->setText("Ask if there is anything else."); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/index.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/index.mdx new file mode 100644 index 000000000..4d214a3df --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/index.mdx @@ -0,0 +1,151 @@ +--- +title: "ContextBuilder" +slug: /reference/php/agents/context-builder +description: "Build multi-step conversation workflows with structured contexts and steps." +max-toc-depth: 3 +--- + +[context]: /docs/sdks/reference/php/agents/context-builder/context +[step]: /docs/sdks/reference/php/agents/context-builder/step +[agentbase]: /docs/sdks/reference/php/agents/agent-base +[addcontext]: /docs/sdks/reference/php/agents/context-builder/add-context +[getcontext]: /docs/sdks/reference/php/agents/context-builder/get-context +[validate]: /docs/sdks/reference/php/agents/context-builder/validate + +ContextBuilder is the top-level container for defining structured conversation +workflows. It holds one or more [`Context`][context] +objects, each containing a sequence of [`Step`][step] +objects. Use it when your agent needs guided, multi-step conversations instead of +free-form prompting. + +Access the builder by calling `defineContexts()` on an +[`AgentBase`][agentbase] instance. The builder +validates the entire context tree when the SWML document is rendered. + +## **Properties** + + + The parent agent that owns these contexts. Typically called internally by + `AgentBase.defineContexts()` rather than instantiated directly. + + + +You rarely create a ContextBuilder directly. Call `self.defineContexts()` inside +your agent class, which creates the builder and wires it into SWML generation +automatically. + + +## **Methods** + + + + Create a new named context and add it to the builder. + + + Retrieve an existing context by name. + + + Validate the entire context configuration tree. + + + +--- + +## **Limits** + +| Limit | Value | +|-------|-------| +| Maximum contexts per builder | 50 | +| Maximum steps per context | 100 | + +--- + +## **Examples** + +### Single context with sequential steps + +```php +addLanguage("English", "en-US", "rime.spore"); + self->promptAddSection("Role", "You help customers place orders."); + } + + $contexts = self->defineContexts(); + + $order = $contexts->addContext("default"); + + $order->addStep("get_item") \; + .setText("Ask what item they want to order.") \; + .setStepCriteria("Customer has specified an item") \; + .setValidSteps(["get_quantity"]); + + $order->addStep("get_quantity") \; + .setText("Ask how many they want.") \; + .setStepCriteria("Customer has specified a quantity") \; + .setValidSteps(["confirm"]); + + $order->addStep("confirm") \; + .setText("Confirm the order details and thank them.") \; + .setStepCriteria("Order has been confirmed") \; + .setEnd(true); + + $agent = $OrderAgent(); + $agent->run(); + +``` + +### Multiple contexts + +```php +addLanguage("English", "en-US", "rime.spore"); + self->promptAddSection("Role", "You are a customer support assistant."); + } + + $contexts = self->defineContexts(); + + // Main menu + $main = $contexts->addContext("default"); + $main->addStep("menu") \; + .setText("Ask whether they need sales, support, or billing help.") \; + .setFunctions("none") \; + .setValidContexts(["sales", "support", "billing"]); + + // Sales context + $sales = $contexts->addContext("sales"); + $sales->setSystemPrompt("You are a friendly sales representative."); + $sales->addStep("qualify") \; + .setText("Understand what product the caller is interested in.") \; + .setFunctions(["check_inventory", "get_pricing"]) \; + .setValidSteps(["close"]); + $sales->addStep("close") \; + .setText("Close the sale or schedule a follow-up.") \; + .setValidContexts(["default"]); + + // Support context + $support = $contexts->addContext("support"); + $support->setSystemPrompt("You are a patient support engineer."); + $support->addStep("diagnose") \; + .setText("Understand the customer's issue.") \; + .setFunctions(["lookup_account", "check_status"]) \; + .setValidSteps(["resolve"]); + $support->addStep("resolve") \; + .setText("Resolve the issue or escalate.") \; + .setFunctions(["create_ticket", "transfer_call"]) \; + .setValidContexts(["default"]); + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/add-bullets.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/add-bullets.mdx new file mode 100644 index 000000000..5fce78d48 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/add-bullets.mdx @@ -0,0 +1,47 @@ +--- +title: "addBullets" +slug: /reference/php/agents/context-builder/step/add-bullets +description: Add a POM section with bullet points to the step. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Add a POM section with bullet points to the step. Cannot be used with `setText()`. + +## **Parameters** + + + Section heading. + + + + List of bullet point strings. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$ctx = $contexts->addContext("default"); +$step = $ctx->addStep("collect_info"); +$step->addSection("Task", "Collect the caller's account information."); +$step->addBullets("Required Information", [; + "Full legal name", + "Account number (10 digits)", + "Reason for calling" +]); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/add-gather-question.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/add-gather-question.mdx new file mode 100644 index 000000000..96d9f5968 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/add-gather-question.mdx @@ -0,0 +1,90 @@ +--- +title: "addGatherQuestion" +slug: /reference/php/agents/context-builder/step/add-gather-question +description: Add a question to this step's gather_info configuration. +max-toc-depth: 3 +--- + +[set-gather-info]: /docs/sdks/reference/php/agents/context-builder/step/set-gather-info +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Add a question to this step's gather_info configuration. +[`setGatherInfo()`][set-gather-info] +must be called before this method. + +## **Parameters** + + + Key name for storing the answer in `global_data`. Must be unique within + this step's gather questions. + + + + The question text to present to the caller. + + + + JSON schema type for the answer parameter. + + - `"string"` -- text value + - `"integer"` -- whole number value + - `"number"` -- numeric value including decimals + - `"boolean"` -- true or false value + + + + When `True`, the AI must confirm the answer with the caller before accepting it. + + + + Extra instruction text appended for this specific question. + + + + Additional function names to make visible while asking this question. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. Raises `ValueError` if `setGatherInfo()` +has not been called first. + +## **Example** + +```php {14,19,25} +defineContexts(); +$ctx = $contexts->addContext("default"); +$intake = $ctx->addStep("intake"); +$intake->setText("Collect patient information."); +$intake->setGatherInfo( + output_key: "patient_info", + completion_action: "next_step", + prompt: "Be friendly and professional when collecting information." +); +$intake->addGatherQuestion( + key: "full_name", + question: "What is your full name?", + confirm: true +); +$intake->addGatherQuestion( + key: "date_of_birth", + question: "What is your date of birth?", + type: "string", + prompt: "Spell it back to confirm." +); +$intake->addGatherQuestion( + key: "insurance_id", + question: "What is your insurance ID number?", + functions: ["verify_insurance"] +); +$ctx->addStep("review")->setText("Review the collected information with the patient."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/add-section.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/add-section.mdx new file mode 100644 index 000000000..ce462be47 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/add-section.mdx @@ -0,0 +1,43 @@ +--- +title: "addSection" +slug: /reference/php/agents/context-builder/step/add-section +description: Add a POM section to the step. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Add a POM section to the step. Cannot be used with `setText()`. + +## **Parameters** + + + Section heading (rendered as a Markdown `##` heading). + + + + Section body text. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {8-9} +defineContexts(); +$ctx = $contexts->addContext("default"); +$step = $ctx->addStep("collect_info"); +$step->addSection("Task", "Collect the caller's account information."); +$step->addSection("Guidelines", "Be polite and patient. Confirm each piece of information."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/clear-sections.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/clear-sections.mdx new file mode 100644 index 000000000..4bd121c22 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/clear-sections.mdx @@ -0,0 +1,35 @@ +--- +title: "clearSections" +slug: /reference/php/agents/context-builder/step/clear-sections +description: Remove all POM sections and direct text from this step. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Remove all POM sections and direct text from this step, allowing it to be +repopulated with new content. + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$ctx = $contexts->addContext("default"); +$step = $ctx->addStep("collect_info"); +$step->addSection("Task", "Original instructions."); +$step->clearSections(); +$step->addSection("Task", "Updated instructions for this step."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/index.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/index.mdx new file mode 100644 index 000000000..9b9f08727 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/index.mdx @@ -0,0 +1,133 @@ +--- +title: "Step" +slug: /reference/php/agents/context-builder/step +description: "An individual step in a conversation context with prompt, criteria, and navigation." +max-toc-depth: 3 +--- + +[context]: /docs/sdks/reference/php/agents/context-builder/context +[addbullets]: /docs/sdks/reference/php/agents/context-builder/step/add-bullets +[addgatherquestion]: /docs/sdks/reference/php/agents/context-builder/step/add-gather-question +[addsection]: /docs/sdks/reference/php/agents/context-builder/step/add-section +[clearsections]: /docs/sdks/reference/php/agents/context-builder/step/clear-sections +[setend]: /docs/sdks/reference/php/agents/context-builder/step/set-end +[setfunctions]: /docs/sdks/reference/php/agents/context-builder/step/set-functions +[setgatherinfo]: /docs/sdks/reference/php/agents/context-builder/step/set-gather-info +[setresetconsolidate]: /docs/sdks/reference/php/agents/context-builder/step/set-reset-consolidate +[setresetfullreset]: /docs/sdks/reference/php/agents/context-builder/step/set-reset-full-reset +[setresetsystemprompt]: /docs/sdks/reference/php/agents/context-builder/step/set-reset-system-prompt +[setresetuserprompt]: /docs/sdks/reference/php/agents/context-builder/step/set-reset-user-prompt +[setskiptonextstep]: /docs/sdks/reference/php/agents/context-builder/step/set-skip-to-next-step +[setskipuserturn]: /docs/sdks/reference/php/agents/context-builder/step/set-skip-user-turn +[setstepcriteria]: /docs/sdks/reference/php/agents/context-builder/step/set-step-criteria +[settext]: /docs/sdks/reference/php/agents/context-builder/step/set-text +[setvalidcontexts]: /docs/sdks/reference/php/agents/context-builder/step/set-valid-contexts +[setvalidsteps]: /docs/sdks/reference/php/agents/context-builder/step/set-valid-steps + +A Step represents a single phase within a +[`Context`][context]. Each step +has its own prompt text, completion criteria, available functions, and navigation +rules. The AI advances through steps automatically when criteria are met. + +You create steps by calling `addStep()` on a Context object. All setter methods +return `self` for fluent method chaining. + +## **Properties** + + + Step name. Must be unique within the parent context. + + +## **Methods** + + + + Add a POM section with bullet points to the step. + + + Add a question to this step's gather_info configuration. + + + Add a POM section to the step. + + + Remove all POM sections and direct text from this step. + + + Set whether the conversation should end after this step completes. + + + Set which SWAIG functions are available during this step. + + + Enable structured info gathering for this step. + + + Set whether to consolidate conversation history on context switch. + + + Set whether to completely replace the system prompt on context switch. + + + Set a new system prompt for context switching from this step. + + + Set a user message to inject when this step triggers a context switch. + + + Automatically advance to the next step without evaluating criteria. + + + Skip waiting for user input after this step completes. + + + Define when this step is considered complete. + + + Set the step's prompt text directly. + + + Set which contexts the agent can navigate to from this step. + + + Set which steps the agent can navigate to from this step. + + + +## **Example** + +```php +defineContexts(); +$ctx = $contexts->addContext("default"); + +$step = $ctx->addStep("collect_info"); + +// Structured prompt with POM sections +$step->addSection("Task", "Collect the caller's account information."); +$step->addBullets("Required Information", [; + "Full legal name", + "Account number (10 digits)", + "Reason for calling" +]); + +// Completion criteria +$step->setStepCriteria( + "Complete when all three pieces of information have been collected " . + "and confirmed with the caller." . +); + +// Only allow relevant functions +$step->setFunctions(["lookup_account", "verify_identity"]); + +// Navigation +$step->setValidSteps(["process_request", "escalate"]); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-end.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-end.mdx new file mode 100644 index 000000000..d9aed2460 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-end.mdx @@ -0,0 +1,40 @@ +--- +title: "setEnd" +slug: /reference/php/agents/context-builder/step/set-end +description: Set whether the conversation should end after this step completes. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Set whether the conversation should end after this step completes. + +## **Parameters** + + + Whether to end the conversation after this step. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {10} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->addStep("greet")->setText("Welcome the caller."); +$farewell = $ctx->addStep("farewell"); +$farewell->setText("Thank you for calling. Goodbye!"); +$farewell->setEnd(true); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-functions.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-functions.mdx new file mode 100644 index 000000000..d80c6aa5f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-functions.mdx @@ -0,0 +1,43 @@ +--- +title: "setFunctions" +slug: /reference/php/agents/context-builder/step/set-functions +description: Set which SWAIG functions are available during this step. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Set which SWAIG functions are available during this step. Restricting functions +per step prevents the AI from calling irrelevant tools. + +## **Parameters** + + + Either `"none"` to disable all functions, or a list of function names to allow. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {9,12} +defineContexts(); +$ctx = $contexts->addContext("default"); +$greet = $ctx->addStep("greet"); +$greet->setText("Welcome the caller."); +$greet->setFunctions("none"); +$verify = $ctx->addStep("verify"); +$verify->setText("Verify the caller's identity."); +$verify->setFunctions(["lookup_account", "verify_identity"]); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-gather-info.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-gather-info.mdx new file mode 100644 index 000000000..2022df195 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-gather-info.mdx @@ -0,0 +1,71 @@ +--- +title: "setGatherInfo" +slug: /reference/php/agents/context-builder/step/set-gather-info +description: Enable structured info gathering for this step. +max-toc-depth: 3 +--- + +[add-gather-question]: /docs/sdks/reference/php/agents/context-builder/step/add-gather-question +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Enable info gathering for this step. Call +[`addGatherQuestion()`][add-gather-question] +after this method to define the questions. + +The gather_info system collects structured information from the caller by +presenting questions one at a time. It uses dynamic step instruction re-injection +rather than tool calls, producing zero `tool_call`/`tool_result` entries in +LLM-visible history. + +## **Parameters** + + + Key in `global_data` to store collected answers under. When `null`, answers are + stored at the top level of `global_data`. + + + + Where to go when all questions are answered. + + - `"next_step"` -- auto-advance to the next sequential step + - A step name (e.g., `"process_results"`) -- jump to that specific step + - `null` -- return to normal step mode after gathering + + + + Preamble text injected once when entering the gather step, giving the AI + personality and context for asking the questions. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$ctx = $contexts->addContext("default"); +$intake = $ctx->addStep("intake"); +$intake->setText("Collect patient information."); +$intake->setGatherInfo( + output_key: "patient_info", + completion_action: "next_step", + prompt: "Be friendly and professional when collecting information." +); +$intake->addGatherQuestion( + key: "full_name", + question: "What is your full name?", + confirm: true +); +$ctx->addStep("review")->setText("Review the collected information with the patient."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-consolidate.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-consolidate.mdx new file mode 100644 index 000000000..522b978b8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-consolidate.mdx @@ -0,0 +1,43 @@ +--- +title: "setResetConsolidate" +slug: /reference/php/agents/context-builder/step/set-reset-consolidate +description: Set whether to consolidate conversation history on context switch. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Set whether to consolidate conversation history when this step switches contexts. + +## **Parameters** + + + Whether to summarize previous conversation on context switch. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {11} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->addStep("greet")->setText("Welcome the caller."); +$transfer = $ctx->addStep("transfer"); +$transfer->setText("Transfer the caller to support."); +$transfer->setValidContexts(["support"]); +$transfer->setResetConsolidate(true); +$support = $contexts->addContext("support"); +$support->addStep("help")->setText("Help the caller with their issue."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-full-reset.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-full-reset.mdx new file mode 100644 index 000000000..8b473f50a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-full-reset.mdx @@ -0,0 +1,47 @@ +--- +title: "setResetFullReset" +slug: /reference/php/agents/context-builder/step/set-reset-full-reset +description: Set whether to completely replace the system prompt on context switch. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Set whether to completely replace the system prompt when this step switches +contexts. + +## **Parameters** + + + Whether to fully rewrite the system prompt on context switch. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {11} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->addStep("greet")->setText("Welcome the caller."); +$transfer = $ctx->addStep("transfer"); +$transfer->setText("Transfer the caller to billing."); +$transfer->setValidContexts(["billing"]); +$transfer->setResetFullReset(true); +$transfer->setResetSystemPrompt( + "You are a billing specialist. Forget all previous context." . +); +$billing = $contexts->addContext("billing"); +$billing->addStep("invoice")->setText("Help with billing inquiries."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-system-prompt.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-system-prompt.mdx new file mode 100644 index 000000000..b5a5fd588 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-system-prompt.mdx @@ -0,0 +1,45 @@ +--- +title: "setResetSystemPrompt" +slug: /reference/php/agents/context-builder/step/set-reset-system-prompt +description: Set a new system prompt for context switching from this step. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Set a new system prompt for when this step navigates to another context. + +## **Parameters** + + + New system prompt to use during the context switch. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {11} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->addStep("greet")->setText("Welcome the caller."); +$transfer = $ctx->addStep("transfer"); +$transfer->setText("Transfer the caller to billing."); +$transfer->setValidContexts(["billing"]); +$transfer->setResetSystemPrompt( + "You are now a billing specialist. Help the customer with their invoice." . +); +$billing = $contexts->addContext("billing"); +$billing->addStep("invoice")->setText("Help with billing inquiries."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-user-prompt.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-user-prompt.mdx new file mode 100644 index 000000000..71ca2d18a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-reset-user-prompt.mdx @@ -0,0 +1,45 @@ +--- +title: "setResetUserPrompt" +slug: /reference/php/agents/context-builder/step/set-reset-user-prompt +description: Set a user message to inject when this step triggers a context switch. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Set a user message to inject when this step triggers a context switch. + +## **Parameters** + + + User message to inject. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {11} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->addStep("greet")->setText("Welcome the caller."); +$transfer = $ctx->addStep("transfer"); +$transfer->setText("Transfer the caller to billing."); +$transfer->setValidContexts(["billing"]); +$transfer->setResetUserPrompt( + "The customer needs help with their most recent invoice." . +); +$billing = $contexts->addContext("billing"); +$billing->addStep("invoice")->setText("Help with billing inquiries."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-skip-to-next-step.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-skip-to-next-step.mdx new file mode 100644 index 000000000..65b9c1776 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-skip-to-next-step.mdx @@ -0,0 +1,41 @@ +--- +title: "setSkipToNextStep" +slug: /reference/php/agents/context-builder/step/set-skip-to-next-step +description: Automatically advance to the next step without evaluating criteria. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Automatically advance to the next step without evaluating step criteria. Useful +for steps that should always flow through sequentially. + +## **Parameters** + + + Whether to skip to the next step automatically. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$ctx = $contexts->addContext("default"); +$preamble = $ctx->addStep("preamble"); +$preamble->setText("Read the disclaimer to the caller."); +$preamble->setSkipToNextStep(true); +$ctx->addStep("main")->setText("Help the caller with their request."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-skip-user-turn.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-skip-user-turn.mdx new file mode 100644 index 000000000..b43db652c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-skip-user-turn.mdx @@ -0,0 +1,41 @@ +--- +title: "setSkipUserTurn" +slug: /reference/php/agents/context-builder/step/set-skip-user-turn +description: Skip waiting for user input after this step completes. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Skip waiting for user input after this step completes. The AI proceeds +immediately without waiting for the caller to speak. + +## **Parameters** + + + Whether to skip the user turn. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {9} +defineContexts(); +$ctx = $contexts->addContext("default"); +$intro = $ctx->addStep("intro"); +$intro->setText("Introduce yourself and immediately begin the intake process."); +$intro->setSkipUserTurn(true); +$ctx->addStep("intake")->setText("Collect the caller's information."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-step-criteria.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-step-criteria.mdx new file mode 100644 index 000000000..e7144b48d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-step-criteria.mdx @@ -0,0 +1,50 @@ +--- +title: "setStepCriteria" +slug: /reference/php/agents/context-builder/step/set-step-criteria +description: Define when this step is considered complete. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Define when this step is considered complete. The AI evaluates this description +against the conversation state to determine whether to advance. + +## **Parameters** + + + Natural-language description of completion conditions. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + + +Be specific. Write "Customer has provided their full name AND phone number" rather +than "Information collected". Include failure conditions when appropriate: +"Verified OR after 3 failed attempts". + + +## **Example** + +```php {9} +defineContexts(); +$ctx = $contexts->addContext("default"); +$step = $ctx->addStep("verify_identity"); +$step->setText("Verify the caller's identity."); +$step->setStepCriteria( + "Complete when the customer has provided their account number " . + "AND verified it with the last four digits of their SSN, " . + "OR after 3 failed verification attempts." . +); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-text.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-text.mdx new file mode 100644 index 000000000..d0b30055b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-text.mdx @@ -0,0 +1,44 @@ +--- +title: "setText" +slug: /reference/php/agents/context-builder/step/set-text +description: Set the step's prompt text directly. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Set the step's prompt text directly. Cannot be used with `addSection()` or +`addBullets()`. + + +Mixing `setText()` with `addSection()` or `addBullets()` raises `ValueError`. +Use one approach or the other. + + +## **Parameters** + + + Plain-text prompt instructions for this step. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {8} +defineContexts(); +$ctx = $contexts->addContext("default"); +$step = $ctx->addStep("greeting"); +$step->setText("Welcome the caller and ask how you can help."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-valid-contexts.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-valid-contexts.mdx new file mode 100644 index 000000000..1bdfbd840 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-valid-contexts.mdx @@ -0,0 +1,45 @@ +--- +title: "setValidContexts" +slug: /reference/php/agents/context-builder/step/set-valid-contexts +description: Set which contexts the agent can navigate to from this step. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Set which contexts the agent can navigate to from this step. Overrides any +context-level `setValidContexts()` for this step. + +## **Parameters** + + + List of context names that are reachable from this step. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {10} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->addStep("greet")->setText("Welcome the caller."); +$step = $ctx->addStep("transfer"); +$step->setText("Transfer the caller to the appropriate department."); +$step->setValidContexts(["billing", "support"]); +$billing = $contexts->addContext("billing"); +$billing->addStep("invoice")->setText("Help with billing inquiries."); +$support = $contexts->addContext("support"); +$support->addStep("help")->setText("Help with support issues."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-valid-steps.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-valid-steps.mdx new file mode 100644 index 000000000..4b33fceab --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/step/set-valid-steps.mdx @@ -0,0 +1,43 @@ +--- +title: "setValidSteps" +slug: /reference/php/agents/context-builder/step/set-valid-steps +description: Set which steps the agent can navigate to from this step. +max-toc-depth: 3 +--- + +[ref-step]: /docs/sdks/reference/php/agents/context-builder/step + +Set which steps the agent can navigate to from this step. + +## **Parameters** + + + List of step names within the same context. Use `"next"` to allow sequential + advancement to the next step in order. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. + +## **Example** + +```php {10} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->addStep("greet")->setText("Welcome the caller."); +$step = $ctx->addStep("collect_info"); +$step->setText("Collect the caller's information."); +$step->setValidSteps(["process_request", "escalate"]); +$ctx->addStep("process_request")->setText("Process the caller's request."); +$ctx->addStep("escalate")->setText("Escalate to a human agent."); + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/context-builder/validate.mdx b/fern/products/sdks/pages/reference/php/agents/context-builder/validate.mdx new file mode 100644 index 000000000..b95813849 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/context-builder/validate.mdx @@ -0,0 +1,48 @@ +--- +title: "validate" +slug: /reference/php/agents/context-builder/validate +description: Validate the entire context configuration tree. +max-toc-depth: 3 +--- + +Validate the entire context configuration. Called automatically during SWML +rendering, but can be called manually to catch errors early. + +Checks performed: + +- At least one context exists. +- A single context is named `"default"`. +- Every context has at least one step. +- All `valid_steps` references point to steps that exist within the same context + (the special value `"next"` is always allowed). +- All `valid_contexts` references (at both context and step level) point to contexts + that exist in the builder. +- All `gather_info` configurations have at least one question, no duplicate keys, + and valid `completion_action` targets. + +## **Returns** + +`null` -- Raises `ValueError` with a descriptive message if validation fails. + +## **Example** + +```php {10} +defineContexts(); +$ctx = $contexts->addContext("default"); +$ctx->addStep("greet")->setText("Hello!"); + +try { + $contexts->validate(); +} catch (ValueError $e) { + echo "Invalid context config: {$e}"; +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/body.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/body.mdx new file mode 100644 index 000000000..5fbe58198 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/body.mdx @@ -0,0 +1,76 @@ +--- +title: "body" +slug: /reference/php/agents/data-map/body +description: Set the request body or parameters for a webhook. +max-toc-depth: 3 +--- + +[ref-datamap]: /docs/sdks/reference/php/agents/data-map + +### body + +**body**(`data`) -> [`DataMap`][ref-datamap] + +Set the request body for the most recently added webhook. Used for POST/PUT +requests. Writes to the `body` key of the webhook definition. + +## **Parameters** + + + Request body data. Supports `${variable}` substitutions. + + +## **Returns** + +`DataMap` -- Self for method chaining. Raises `ValueError` if no webhook has been +added yet. + +--- + +### params + +**params**(`data`) -> `DataMap` + +Set request query/form parameters for the most recently added webhook. Writes to the +`params` key of the webhook definition. + + +`params()` is **not** an alias for `body()`. They write to different keys in the +webhook specification: `body` sets the request body, while `params` sets +query/form parameters. + + +## **Parameters** + + + Request parameters. Supports `${variable}` substitutions. + + +## **Returns** + +`DataMap` -- Self for method chaining. + +## **Example** + +```php {13} + "Bearer TOKEN"] + ) + .$body(["query" => "${args.query]", "limit": 3}) + .$output(new FunctionResult("Found: ${response.results[0].title}")) +); + +echo $search->toSwaigFunction(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/create-expression-tool.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/create-expression-tool.mdx new file mode 100644 index 000000000..470b9792c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/create-expression-tool.mdx @@ -0,0 +1,48 @@ +--- +title: "createExpressionTool" +slug: /reference/php/agents/data-map/create-expression-tool +description: Create a expression tool. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/data-map + +Create a expression tool. + +## **Parameters** + + + The name identifier. + + + + The purpose description for the tool. + + + + Parameter definitions for the tool. + + + + Array of expression definitions. + + +## **Returns** + +`array` -- Array representation. + +## **Example** + +```php + "value"], + expressions: [] +); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/create-simple-api-tool.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/create-simple-api-tool.mdx new file mode 100644 index 000000000..b3658e8b5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/create-simple-api-tool.mdx @@ -0,0 +1,64 @@ +--- +title: "createSimpleApiTool" +slug: /reference/php/agents/data-map/create-simple-api-tool +description: Create a simple api tool. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/data-map + +Create a simple api tool. + +## **Parameters** + + + The name identifier. + + + + The purpose description for the tool. + + + + Parameter definitions for the tool. + + + + The HTTP method. + + + + The URL endpoint. + + + + The expected output format. + + + + HTTP headers to include. + Defaults to `[]`. + + +## **Returns** + +`array` -- Array representation. + +## **Example** + +```php + "value"], + method: "GET", + url: "https://api.example.com/plants", + output: "value", + headers: ["Content-Type" => "application/json"] +); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/description.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/description.mdx new file mode 100644 index 000000000..03c21b34c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/description.mdx @@ -0,0 +1,31 @@ +--- +title: "description" +slug: /reference/php/agents/data-map/description +description: Set the description for the data map tool. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/data-map + +Set the description for the data map tool. + +## **Parameters** + + + Description text. + + +## **Returns** + +`self` -- The the data map instance for method chaining. + +## **Example** + +```php +description("Look up plant information"); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/error-keys.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/error-keys.mdx new file mode 100644 index 000000000..cc5cd13cc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/error-keys.mdx @@ -0,0 +1,63 @@ +--- +title: "errorKeys" +slug: /reference/php/agents/data-map/error-keys +description: Set error detection keys for webhook responses. +max-toc-depth: 3 +--- + +[ref-datamap]: /docs/sdks/reference/php/agents/data-map + +Set error keys for the most recently added webhook (or top-level if no webhooks +exist). If any of these keys appear in the API response, the response is treated +as an error. + +## **Parameters** + + + List of JSON keys whose presence indicates an error. + + +## **Returns** + +[`DataMap`][ref-datamap] -- Self for method chaining. + +--- + +Set top-level error keys that apply to all webhooks. + +## **Parameters** + + + List of JSON keys whose presence indicates an error. + + +## **Returns** + +`DataMap` -- Self for method chaining. + +## **Example** + +```php {9} +setPromptText("You are a helpful assistant."); +$agent->registerSwaigFunction($api_tool->toSwaigFunction()); + + $agent->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/expression.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/expression.mdx new file mode 100644 index 000000000..54b64b16a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/expression.mdx @@ -0,0 +1,69 @@ +--- +title: "expression" +slug: /reference/php/agents/data-map/expression +description: Add a pattern-based response without an API call. +max-toc-depth: 3 +--- + +[ref-datamap]: /docs/sdks/reference/php/agents/data-map +[ref-functionresult]: /docs/sdks/reference/php/agents/function-result + +Add a pattern-based response that does not require an API call. Expressions are +evaluated in order; the first matching pattern wins. + +## **Parameters** + + + Template string to test (e.g., `"${args.command}"`). + + + + Regex pattern to match against the test value. + + + + [FunctionResult][ref-functionresult] to return when the pattern matches. + + + + Optional FunctionResult to return when the pattern does not match. + + +## **Returns** + +[`DataMap`][ref-datamap] -- Self for method chaining. + +## **Example** + +```php {8,12,16} +setPromptText("You are a helpful assistant."); +$agent->registerSwaigFunction($volume_control->toSwaigFunction()); + + $agent->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/fallback-output.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/fallback-output.mdx new file mode 100644 index 000000000..72df6ac09 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/fallback-output.mdx @@ -0,0 +1,31 @@ +--- +title: "fallbackOutput" +slug: /reference/php/agents/data-map/fallback-output +description: Set the fallback output when no expressions match. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/data-map + +Set the fallback output when no expressions match. + +## **Parameters** + + + The fallback result value. + + +## **Returns** + +`self` -- The the data map instance for method chaining. + +## **Example** + +```php +fallbackOutput("value"); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/foreach.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/foreach.mdx new file mode 100644 index 000000000..20b30ae06 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/foreach.mdx @@ -0,0 +1,78 @@ +--- +title: "foreach" +slug: /reference/php/agents/data-map/foreach +description: Process an array from the webhook response. +max-toc-depth: 3 +--- + +[ref-datamap]: /docs/sdks/reference/php/agents/data-map + +Process an array from the webhook response, building a formatted string from +each element. + +## **Parameters** + + + Configuration dictionary with the following keys: + + + + + Key in the API response containing the array. + + + + Variable name for the built string (reference as `${output_key}` in output). + + + + Maximum number of items to process. + + + + Template string to append for each item. Use `${this.field}` to reference + fields on the current array element. + + + +## **Returns** + +[`DataMap`][ref-datamap] -- Self for method chaining. Raises `ValueError` if no webhook has been +added yet. + +## **Example** + +```php {14} + "Bearer TOKEN"] + ) + .$body(["query" => "${args.query]", "limit": 3}) + .foreach({ + "input_key": "results", + "output_key": "formatted_results", + "max": 3, + "append": "- ${this.title}: ${this.summary}\n" + }) + .$output(new FunctionResult("Found:\n${formatted_results}")) + .fallbackOutput(new FunctionResult("Search is currently unavailable.")) +); + +$agent = new AgentBase(name: "docs-agent"); +$agent->setPromptText("You are a helpful assistant."); +$agent->registerSwaigFunction($search_docs->toSwaigFunction()); + + $agent->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/global-error-keys.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/global-error-keys.mdx new file mode 100644 index 000000000..331613686 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/global-error-keys.mdx @@ -0,0 +1,31 @@ +--- +title: "globalErrorKeys" +slug: /reference/php/agents/data-map/global-error-keys +description: Set the global error keys for data map processing. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/data-map + +Set the global error keys for data map processing. + +## **Parameters** + + + Array of error key strings. + + +## **Returns** + +`self` -- The the data map instance for method chaining. + +## **Example** + +```php +globalErrorKeys(["error_key"]); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/index.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/index.mdx new file mode 100644 index 000000000..6d642ab32 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/index.mdx @@ -0,0 +1,219 @@ +--- +title: "DataMap" +slug: /reference/php/agents/data-map +description: "Fluent builder for server-side API tools that execute without webhooks." +max-toc-depth: 3 +--- + +[swaigfunction]: /docs/sdks/reference/php/agents/swaig-function +[functionresult]: /docs/sdks/reference/php/agents/function-result +[data-map]: /docs/swml/reference/ai/swaig/functions/data-map +[swml-data-map-reference]: /docs/swml/reference/ai/swaig/functions/data-map +[body]: /docs/sdks/reference/php/agents/data-map/body +[errorkeys]: /docs/sdks/reference/php/agents/data-map/error-keys +[expression]: /docs/sdks/reference/php/agents/data-map/expression +[foreach]: /docs/sdks/reference/php/agents/data-map/foreach +[output]: /docs/sdks/reference/php/agents/data-map/output +[parameter]: /docs/sdks/reference/php/agents/data-map/parameter +[purpose]: /docs/sdks/reference/php/agents/data-map/purpose +[toswaigfunction]: /docs/sdks/reference/php/agents/data-map/to-swaig-function +[webhook]: /docs/sdks/reference/php/agents/data-map/webhook +[webhookexpressions]: /docs/sdks/reference/php/agents/data-map/webhook-expressions + +DataMap builds SWAIG function definitions that execute REST API calls directly on +SignalWire's infrastructure -- no webhook endpoint required on your server. This +reduces latency, simplifies deployment, and is ideal for straightforward +API-to-response integrations. + +Use DataMap when you need to call an external REST API and format the response +with simple variable substitution. For complex business logic, database access, +or multi-step processing, use a standard SWAIG function with a handler instead. + + +See [`SWAIGFunction`][swaigfunction] for +handler-based tool definitions, and +[`FunctionResult`][functionresult] for the +response builder used in DataMap outputs. + + + +DataMap generates a SWML [`data_map`][data-map] object +within a SWAIG function definition. See the +[SWML data_map reference][swml-data-map-reference] for the +full specification. + + +## **Properties** + + + Name of the SWAIG function this DataMap will create. + + +## **Variable Substitution Patterns** + +| Pattern | Description | +|---------|-------------| +| `${args.param}` | Function argument value | +| `${enc:args.param}` | URL-encoded argument (use in webhook URLs) | +| `${lc:args.param}` | Lowercase argument value | +| `${fmt_ph:args.phone}` | Format as phone number | +| `${response.field}` | API response field | +| `${response.arr[0]}` | Array element in response | +| `${global_data.key}` | Global session data | +| `${meta_data.key}` | Call metadata | +| `${this.field}` | Current item in foreach | +| [`createExpressionTool()`](/docs/sdks/reference/php/agents/data-map/create-expression-tool) | Create expression tool. | +| [`createSimpleApiTool()`](/docs/sdks/reference/php/agents/data-map/create-simple-api-tool) | Create simple api tool. | +| [`description()`](/docs/sdks/reference/php/agents/data-map/description) | Get the description. | +| [`fallbackOutput()`](/docs/sdks/reference/php/agents/data-map/fallback-output) | fallbackOutput. | +| [`globalErrorKeys()`](/docs/sdks/reference/php/agents/data-map/global-error-keys) | globalErrorKeys. | +| [`params()`](/docs/sdks/reference/php/agents/data-map/params) | Get the parameters. | + +Modifiers are applied right-to-left: `${enc:lc:args.param}` lowercases first, +then URL-encodes. + +## **Methods** + + + + Set the request body or parameters for a webhook. + + + Set error detection keys for webhook responses. + + + Add a pattern-based response without an API call. + + + Process an array from the webhook response. + + + Set the output template for a webhook or the fallback output. + + + Add a function parameter to the tool definition. + + + Set the function description shown to the AI. + + + Convert the DataMap to a SWAIG function definition dictionary. + + + Add an API call to the DataMap. + + + Add post-processing expressions for a webhook response. + + + +--- + +## **Examples** + +### Weather lookup + +```php {11} +addLanguage("English", "en-US", "rime.spore"); + self->promptAddSection("Role", "You help users check the weather."); + } + + $weather = ( + new DataMap("get_weather") + .$description("Get current weather for a city") + .$parameter("city", "string", "City name", required: true) + .$webhook( + "GET", + "https://api.weatherapi.com/v1/current.json" . + "?key=YOUR_API_KEY&q=${enc:args.city}" + ) + .$output(new FunctionResult( + "Current weather in ${args.city}: " . + "${response.current.condition.text}, " . + "${response.current.temp_f} degrees Fahrenheit" + )) + .fallbackOutput(new FunctionResult( + "Sorry, I couldn't get weather data for ${args.city}" + )) + ); + + self->registerSwaigFunction($weather->toSwaigFunction()); + + $WeatherAgent()->run(); + +``` + +### Expression-based control + +```php {5} +setPromptText("You are a helpful assistant."); +$agent->registerSwaigFunction($volume_control->toSwaigFunction()); + + $agent->run(); + +``` + +### POST with body and foreach + +```php {5} + "Bearer TOKEN"] + ) + .$body(["query" => "${args.query]", "limit": 3}) + .foreach({ + "input_key": "results", + "output_key": "formatted_results", + "max": 3, + "append": "- ${this.title}: ${this.summary}\n" + }) + .$output(new FunctionResult("Found:\n${formatted_results}")) + .fallbackOutput(new FunctionResult("Search is currently unavailable.")) +); + +echo $search_docs->toSwaigFunction(); + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/output.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/output.mdx new file mode 100644 index 000000000..4b1d6f310 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/output.mdx @@ -0,0 +1,76 @@ +--- +title: "output" +slug: /reference/php/agents/data-map/output +description: Set the output template for a webhook or the fallback output. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result +[ref-datamap]: /docs/sdks/reference/php/agents/data-map + +Set the output for the most recently added webhook. The +[`FunctionResult`][functionresult] template +is filled with response data after the API call succeeds. + +## **Parameters** + + + A FunctionResult defining the response template. Use `${response.field}` to + reference API response fields. + + +## **Returns** + +[`DataMap`][ref-datamap] -- Self for method chaining. Raises `ValueError` if no webhook has been +added yet. + +--- + +Set a top-level fallback output used when all webhooks fail. + +## **Parameters** + + + A FunctionResult defining the fallback response. + + +## **Returns** + +`DataMap` -- Self for method chaining. + + +Always set a `fallbackOutput` so the AI has something meaningful to say even when +external APIs are unavailable. + + +## **Example** + +```php {9} +setPromptText("You are a helpful assistant."); +$agent->registerSwaigFunction($weather->toSwaigFunction()); + + $agent->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/parameter.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/parameter.mdx new file mode 100644 index 000000000..cc4ba91ce --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/parameter.mdx @@ -0,0 +1,62 @@ +--- +title: "parameter" +slug: /reference/php/agents/data-map/parameter +description: Add a function parameter to the tool definition. +max-toc-depth: 3 +--- + +[ref-datamap]: /docs/sdks/reference/php/agents/data-map + +Add a function parameter to the tool definition. + +## **Parameters** + + + Parameter name. + + + + JSON schema type for the parameter. + + - `"string"` -- text value + - `"integer"` -- whole number value + - `"number"` -- numeric value including decimals + - `"boolean"` -- true or false value + - `"array"` -- list of values + - `"object"` -- nested key-value structure + + + + Description of the parameter shown to the AI. + + + + Whether this parameter is required. + + + + Optional list of allowed values for this parameter. + + +## **Returns** + +[`DataMap`][ref-datamap] -- Self for method chaining. + +## **Example** + +```php {6-7} +toSwaigFunction(); +// {'function': 'get_weather', 'parameters': {'type': 'object', 'properties': {'city': ..., 'units': ...}, 'required': ['city']}, ...} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/params.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/params.mdx new file mode 100644 index 000000000..853888183 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/params.mdx @@ -0,0 +1,31 @@ +--- +title: "params" +slug: /reference/php/agents/data-map/params +description: Set the input parameters for the data map tool. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/data-map + +Set the input parameters for the data map tool. + +## **Parameters** + + + The data payload. + + +## **Returns** + +`self` -- The the data map instance for method chaining. + +## **Example** + +```php +params([]); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/purpose.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/purpose.mdx new file mode 100644 index 000000000..fa89568fb --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/purpose.mdx @@ -0,0 +1,63 @@ +--- +title: "purpose" +slug: /reference/php/agents/data-map/purpose +description: Set the function description shown to the AI. +max-toc-depth: 3 +--- + +[ref-datamap]: /docs/sdks/reference/php/agents/data-map + +Set the function description shown to the AI when deciding which tool to call. + +## **Parameters** + + + Human-readable description of what this function does. + + +## **Returns** + +[`DataMap`][ref-datamap] -- Self for method chaining. + +--- + +Alias for `purpose()`. + +## **Parameters** + + + Human-readable description of what this function does. + + +## **Returns** + +`DataMap` -- Self for method chaining. + +## **Example** + +```php {4} +purpose("Get the current weather for a given city"); + +echo $weather->toSwaigFunction(); +// {'function': 'get_weather', 'description': 'Get the current weather for a given city', ...} + + +``` + +The `description()` method is an alias for `purpose()`: + +```php +description("Get the current weather for a given city"); + +echo $weather->toSwaigFunction(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/to-swaig-function.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/to-swaig-function.mdx new file mode 100644 index 000000000..725c575d7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/to-swaig-function.mdx @@ -0,0 +1,49 @@ +--- +title: "toSwaigFunction" +slug: /reference/php/agents/data-map/to-swaig-function +description: Convert the DataMap to a SWAIG function definition dictionary. +max-toc-depth: 3 +--- + +[ref-datamap]: /docs/sdks/reference/php/agents/data-map + +Convert this [DataMap][ref-datamap] to a SWAIG function definition dictionary. Register the +result with your agent using `agent.registerSwaigFunction()`. + +## **Returns** + +`dict[string, mixed]` -- A dictionary containing the function name, description, +parameter schema, and `data_map` configuration (instead of a webhook URL). + +## **Example** + +```php {19} +setPromptText("You are a helpful assistant."); + } + + $weather = ( + new DataMap("get_weather") + .$description("Get current weather for a city") + .$parameter("city", "string", "City name", required: true) + .$webhook("GET", "https://api.weatherapi.com/v1/current.json?key: KEY&q: ${enc:args.city}") + .$output(new FunctionResult("Weather: ${response.current.condition.text}, ${response.current.temp_f}F")) + .fallbackOutput(new FunctionResult("Weather data unavailable for ${args.city}")) + ); + + // Convert DataMap to a SWAIG function definition and register it + self->registerSwaigFunction($weather->toSwaigFunction()); + + $WeatherAgent()->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/webhook-expressions.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/webhook-expressions.mdx new file mode 100644 index 000000000..689134fed --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/webhook-expressions.mdx @@ -0,0 +1,57 @@ +--- +title: "webhookExpressions" +slug: /reference/php/agents/data-map/webhook-expressions +description: Add post-processing expressions for a webhook response. +max-toc-depth: 3 +--- + +[ref-datamap]: /docs/sdks/reference/php/agents/data-map + +Add expressions that run after the most recently added webhook completes. +Allows conditional output based on the API response. + +## **Parameters** + + + List of expression definitions to evaluate against the webhook response. + + +## **Returns** + +[`DataMap`][ref-datamap] -- Self for method chaining. Raises `ValueError` if no webhook has been +added yet. + +## **Example** + +```php {8} + "Service ${args.service] is running normally."} + }, + { + "test": "${response.status}", + "pattern": "degraded|down", + "output": ["response" => "Service ${args.service] is experiencing issues."} + } + ]) +); + +$agent = new AgentBase(name: "status-agent"); +$agent->setPromptText("You are a helpful assistant."); +$agent->registerSwaigFunction($status_check->toSwaigFunction()); + + $agent->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/data-map/webhook.mdx b/fern/products/sdks/pages/reference/php/agents/data-map/webhook.mdx new file mode 100644 index 000000000..90280b799 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/data-map/webhook.mdx @@ -0,0 +1,94 @@ +--- +title: "webhook" +slug: /reference/php/agents/data-map/webhook +description: Add an API call to the DataMap. +max-toc-depth: 3 +--- + +[ref-datamap]: /docs/sdks/reference/php/agents/data-map + +Add an API call. Multiple webhooks can be chained -- they execute in order, and +if earlier webhooks fail, later ones act as fallbacks. + +## **Parameters** + + + HTTP method for the request. + + - `"GET"` -- retrieve a resource + - `"POST"` -- create a resource or submit data + - `"PUT"` -- replace a resource + - `"DELETE"` -- remove a resource + - `"PATCH"` -- partially update a resource + + + + API endpoint URL. Supports `${variable}` substitutions (use `${enc:args.param}` + for URL-encoded values). + + + + HTTP headers to include in the request. + + + + Send the JSON body as a single form parameter with this name. + + + + Merge function arguments into the request parameters automatically. + + + + Only execute this webhook if all listed arguments are present. + + +## **Returns** + +[`DataMap`][ref-datamap] -- Self for method chaining. + +## **Example** + +```php {8} + "application/json"] + ) + .$output(new FunctionResult("Weather: ${response.current.condition.text}")) +); + +echo $weather->toSwaigFunction(); + + +``` + +Chained webhooks act as fallbacks -- if the first webhook fails, the second is tried: + +```php {8,10} + + Action type identifier (e.g., `"hold"`, `"hangup"`, `"setGlobalData"`). + + + + Action payload. Can be a string, boolean, dict, or list depending on the action type. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11-12} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="custom_action", description="Process a custom action") +function customAction($args, $raw_data) +{ + return (; + new FunctionResult("Processing your request.") + .addAction("setGlobalData", ["status" => "active"]) + .addAction("hold", 60) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/add-actions.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/add-actions.mdx new file mode 100644 index 000000000..5f96a71e8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/add-actions.mdx @@ -0,0 +1,50 @@ +--- +title: "addActions" +slug: /reference/php/agents/function-result/add-actions +description: Append multiple raw actions to the FunctionResult action list. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Append multiple raw actions at once. Each action dictionary is added to the +action list in order. + +## **Parameters** + + + List of action dictionaries to append. Each dictionary should map a single + action name to its payload. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="batch_actions", description="Process multiple actions at once") +function batchActions($args, $raw_data) +{ + return (; + new FunctionResult("Processing your request.") + .addActions([ + ["setGlobalData" => {"key": "value"]}, + ["hold" => 60], + ["say" => "Please wait."] + ]) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/add-dynamic-hints.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/add-dynamic-hints.mdx new file mode 100644 index 000000000..30c4964d2 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/add-dynamic-hints.mdx @@ -0,0 +1,85 @@ +--- +title: "addDynamicHints" +slug: /reference/php/agents/function-result/add-dynamic-hints +description: Add speech recognition hints dynamically during a call. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Add speech recognition hints dynamically during a call. Hints improve recognition +accuracy for domain-specific vocabulary, product names, or uncommon words. Each +hint can be a simple string or a pronunciation pattern object that maps +misrecognized speech to the correct text. + +## **Parameters** + + + List of hints. Each entry is either: + - A `string` — a word or phrase to boost recognition (e.g., `"SignalWire"`) + - A `dict` with pronunciation pattern fields: + + | Field | Type | Description | + |-------|------|-------------| + | `pattern` | `string` | Regex pattern to match in recognized speech | + | `replace` | `string` | Replacement text when the pattern matches | + | `ignore_case` | `bool` | Case-insensitive matching (optional) | + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Examples** + +### Simple Word Hints + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="set_medical_context", description="Add medical speech hints") +function setMedicalContext($args, $raw_data) +{ + return (; + new FunctionResult("Switching to medical context.") + .addDynamicHints(["prescription", "dosage", "milligrams", "refill"]) + ); +} + +$agent->serve(); + + +``` + +### Pronunciation Patterns + +```php {12} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="set_name_hints", description="Add name pronunciation hints") +function setNameHints($args, $raw_data) +{ + $name = $args["customer_name"] ?? ""; + return (; + new FunctionResult("I'll listen for {$name}.") + .addDynamicHints([ + $name, + ["pattern" => "cab bee", "replace": "Cabby", "ignore_case": true] + ]) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/clear-dynamic-hints.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/clear-dynamic-hints.mdx new file mode 100644 index 000000000..cc351cc9d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/clear-dynamic-hints.mdx @@ -0,0 +1,41 @@ +--- +title: "clearDynamicHints" +slug: /reference/php/agents/function-result/clear-dynamic-hints +description: Remove all dynamically added speech recognition hints. +max-toc-depth: 3 +--- + +[add-dynamic-hints]: /docs/sdks/reference/php/agents/function-result/add-dynamic-hints +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Remove all dynamically added speech recognition hints. This clears every hint +that was previously added via [`addDynamicHints()`][add-dynamic-hints]. +Static hints defined on the agent at configuration time are not affected. + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="reset_context", description="Reset speech recognition context") +function resetContext($args, $raw_data) +{ + return (; + new FunctionResult("Context reset.") + .clearDynamicHints() + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/connect.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/connect.mdx new file mode 100644 index 000000000..01be9bca5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/connect.mdx @@ -0,0 +1,116 @@ +--- +title: "connect" +slug: /reference/php/agents/function-result/connect +description: Transfer or connect the call to another destination. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Transfer or connect the call to another destination. Generates a SWML `connect` +verb under the hood. + + +When `final=True` (the default), the call permanently leaves the agent. When +`final=False`, the call returns to the agent if the far end hangs up first. + + +## **Parameters** + + + Where to connect the call. Accepts a phone number in E.164 format (e.g., + `"+15551234567"`) or a SIP address (e.g., `"support@company.com"`). + + + + Whether this is a permanent transfer. + - `True` — call exits the agent completely (terminal action) + - `False` — call returns to the agent when the far end hangs up + + + + Caller ID override. Phone number or SIP address to show as the caller. When + `null`, the current call's originating address is used. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Examples** + +### Permanent Transfer + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="transfer_to_sales", description="Transfer caller to the sales team") +function transferToSales($args, $raw_data) +{ + return (; + new FunctionResult("Transferring you to sales.") + .$connect("+15551234567", final: true) + ); +} + +$agent->serve(); + + +``` + +### Temporary Transfer + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="consult_specialist", description="Connect to a specialist temporarily") +function consultSpecialist($args, $raw_data) +{ + return (; + new FunctionResult("Connecting you to a specialist.") + .$connect("+15551234567", final: false) + ); +} + +$agent->serve(); + + +``` + +### Custom Caller ID + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="transfer_with_caller_id", description="Transfer with custom caller ID") +function transferWithCallerId($args, $raw_data) +{ + return (; + new FunctionResult("Transferring now.") + .$connect( + "support@company.com", + final: true, + from_addr: "+15559876543" + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/create-payment-action.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/create-payment-action.mdx new file mode 100644 index 000000000..77f2b9068 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/create-payment-action.mdx @@ -0,0 +1,66 @@ +--- +title: "createPaymentAction" +slug: /reference/php/agents/function-result/create-payment-action +description: Build a single action entry for a payment prompt. +max-toc-depth: 3 +--- + +[create-payment-prompt]: /docs/sdks/reference/php/agents/function-result/create-payment-prompt +[ref-functionresult]: /docs/sdks/reference/php/agents/function-result + +**[FunctionResult][ref-functionresult].create_payment_action**(`action_type`, `phrase`) -> `dict[string, string]` + +Static helper that builds a single action entry for a payment prompt. + +## **Parameters** + + + Action type. + + - `"Say"` -- use text-to-speech + - `"Play"` -- play an audio file URL + + + + Text to speak (when `action_type` is `"Say"`) or URL to play (when `action_type` + is `"Play"`). + + +## **Returns** + +`dict[string, string]` — action dictionary for use in +[`createPaymentPrompt()`][create-payment-prompt]. + +## **Example** + +```php {9-10} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="collect_card", description="Collect card payment") +function collectCard($args, $raw_data) +{ + $say_action = FunctionResult->createPaymentAction("Say", "Please enter your card number."); + $play_action = FunctionResult->createPaymentAction("Play", "https://example.com/card-prompt.mp3"); + $prompt = FunctionResult->createPaymentPrompt( + for_situation: "payment-card-number", + actions: [$say_action] + ); + return (; + new FunctionResult("I'll collect your payment now.") + .$pay( + payment_connector_url: "https://api.example.com/pay", + charge_amount: "19.99", + prompts: [$prompt] + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/create-payment-parameter.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/create-payment-parameter.mdx new file mode 100644 index 000000000..2ba13a016 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/create-payment-parameter.mdx @@ -0,0 +1,66 @@ +--- +title: "createPaymentParameter" +slug: /reference/php/agents/function-result/create-payment-parameter +description: Build a parameter entry for the pay() method. +max-toc-depth: 3 +--- + +[pay]: /docs/sdks/reference/php/agents/function-result/pay +[ref-functionresult]: /docs/sdks/reference/php/agents/function-result + +**[FunctionResult][ref-functionresult].create_payment_parameter**(`name`, `value`) -> `dict[string, string]` + +Static helper that builds a parameter entry for the `parameters` list of +[`pay()`][pay]. + +## **Parameters** + + + Parameter name. + + + + Parameter value. + + +## **Returns** + +`dict[string, string]` — parameter dictionary for use in the `parameters` list of +[`pay()`][pay]. + +## **Example** + +```php {22} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="subscription_payment", description="Set up a subscription payment") +function subscriptionPayment($args, $raw_data) +{ + $prompt = FunctionResult->createPaymentPrompt( + for_situation: "payment-card-number", + actions: [ + FunctionResult->createPaymentAction("Say", "Please enter your credit card number.") + ] + ); + return (; + new FunctionResult("Let's set up your subscription.") + .$pay( + payment_connector_url: "https://api.example.com/subscribe", + charge_amount: "29.99", + prompts: [$prompt], + parameters: [ + FunctionResult->createPaymentParameter("plan", "monthly") + ] + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/create-payment-prompt.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/create-payment-prompt.mdx new file mode 100644 index 000000000..db64ec72e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/create-payment-prompt.mdx @@ -0,0 +1,75 @@ +--- +title: "createPaymentPrompt" +slug: /reference/php/agents/function-result/create-payment-prompt +description: Build a payment prompt object for use with pay(). +max-toc-depth: 3 +--- + +[pay]: /docs/sdks/reference/php/agents/function-result/pay +[create-payment-action]: /docs/sdks/reference/php/agents/function-result/create-payment-action +[ref-functionresult]: /docs/sdks/reference/php/agents/function-result + +**[FunctionResult][ref-functionresult].create_payment_prompt**(`for_situation`, `actions`, `card_type=null`, `error_type=null`) -> `dict[string, mixed]` + +Static helper that builds a payment prompt object for use with the `prompts` +parameter of [`pay()`][pay]. +Payment prompts customize the TTS messages played during different stages of +payment collection. + +## **Parameters** + + + The payment stage this prompt applies to (e.g., `"payment-card-number"`, + `"expiration-date"`, `"security-code"`, `"postal-code"`). + + + + List of prompt actions. Use [`createPaymentAction()`][create-payment-action] + to build each entry. + + + + Space-separated card types this prompt applies to (e.g., `"visa mastercard"`). + + + + Space-separated error types this prompt handles. + + +## **Returns** + +`dict[string, mixed]` — prompt dictionary to pass in the `prompts` list of [`pay()`][pay]. + +## **Example** + +```php {9} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="collect_card", description="Collect card payment") +function collectCard($args, $raw_data) +{ + $prompt = FunctionResult->createPaymentPrompt( + for_situation: "payment-card-number", + actions: [ + FunctionResult->createPaymentAction("Say", "Please enter your credit card number.") + ] + ); + return (; + new FunctionResult("I'll collect your payment now.") + .$pay( + payment_connector_url: "https://api.example.com/pay", + charge_amount: "49.99", + prompts: [$prompt] + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/enable-extensive-data.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/enable-extensive-data.mdx new file mode 100644 index 000000000..9ae486e9f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/enable-extensive-data.mdx @@ -0,0 +1,46 @@ +--- +title: "enableExtensiveData" +slug: /reference/php/agents/function-result/enable-extensive-data +description: Send full data to the LLM for the current turn only. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Send full data to the LLM for the current turn only. On subsequent turns, the +full data is replaced with a smaller summary. Useful for one-time data-heavy +responses that would otherwise bloat the conversation history. + +## **Parameters** + + + `True` to send extensive data this turn, `False` to disable. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="return_large_result", description="Return detailed search results") +function returnLargeResult($args, $raw_data) +{ + return (; + new FunctionResult("Here are the detailed search results.") + .enableExtensiveData(true) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/enable-functions-on-timeout.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/enable-functions-on-timeout.mdx new file mode 100644 index 000000000..ff029ec4a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/enable-functions-on-timeout.mdx @@ -0,0 +1,46 @@ +--- +title: "enableFunctionsOnTimeout" +slug: /reference/php/agents/function-result/enable-functions-on-timeout +description: Allow SWAIG function calls when a speaker timeout occurs. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Control whether SWAIG functions can be called when a speaker timeout occurs. +When enabled, the agent can invoke functions after the user has been silent +for the configured timeout period. + +## **Parameters** + + + `True` to allow function calls on speaker timeout, `False` to disable. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="enable_escalation_on_timeout", description="Enable function calls on timeout") +function enableEscalationOnTimeout($args, $raw_data) +{ + return (; + new FunctionResult("I'll help you with that.") + .enableFunctionsOnTimeout(enabled: true) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/execute-rpc.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/execute-rpc.mdx new file mode 100644 index 000000000..d62ad0151 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/execute-rpc.mdx @@ -0,0 +1,67 @@ +--- +title: "executeRpc" +slug: /reference/php/agents/function-result/execute-rpc +description: Execute a generic RPC method on a call. +max-toc-depth: 3 +--- + +[rpc-dial]: /docs/sdks/reference/php/agents/function-result/rpc-dial +[rpc-ai-message]: /docs/sdks/reference/php/agents/function-result/rpc-ai-message +[rpc-ai-unhold]: /docs/sdks/reference/php/agents/function-result/rpc-ai-unhold +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Execute a generic RPC method on a call. This is the low-level interface for +cross-call communication. For common operations, prefer the specific helpers +[`rpcDial()`][rpc-dial], +[`rpcAiMessage()`][rpc-ai-message], and +[`rpcAiUnhold()`][rpc-ai-unhold]. + +## **Parameters** + + + RPC method name (e.g., `"dial"`, `"ai_message"`, `"ai_unhold"`). + + + + Parameters for the RPC method. + + + + Target call ID for the RPC command. + + + + Target node ID for the RPC command. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="execute_custom_rpc", description="Execute a custom RPC command") +function executeCustomRpc($args, $raw_data) +{ + return (; + new FunctionResult("Executing RPC.") + .executeRpc( + method: "ai_message", + call_id: "target-call-id", + params: ["role" => "system", "message_text": "Hello from another call."] + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/execute-swml.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/execute-swml.mdx new file mode 100644 index 000000000..0e6b95a47 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/execute-swml.mdx @@ -0,0 +1,75 @@ +--- +title: "executeSwml" +slug: /reference/php/agents/function-result/execute-swml +description: Execute a raw SWML document as an action. +max-toc-depth: 3 +--- + +[connect]: /docs/sdks/reference/php/agents/function-result/connect +[record-call]: /docs/sdks/reference/php/agents/function-result/record-call +[send-sms]: /docs/sdks/reference/php/agents/function-result/send-sms +[functionresult]: /docs/sdks/reference/php/agents/function-result +[ref-swmlbuilder]: /docs/sdks/reference/php/agents/swml-builder + +Execute a raw SWML document as an action. This is the escape hatch for advanced +use cases that are not covered by the named convenience methods. + + +Most use cases are covered by the specific action methods +([`connect()`][connect], +[`recordCall()`][record-call], +[`sendSms()`][send-sms], etc.). +Use `executeSwml()` only when you need SWML features not available through +convenience methods. + + +## **Parameters** + + + SWML content in one of three formats: + - `string` — raw SWML JSON text (parsed internally) + - `dict` — SWML data structure + - SWML object — any object with a `.to_dict()` method (e.g., a [`Document`][ref-swmlbuilder] instance) + + + + When `True`, the call exits the agent after the SWML executes. When `False`, + the SWML executes inline and the agent continues. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {20} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="play_announcement", description="Play an announcement") +function playAnnouncement($args, $raw_data) +{ + $swml_doc = {; + "version": "1.0.0", + "sections": { + "main": [; + ["play" => {"url": "https://example.com/announcement.mp3"]}, + ["hangup" => {]} + ]; + } + } + return (; + new FunctionResult() + .executeSwml($swml_doc, transfer: false) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/hangup.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/hangup.mdx new file mode 100644 index 000000000..e0ff38869 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/hangup.mdx @@ -0,0 +1,44 @@ +--- +title: "hangup" +slug: /reference/php/agents/function-result/hangup +description: End the call immediately. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +End the call immediately. + + +This is a terminal action. Any actions chained **after** `hangup()` may not execute. +Always place `hangup()` last in the chain. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {12} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="end_call", description="End the call") +function endCall($args, $raw_data) +{ + return (; + new FunctionResult("Thank you for calling. Goodbye!") + .updateGlobalData(["call_ended" => true]) + .$hangup() + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/hold.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/hold.mdx new file mode 100644 index 000000000..810de4cdb --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/hold.mdx @@ -0,0 +1,45 @@ +--- +title: "hold" +slug: /reference/php/agents/function-result/hold +description: Put the call on hold with an optional timeout. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Put the call on hold. The caller hears hold music until the hold is released +or the timeout expires. + +## **Parameters** + + + Maximum hold duration in seconds. Clamped to the range 0--900 (15 minutes max). + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {7,11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="hold_for_agent", description="Place the caller on hold") +function holdForAgent($args, $raw_data) +{ + return (; + new FunctionResult("Please hold while I find an available agent.") + .$hold(timeout: 60) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/index.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/index.mdx new file mode 100644 index 000000000..e879bd48f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/index.mdx @@ -0,0 +1,390 @@ +--- +title: "FunctionResult" +slug: /reference/php/agents/function-result +description: Fluent interface for returning responses and actions from SWAIG tool functions. +max-toc-depth: 3 +--- + +[tool]: /docs/sdks/reference/php/agents/agent-base#tool +[define-tool]: /docs/sdks/reference/php/agents/agent-base/define-tool +[agentbase]: /docs/sdks/reference/php/agents/agent-base +[swaig-function]: /docs/swml/reference/ai/swaig/functions +[swml-swaig-functions-reference]: /docs/swml/reference/ai/swaig/functions +[setresponse]: /docs/sdks/reference/php/agents/function-result/set-response +[setpostprocess]: /docs/sdks/reference/php/agents/function-result/set-post-process +[addaction]: /docs/sdks/reference/php/agents/function-result/add-action +[addactions]: /docs/sdks/reference/php/agents/function-result/add-actions +[connect]: /docs/sdks/reference/php/agents/function-result/connect +[hangup]: /docs/sdks/reference/php/agents/function-result/hangup +[hold]: /docs/sdks/reference/php/agents/function-result/hold +[swmltransfer]: /docs/sdks/reference/php/agents/function-result/swml-transfer +[say]: /docs/sdks/reference/php/agents/function-result/say +[waitforuser]: /docs/sdks/reference/php/agents/function-result/wait-for-user +[stop]: /docs/sdks/reference/php/agents/function-result/stop +[playbackgroundfile]: /docs/sdks/reference/php/agents/function-result/play-background-file +[stopbackgroundfile]: /docs/sdks/reference/php/agents/function-result/stop-background-file +[recordcall]: /docs/sdks/reference/php/agents/function-result/record-call +[stoprecordcall]: /docs/sdks/reference/php/agents/function-result/stop-record-call +[tap]: /docs/sdks/reference/php/agents/function-result/tap +[stoptap]: /docs/sdks/reference/php/agents/function-result/stop-tap +[updateglobaldata]: /docs/sdks/reference/php/agents/function-result/update-global-data +[removeglobaldata]: /docs/sdks/reference/php/agents/function-result/remove-global-data +[setmetadata]: /docs/sdks/reference/php/agents/function-result/set-metadata +[removemetadata]: /docs/sdks/reference/php/agents/function-result/remove-metadata +[swmlchangestep]: /docs/sdks/reference/php/agents/function-result/swml-change-step +[swmlchangecontext]: /docs/sdks/reference/php/agents/function-result/swml-change-context +[switchcontext]: /docs/sdks/reference/php/agents/function-result/switch-context +[swmluserevent]: /docs/sdks/reference/php/agents/function-result/swml-user-event +[simulateuserinput]: /docs/sdks/reference/php/agents/function-result/simulate-user-input +[togglefunctions]: /docs/sdks/reference/php/agents/function-result/toggle-functions +[enablefunctionsontimeout]: /docs/sdks/reference/php/agents/function-result/enable-functions-on-timeout +[adddynamichints]: /docs/sdks/reference/php/agents/function-result/add-dynamic-hints +[cleardynamichints]: /docs/sdks/reference/php/agents/function-result/clear-dynamic-hints +[setendofspeechtimeout]: /docs/sdks/reference/php/agents/function-result/set-end-of-speech-timeout +[setspeecheventtimeout]: /docs/sdks/reference/php/agents/function-result/set-speech-event-timeout +[updatesettings]: /docs/sdks/reference/php/agents/function-result/update-settings +[enableextensivedata]: /docs/sdks/reference/php/agents/function-result/enable-extensive-data +[replaceinhistory]: /docs/sdks/reference/php/agents/function-result/replace-in-history +[sendsms]: /docs/sdks/reference/php/agents/function-result/send-sms +[pay]: /docs/sdks/reference/php/agents/function-result/pay +[createpaymentprompt]: /docs/sdks/reference/php/agents/function-result/create-payment-prompt +[createpaymentaction]: /docs/sdks/reference/php/agents/function-result/create-payment-action +[createpaymentparameter]: /docs/sdks/reference/php/agents/function-result/create-payment-parameter +[siprefer]: /docs/sdks/reference/php/agents/function-result/sip-refer +[joinroom]: /docs/sdks/reference/php/agents/function-result/join-room +[joinconference]: /docs/sdks/reference/php/agents/function-result/join-conference +[executeswml]: /docs/sdks/reference/php/agents/function-result/execute-swml +[executerpc]: /docs/sdks/reference/php/agents/function-result/execute-rpc +[rpcdial]: /docs/sdks/reference/php/agents/function-result/rpc-dial +[rpcaimessage]: /docs/sdks/reference/php/agents/function-result/rpc-ai-message +[rpcaiunhold]: /docs/sdks/reference/php/agents/function-result/rpc-ai-unhold + +`FunctionResult` is the return type for all SWAIG tool functions. It wraps a response +message (text for the AI to speak) and an ordered list of actions (transfers, SMS, +data updates, context switches, and more). Every method returns `self`, so you can +chain calls into a single fluent expression. + +Returned from functions defined with the [`@tool()`][tool] decorator +or [`defineTool()`][define-tool] on +[`AgentBase`][agentbase]. + + +FunctionResult builds the response payload for a [SWAIG function][swaig-function]. +See the [SWML SWAIG functions reference][swml-swaig-functions-reference] for the +full response format specification. + + +## **Properties** + + + Text the AI speaks back to the caller after the function executes. + + + + Ordered list of action objects to execute. Actions run sequentially in the + order they were added. + + + + When `True`, the AI speaks the response and takes one more conversational turn + with the user before executing actions. When `False` (default), actions execute + immediately after the response. + + +## **Example** + +```php {10} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="transfer_to_billing", description="Transfer the caller to billing") +function transferToBilling($args, $raw_data) +{ + return (; + new FunctionResult( + "I'll transfer you to billing. Anything else first?", + post_process: true + ) + .updateGlobalData(["transferred" => true]) + .sendSms( + to_number: "+15551234567", + from_number: "+15559876543", + body: "You are being transferred to billing." + ) + .$connect("+15551234567", final: true) + ); +} + +$agent->serve(); + +``` + +## **Fluent Chaining Pattern** + +Every method on `FunctionResult` returns `self`, so you build complex responses +in a single expression. Actions execute in the order they are added. + + +Terminal actions like `connect(final=True)` and `hangup()` end the call flow. +Place them **last** in the chain so that preceding actions (data updates, SMS, etc.) +have a chance to execute. + + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="transfer_call", description="Transfer the call") +function transferCall($args, $raw_data) +{ + // Data update + SMS execute before the terminal transfer + return (; + new FunctionResult("Transferring you now.") + .updateGlobalData(["transferred" => true]) + .sendSms( + to_number: "+15551234567", + from_number: "+15559876543", + body: "Your call is being transferred." + ) + .$connect("+15551234567", final: true) # $terminal — $goes $last + ); +} + +$agent->serve(); + +``` + +## **Methods** + +### Core + + + + Set or replace the response text on a FunctionResult. + + + Enable or disable post-processing on a FunctionResult. + + + Append a raw action to the FunctionResult action list. + + + Append multiple raw actions to the FunctionResult action list. + + + +### Call Control + + + + Transfer or connect the call to another destination. + + + End the call immediately. + + + Put the call on hold with an optional timeout. + + + Transfer the call to a SWML endpoint with a return message. + + + +### Speech + + + + Make the AI agent speak specific text immediately. + + + Control how the agent pauses and waits for user input. + + + Stop the agent execution immediately. + + + +### Media + + + + Play an audio or video file in the background during a call. + + + Stop the currently playing background audio file. + + + Start recording the call in the background. + + + Stop an active background call recording. + + + Stream call audio to an external endpoint via WebSocket or RTP. + + + Stop an active media tap stream. + + + +### Data + + + + Set or update key-value pairs in the global session data. + + + Remove one or more keys from the global session data. + + + Set function-scoped metadata on a FunctionResult. + + + Remove one or more keys from the current function's metadata store. + + + +### Context Navigation + + + + Transition to a different step within the current conversation context. + + + Switch to a different conversation context. + + + Perform an advanced context switch with prompt replacement and history control. + + + +### Events + + + + Send a custom user event through SWML for real-time UI updates. + + + Inject text as simulated user speech input. + + + +### Functions + + + + Enable or disable specific SWAIG functions at runtime. + + + Allow SWAIG function calls when a speaker timeout occurs. + + + +### Hints + + + + Add speech recognition hints dynamically during a call. + + + Remove all dynamically added speech recognition hints. + + + +### Settings + + + + Adjust the end-of-speech silence timeout for speech recognition. + + + Adjust the speech event timeout for noisy environments. + + + Update AI runtime settings dynamically during a call. + + + Send full data to the LLM for the current turn only. + + + Control how this function call appears in the AI's conversation history. + + + +### SMS + + + + Send an SMS or MMS message from a tool function. + + + +### Payment + + + + Collect and process a credit card payment during a call. + + + Build a payment prompt object for use with pay(). + + + Build a single action entry for a payment prompt. + + + Build a parameter entry for the pay() method. + + + +### SIP + + + + Send a SIP REFER message to transfer the call in a SIP environment. + + + +### Rooms and Conferences + + + + Join a SignalWire RELAY room for multi-party communication. + + + Join an ad-hoc audio conference with extensive configuration options. + + + +### SWML and RPC + + + + Execute a raw SWML document as an action. + + + Execute a generic RPC method on a call. + + + Dial out to a phone number with a destination SWML URL via RPC. + + + Inject a message into the AI agent running on another call. + + + Release another call from hold via RPC. + + + Convert the result to an array. + + + Convert the result to a JSON string. + + diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/join-conference.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/join-conference.mdx new file mode 100644 index 000000000..32589670f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/join-conference.mdx @@ -0,0 +1,184 @@ +--- +title: "joinConference" +slug: /reference/php/agents/function-result/join-conference +description: Join an ad-hoc audio conference with extensive configuration options. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Join an ad-hoc audio conference. Conferences support both RELAY and CXML calls +with extensive configuration for moderation, recording, and event callbacks. + +When all parameters are at their defaults (except `name`), a simplified form is +used internally. Passing any non-default parameter triggers the full object form. + +## **Parameters** + + + Conference name. All participants joining the same name are in the same + conference. + + + + Join the conference muted. + + + + Beep configuration for join/leave notifications. + + - `"true"` -- beep on both enter and exit + - `"false"` -- no beep + - `"onEnter"` -- beep only when a participant joins + - `"onExit"` -- beep only when a participant leaves + + + + Whether the conference starts when this participant enters. When `False`, + the participant waits until another participant with `start_on_enter=True` joins. + + + + Whether the conference ends for all participants when this participant leaves. + + + + SWML URL for hold music played while waiting for the conference to start. + When `null`, default hold music is used. + + + + Maximum number of participants. Must be a positive integer, maximum 250. + + + + Recording mode. + + - `"do-not-record"` -- do not record the conference + - `"record-from-start"` -- begin recording as soon as the conference starts + + + + Conference region for geographic optimization. + + + + Silence trimming in recordings. + + - `"trim-silence"` -- remove leading and trailing silence from the recording + - `"do-not-trim"` -- keep silence in the recording as-is + + + + SWML Call ID or CXML CallSid of a participant who can coach (whisper to) + this participant without other participants hearing. + + + + Space-separated list of events to report. + + - `"start"` -- conference has started + - `"end"` -- conference has ended + - `"join"` -- a participant joined + - `"leave"` -- a participant left + - `"mute"` -- a participant was muted or unmuted + - `"hold"` -- a participant was placed on hold or resumed + - `"modify"` -- conference settings were modified + - `"speaker"` -- active speaker changed + - `"announcement"` -- an announcement was played + + + + URL to receive conference status event webhooks. + + + + HTTP method for status callbacks. + + - `"GET"` -- send status callbacks as GET requests + - `"POST"` -- send status callbacks as POST requests + + + + URL to receive recording status event webhooks. + + + + HTTP method for recording status callbacks. + + - `"GET"` -- send recording status callbacks as GET requests + - `"POST"` -- send recording status callbacks as POST requests + + + + Space-separated list of recording events to report. + + - `"in-progress"` -- recording is currently in progress + - `"completed"` -- recording has completed + - `"absent"` -- no recording was produced + + + + Result handling configuration. Pass an object `{}` for `return_value`-based + switching, or an array `[]` for conditional switching. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Examples** + +### Simple Conference + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="join_team_call", description="Join the team standup call") +function joinTeamCall($args, $raw_data) +{ + return (; + new FunctionResult("Joining the team call.") + .joinConference(name: "team-standup") + ); +} + +$agent->serve(); + + +``` + +### Moderated Conference + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="join_moderated_conference", description="Join a moderated conference") +function joinModeratedConference($args, $raw_data) +{ + return (; + new FunctionResult("Joining the conference.") + .joinConference( + name: "quarterly-review", + muted: true, + start_on_enter: false, + record: "record-from-start", + max_participants: 50 + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/join-room.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/join-room.mdx new file mode 100644 index 000000000..0c133aecd --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/join-room.mdx @@ -0,0 +1,45 @@ +--- +title: "joinRoom" +slug: /reference/php/agents/function-result/join-room +description: Join a SignalWire RELAY room for multi-party communication. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Join a SignalWire RELAY room. Rooms enable multi-party communication and +collaboration between participants. + +## **Parameters** + + + Name of the room to join. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="join_support_room", description="Join the support room") +function joinSupportRoom($args, $raw_data) +{ + return (; + new FunctionResult("Connecting to the support room.") + .joinRoom(name: "support-room-1") + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/pay.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/pay.mdx new file mode 100644 index 000000000..4cf88dbe2 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/pay.mdx @@ -0,0 +1,138 @@ +--- +title: "pay" +slug: /reference/php/agents/function-result/pay +description: Collect and process a credit card payment during a call. +max-toc-depth: 3 +--- + +[create-payment-parameter]: /docs/sdks/reference/php/agents/function-result/create-payment-parameter +[create-payment-prompt]: /docs/sdks/reference/php/agents/function-result/create-payment-prompt +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Collect and process a credit card payment during the call. Generates a SWML +`pay` verb that walks the caller through entering card details via DTMF or +voice, then submits to your payment connector endpoint. + +## **Parameters** + + + URL of your payment processing endpoint. SignalWire sends the collected card + data to this URL for processing. + + + + How the caller provides card details. + + - `"dtmf"` -- caller enters digits on the keypad + - `"voice"` -- caller speaks the numbers + + + + URL to receive payment status change webhook notifications. + + + + Payment method type. Currently only `"credit-card"` is supported. + + + + Seconds to wait for the next DTMF digit before timing out. + + + + Number of retry attempts if payment collection fails. + + + + Whether to prompt the caller for the card's security code (CVV). + + + + Whether to prompt for the billing postal code. Pass `True` to prompt, `False` + to skip, or a string with the actual postal code to use without prompting. + + + + Minimum number of digits required for the postal code. + + + + Payment token type. + + - `"one-time"` -- single-use token + - `"reusable"` -- token can be charged again later + + + + Amount to charge as a decimal string (e.g., `"49.99"`). + + + + ISO 4217 currency code (e.g., `"usd"`, `"eur"`). + + + + Language for TTS payment prompts (e.g., `"en-US"`, `"es-MX"`). + + + + TTS voice for payment prompts (e.g., `"woman"`, `"man"`). + + + + Custom description for the payment transaction. + + + + Space-separated list of accepted card types. + + + + Additional name/value pairs to send to the payment connector. + Use [`createPaymentParameter()`][create-payment-parameter] to build entries. + + + + Custom prompt configurations to override default payment prompts. + Use [`createPaymentPrompt()`][create-payment-prompt] to build entries. + + + + AI response template after payment completes. The `${pay_result}` variable + is substituted with the payment outcome. Set to `null` to disable. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {7,12} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="collect_payment", description="Collect a credit card payment") +function collectPayment($args, $raw_data) +{ + $amount = $args["amount"] ?? null; + return (; + new FunctionResult("I'll collect your payment information now.") + .$pay( + payment_connector_url: "https://api.example.com/payment", + charge_amount: $amount, + currency: "usd", + security_code: true, + postal_code: true + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/play-background-file.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/play-background-file.mdx new file mode 100644 index 000000000..37cb43f87 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/play-background-file.mdx @@ -0,0 +1,52 @@ +--- +title: "playBackgroundFile" +slug: /reference/php/agents/function-result/play-background-file +description: Play an audio or video file in the background during a call. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Play an audio or video file in the background while the conversation continues. + +## **Parameters** + + + URL of the audio or video file to play (e.g., `"https://example.com/hold-music.mp3"`). + + + + When `True`, suppresses the agent's attention-getting behavior during playback. + The agent will not try to re-engage the user while the file is playing. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="play_hold_music", description="Play hold music in the background") +function playHoldMusic($args, $raw_data) +{ + return (; + new FunctionResult("Please hold.") + .playBackgroundFile( + "https://example.com/hold-music.mp3", + wait: true + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/record-call.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/record-call.mdx new file mode 100644 index 000000000..34ee3e0e6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/record-call.mdx @@ -0,0 +1,137 @@ +--- +title: "recordCall" +slug: /reference/php/agents/function-result/record-call +description: Start recording the call in the background. +max-toc-depth: 3 +--- + +[stop-record-call]: /docs/sdks/reference/php/agents/function-result/stop-record-call +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Start recording the call in the background. The conversation continues while +recording is active. + + +For continuous call recording, omit `initial_timeout` and `end_silence_timeout`. +Those parameters are for voicemail-style recordings that automatically stop on +silence. Use [`stopRecordCall()`][stop-record-call] to end continuous recordings. + + +## **Parameters** + + + Identifier for this recording. Pass the same ID to `stopRecordCall()` to + stop this specific recording. + + + + Record in stereo (`True`) or mono (`False`). + + + + Recording file format. + + - `"wav"` -- uncompressed WAV audio + - `"mp3"` -- compressed MP3 audio + + + + Audio direction to record. + + - `"speak"` -- what the agent says + - `"listen"` -- what the caller says + - `"both"` -- both sides of the conversation + + + + DTMF digits that stop recording when pressed (e.g., `"#"`). + + + + Play a beep tone before recording starts. + + + + Input sensitivity level for the recording. + + + + Seconds to wait for speech to begin before auto-stopping. Used for + voicemail-style recordings. + + + + Seconds of silence after speech to wait before auto-stopping. Used for + voicemail-style recordings. + + + + Maximum recording duration in seconds. + + + + URL to receive recording status webhook events. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Examples** + +### Continuous Recording + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="start_recording", description="Start recording the call") +function startRecording($args, $raw_data) +{ + return (; + new FunctionResult("Recording started.") + .recordCall( + control_id: "main_recording", + stereo: true, + format: "mp3" + ) + ); +} + +$agent->serve(); + + +``` + +### Voicemail Recording + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="record_voicemail", description="Record a voicemail message") +function recordVoicemail($args, $raw_data) +{ + return (; + new FunctionResult("Please leave your message after the beep.") + .recordCall( + control_id: "voicemail", + beep: true, + max_length: 120.0, + end_silence_timeout: 3.0 + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/remove-global-data.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/remove-global-data.mdx new file mode 100644 index 000000000..1708badc8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/remove-global-data.mdx @@ -0,0 +1,44 @@ +--- +title: "removeGlobalData" +slug: /reference/php/agents/function-result/remove-global-data +description: Remove one or more keys from the global session data. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Remove one or more keys from the global session data. + +## **Parameters** + + + A single key string or a list of key strings to remove from global data. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="clear_session_data", description="Clear session data") +function clearSessionData($args, $raw_data) +{ + return (; + new FunctionResult("Session data cleared.") + .removeGlobalData(["customer_id", "verified"]) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/remove-metadata.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/remove-metadata.mdx new file mode 100644 index 000000000..c587286d3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/remove-metadata.mdx @@ -0,0 +1,44 @@ +--- +title: "removeMetadata" +slug: /reference/php/agents/function-result/remove-metadata +description: Remove one or more keys from the current function's metadata store. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Remove one or more keys from the current function's metadata store. + +## **Parameters** + + + A single key string or a list of key strings to remove from metadata. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="clear_metadata", description="Clear function metadata") +function clearMetadata($args, $raw_data) +{ + return (; + new FunctionResult("Metadata cleared.") + .removeMetadata(["timestamp", "user_id"]) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/replace-in-history.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/replace-in-history.mdx new file mode 100644 index 000000000..37671fc2b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/replace-in-history.mdx @@ -0,0 +1,82 @@ +--- +title: "replaceInHistory" +slug: /reference/php/agents/function-result/replace-in-history +description: Control how this function call appears in the AI's conversation history. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Control how this function call appears in the AI's conversation history. Use +this to remove sensitive information (credit card numbers, SSNs) or replace +verbose tool results with concise summaries. + + +When `True` is passed, the entire tool-call/result pair is removed from history. +When a string is passed, the pair is replaced with that text as an assistant message. + + +## **Parameters** + + + - `True` — remove the tool-call and result pair from history entirely + - A `string` — replace the pair with an assistant message containing this text + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Examples** + +### Remove Sensitive Exchange + +```php {13} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="verify_identity", description="Verify caller identity") +function verifyIdentity($args, $raw_data) +{ + $ssn = $args["ssn"] ?? null; + // ... verify SSN ... + return (; + new FunctionResult("I've verified your identity.") + .replaceInHistory(true) + ); +} + +$agent->serve(); + + +``` + +### Replace with Summary + +```php {13} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="process_payment", description="Process a payment") +function processPayment($args, $raw_data) +{ + $card_number = $args["card_number"] ?? null; + // ... process payment ... + return (; + new FunctionResult("Payment processed successfully.") + .replaceInHistory("Payment information was collected and processed.") + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/rpc-ai-message.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/rpc-ai-message.mdx new file mode 100644 index 000000000..0d7800396 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/rpc-ai-message.mdx @@ -0,0 +1,58 @@ +--- +title: "rpcAiMessage" +slug: /reference/php/agents/function-result/rpc-ai-message +description: Inject a message into the AI agent running on another call. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Inject a message into the AI agent running on another call. Useful for +cross-call coordination, such as notifying a held caller's agent about a +status change or instructing it to relay information. + +## **Parameters** + + + Call ID of the target call whose AI agent should receive the message. + + + + The message text to inject into the target AI's conversation. + + + + Role for the injected message. Typically `"system"` for instructions. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {12} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="notify_caller", description="Notify the caller on the other line") +function notifyCaller($args, $raw_data) +{ + $caller_call_id = $args["original_call_id"] ?? null; + return (; + new FunctionResult("I'll let them know.") + .rpcAiMessage( + call_id: $caller_call_id, + message_text: "The person you're trying to reach is unavailable. Please leave a message." + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/rpc-ai-unhold.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/rpc-ai-unhold.mdx new file mode 100644 index 000000000..8ba145e49 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/rpc-ai-unhold.mdx @@ -0,0 +1,48 @@ +--- +title: "rpcAiUnhold" +slug: /reference/php/agents/function-result/rpc-ai-unhold +description: Release another call from hold via RPC. +max-toc-depth: 3 +--- + +[rpc-ai-message]: /docs/sdks/reference/php/agents/function-result/rpc-ai-message +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Release another call from hold. Typically used after injecting a message into +the held caller's AI agent via [`rpcAiMessage()`][rpc-ai-message]. + +## **Parameters** + + + Call ID of the call to release from hold. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {13} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="release_caller", description="Release the caller from hold") +function releaseCaller($args, $raw_data) +{ + $caller_call_id = $args["original_call_id"] ?? null; + return (; + new FunctionResult("Returning you to the caller.") + .rpcAiMessage($caller_call_id, "You can take their message now.") + .rpcAiUnhold($caller_call_id) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/rpc-dial.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/rpc-dial.mdx new file mode 100644 index 000000000..f603d67d3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/rpc-dial.mdx @@ -0,0 +1,68 @@ +--- +title: "rpcDial" +slug: /reference/php/agents/function-result/rpc-dial +description: Dial out to a phone number with a destination SWML URL via RPC. +max-toc-depth: 3 +--- + +[hold]: /docs/sdks/reference/php/agents/function-result/hold +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Dial out to a phone number with a destination SWML URL that handles the +outbound call leg. This is commonly used in call screening scenarios: place the +caller on hold with [`hold()`][hold], +then dial out to a human whose call is handled by a separate SWML agent. + +## **Parameters** + + + Phone number to dial in E.164 format. + + + + Caller ID to display in E.164 format. + + + + URL of the SWML document that handles the outbound call leg. The SWML at this + URL typically runs a screening agent that can accept, reject, or take a message. + + + + Device type for the outbound leg. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {14} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="screen_call", description="Screen a call by dialing out") +function screenCall($args, $raw_data) +{ + $human_number = $args["phone_number"] ?? null; + $caller_name = $args["caller_name"] ?? "Unknown"; + return (; + new FunctionResult("Please hold while I connect you.") + .$hold(timeout: 120) + .rpcDial( + to_number: $human_number, + from_number: "+15559876543", + dest_swml: "https://example.com/screening-agent?caller={$caller_name}" + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/say.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/say.mdx new file mode 100644 index 000000000..ff1e3d2de --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/say.mdx @@ -0,0 +1,46 @@ +--- +title: "say" +slug: /reference/php/agents/function-result/say +description: Make the AI agent speak specific text immediately. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Make the AI agent speak specific text immediately, bypassing the normal LLM +response flow. The text is spoken in the agent's configured voice. + +## **Parameters** + + + Text for the agent to speak. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {12} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="announce_status", description="Announce the order status") +function announceStatus($args, $raw_data) +{ + $status = $args["status"] ?? null; + return (; + new FunctionResult() + .$say("Your order status is: {$status}") + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/send-sms.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/send-sms.mdx new file mode 100644 index 000000000..6b0490d7f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/send-sms.mdx @@ -0,0 +1,105 @@ +--- +title: "sendSms" +slug: /reference/php/agents/function-result/send-sms +description: Send an SMS or MMS message from a tool function. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Send an SMS or MMS message to a phone number. At least one of `body` or `media` +must be provided. Generates a SWML `sendSms` verb under the hood. + +## **Parameters** + + + Destination phone number in E.164 format (e.g., `"+15551234567"`). + + + + Sender phone number in E.164 format. Must be a number in your SignalWire project. + + + + Text body of the message. + + + + List of media URLs to include as MMS attachments. + + + + Tags to associate with the message for searching and filtering in the + SignalWire dashboard. + + + + Region to originate the message from. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Examples** + +### Text Message + +```php {13} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="send_confirmation", description="Send an order confirmation SMS") +function sendConfirmation($args, $raw_data) +{ + $phone = $args["phone_number"] ?? null; + $order_id = $args["order_id"] ?? null; + return (; + new FunctionResult("I've sent you a confirmation text.") + .sendSms( + to_number: $phone, + from_number: "+15559876543", + body: "Your order {$order_id} has been confirmed!" + ) + ); +} + +$agent->serve(); + + +``` + +### MMS with Media + +```php {13} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="send_receipt", description="Send a receipt with media attachment") +function sendReceipt($args, $raw_data) +{ + $phone = $args["phone_number"] ?? null; + $receipt_url = $args["receipt_url"] ?? null; + return (; + new FunctionResult("I've sent your receipt.") + .sendSms( + to_number: $phone, + from_number: "+15559876543", + body: "Here's your receipt:", + media: [$receipt_url] + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/set-end-of-speech-timeout.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/set-end-of-speech-timeout.mdx new file mode 100644 index 000000000..1da7becdd --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/set-end-of-speech-timeout.mdx @@ -0,0 +1,47 @@ +--- +title: "setEndOfSpeechTimeout" +slug: /reference/php/agents/function-result/set-end-of-speech-timeout +description: Adjust the end-of-speech silence timeout for speech recognition. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Adjust the end-of-speech timeout. This controls how many milliseconds of silence +after detected speech are required before the system finalizes speech recognition. +A shorter value makes the agent respond faster; a longer value gives the caller +more time to pause mid-sentence. + +## **Parameters** + + + Timeout in milliseconds. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="speed_up_response", description="Reduce speech timeout for faster responses") +function speedUpResponse($args, $raw_data) +{ + return (; + new FunctionResult() + .setEndOfSpeechTimeout(500) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/set-metadata.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/set-metadata.mdx new file mode 100644 index 000000000..01423de9e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/set-metadata.mdx @@ -0,0 +1,50 @@ +--- +title: "setMetadata" +slug: /reference/php/agents/function-result/set-metadata +description: Set function-scoped metadata on a FunctionResult. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Set function-scoped metadata. Metadata is scoped to the current function's +`meta_data_token`, so each function maintains its own independent metadata +store. + +## **Parameters** + + + Dictionary of key-value pairs to store as metadata. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="track_usage", description="Track user activity") +function trackUsage($args, $raw_data) +{ + return (; + new FunctionResult("Usage tracked.") + .setMetadata({ + "last_action": "search", + "timestamp": "2024-01-15T10:30:00Z", + "user_id": args.$get("user_id") + }) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/set-post-process.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/set-post-process.mdx new file mode 100644 index 000000000..de3720e7d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/set-post-process.mdx @@ -0,0 +1,48 @@ +--- +title: "setPostProcess" +slug: /reference/php/agents/function-result/set-post-process +description: Enable or disable post-processing on a FunctionResult. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Enable or disable post-processing after construction. When post-processing is +enabled, the AI speaks the response and takes one more conversational turn with +the user before executing actions. This is useful for confirmation workflows. + +## **Parameters** + + + `True` to let the AI respond once more before executing actions. `False` to + execute actions immediately. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="transfer_with_confirmation", description="Transfer with confirmation") +function transferWithConfirmation($args, $raw_data) +{ + return (; + new FunctionResult("I'll transfer you to billing. Do you have any other questions first?") + .setPostProcess(true) + .$connect("+15551234567", final: true) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/set-response.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/set-response.mdx new file mode 100644 index 000000000..5ebab90c0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/set-response.mdx @@ -0,0 +1,50 @@ +--- +title: "setResponse" +slug: /reference/php/agents/function-result/set-response +description: Set or replace the response text on a FunctionResult. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Set or replace the response text after construction. The response is the text +the AI speaks back to the caller after the function executes. + +## **Parameters** + + + Text for the AI to speak to the caller. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {12,14} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="check_order", description="Look up an order by ID") +function checkOrder($args, $raw_data) +{ + $order_id = $args["order_id"] ?? null; + $result = new FunctionResult(); + if ($order_id) { + $result->setResponse("Your order {$order_id} shipped yesterday."); + } + } else { + $result->setResponse("I couldn't find that order number."); + } + return $result; +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/set-speech-event-timeout.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/set-speech-event-timeout.mdx new file mode 100644 index 000000000..b352fb4c7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/set-speech-event-timeout.mdx @@ -0,0 +1,49 @@ +--- +title: "setSpeechEventTimeout" +slug: /reference/php/agents/function-result/set-speech-event-timeout +description: Adjust the speech event timeout for noisy environments. +max-toc-depth: 3 +--- + +[set-end-of-speech-timeout]: /docs/sdks/reference/php/agents/function-result/set-end-of-speech-timeout +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Adjust the speech event timeout. This controls how many milliseconds since the +last speech detection event to wait before finalizing recognition. This timeout +works better than [`setEndOfSpeechTimeout()`][set-end-of-speech-timeout] +in noisy environments. + +## **Parameters** + + + Timeout in milliseconds. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {12} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="configure_timeouts", description="Configure speech recognition timeouts") +function configureTimeouts($args, $raw_data) +{ + return (; + new FunctionResult() + .setEndOfSpeechTimeout(800) + .setSpeechEventTimeout(5000) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/simulate-user-input.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/simulate-user-input.mdx new file mode 100644 index 000000000..e7ffa3ffa --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/simulate-user-input.mdx @@ -0,0 +1,46 @@ +--- +title: "simulateUserInput" +slug: /reference/php/agents/function-result/simulate-user-input +description: Inject text as simulated user speech input. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Inject text as if the user spoke it. The AI agent processes the injected text +exactly as it would process real speech input. Useful for driving automated +workflows or confirmations. + +## **Parameters** + + + Text to inject as simulated user speech. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="auto_confirm", description="Automatically confirm the action") +function autoConfirm($args, $raw_data) +{ + return (; + new FunctionResult() + .simulateUserInput("yes, I confirm") + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/sip-refer.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/sip-refer.mdx new file mode 100644 index 000000000..720358396 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/sip-refer.mdx @@ -0,0 +1,55 @@ +--- +title: "sipRefer" +slug: /reference/php/agents/function-result/sip-refer +description: Send a SIP REFER message to transfer the call in a SIP environment. +max-toc-depth: 3 +--- + +[connect]: /docs/sdks/reference/php/agents/function-result/connect +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Send a SIP REFER message to transfer the call in a SIP environment. This is +used for attended or blind transfers within SIP-based phone systems and PBX +deployments. + + +For standard phone-number or SIP-address transfers, use +[`connect()`][connect] +instead. Use `sipRefer()` when the transfer must be performed via the SIP +REFER mechanism (e.g., transferring to a PBX extension). + + +## **Parameters** + + + SIP URI to send the REFER to (e.g., `"sip:1001@pbx.example.com"`). + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {12} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="transfer_to_extension", description="Transfer to a PBX extension") +function transferToExtension($args, $raw_data) +{ + $extension = $args["extension"] ?? null; + return (; + new FunctionResult("Transferring to extension {$extension}.") + .sipRefer("sip:{$extension}@pbx.example.com") + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/stop-background-file.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/stop-background-file.mdx new file mode 100644 index 000000000..510fcf817 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/stop-background-file.mdx @@ -0,0 +1,38 @@ +--- +title: "stopBackgroundFile" +slug: /reference/php/agents/function-result/stop-background-file +description: Stop the currently playing background audio file. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Stop the currently playing background audio file. + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="stop_hold_music", description="Stop hold music playback") +function stopHoldMusic($args, $raw_data) +{ + return (; + new FunctionResult("I'm back.") + .stopBackgroundFile() + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/stop-record-call.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/stop-record-call.mdx new file mode 100644 index 000000000..42d4dd417 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/stop-record-call.mdx @@ -0,0 +1,45 @@ +--- +title: "stopRecordCall" +slug: /reference/php/agents/function-result/stop-record-call +description: Stop an active background call recording. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Stop an active background call recording. + +## **Parameters** + + + Identifier of the recording to stop. If not provided, the most recent + recording is stopped. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="stop_recording", description="Stop recording the call") +function stopRecording($args, $raw_data) +{ + return (; + new FunctionResult("Recording stopped.") + .stopRecordCall(control_id: "main_recording") + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/stop-tap.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/stop-tap.mdx new file mode 100644 index 000000000..73c032992 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/stop-tap.mdx @@ -0,0 +1,45 @@ +--- +title: "stopTap" +slug: /reference/php/agents/function-result/stop-tap +description: Stop an active media tap stream. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Stop an active media tap stream. + +## **Parameters** + + + Identifier of the tap to stop. If not provided, the most recently started + tap is stopped. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="stop_monitoring", description="Stop monitoring the call") +function stopMonitoring($args, $raw_data) +{ + return (; + new FunctionResult("Monitoring stopped.") + .$stop_tap(control_id: "supervisor_tap") + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/stop.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/stop.mdx new file mode 100644 index 000000000..bf14e767f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/stop.mdx @@ -0,0 +1,40 @@ +--- +title: "stop" +slug: /reference/php/agents/function-result/stop +description: Stop the agent execution immediately. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Stop the agent execution immediately. This halts the AI from processing further +and can be used to interrupt the current speech flow. + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="interrupt_and_restart", description="Interrupt and restart the conversation") +function interruptAndRestart($args, $raw_data) +{ + return (; + new FunctionResult() + .$stop() + .$say("Let me start over.") + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/switch-context.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/switch-context.mdx new file mode 100644 index 000000000..8cb2071ea --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/switch-context.mdx @@ -0,0 +1,99 @@ +--- +title: "switchContext" +slug: /reference/php/agents/function-result/switch-context +description: Perform an advanced context switch with prompt replacement and history control. +max-toc-depth: 3 +--- + +[swml-change-context]: /docs/sdks/reference/php/agents/function-result/swml-change-context +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Perform an advanced context switch by replacing the system prompt, injecting a +user message, or resetting the conversation entirely. This is more flexible +than [`swmlChangeContext()`][swml-change-context], +which switches to a pre-defined named context. + +When only `system_prompt` is provided (no other arguments), it performs a simple +string-based context switch. When multiple arguments are given, it constructs an +object-based context switch with fine-grained control. + +## **Parameters** + + + New system prompt to replace the current one. + + + + A user message to inject into the conversation after the context switch. + + + + When `True`, the existing conversation history is summarized into a condensed + form before applying the new context. Reduces token usage on long conversations. + + + + When `True`, performs a complete context reset, clearing all conversation + history and starting fresh with the new prompt. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Examples** + +### Simple Prompt Swap + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="switch_to_technical", description="Switch to technical support mode") +function switchToTechnical($args, $raw_data) +{ + return (; + new FunctionResult("Switching to technical support mode.") + .switchContext( + system_prompt: "You are a technical support specialist. " + "Help the customer with their technical issue." + ) + ); +} + +$agent->serve(); + + +``` + +### Full Reset with User Message + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="escalate_to_supervisor", description="Escalate to a supervisor") +function escalateToSupervisor($args, $raw_data) +{ + return (; + new FunctionResult("Connecting you to a supervisor.") + .switchContext( + system_prompt: "You are a customer service supervisor.", + user_prompt: "A customer has been escalated to you.", + full_reset: true + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/swml-change-context.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/swml-change-context.mdx new file mode 100644 index 000000000..0377b5ef2 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/swml-change-context.mdx @@ -0,0 +1,48 @@ +--- +title: "swmlChangeContext" +slug: /reference/php/agents/function-result/swml-change-context +description: Switch to a different conversation context. +max-toc-depth: 3 +--- + +[contextbuilder]: /docs/sdks/reference/php/agents/context-builder +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Switch to a different conversation context. Contexts represent distinct +operational modes (e.g., "sales", "support", "billing"), each with their own +prompts, tools, and steps defined via +[`ContextBuilder`][contextbuilder]. + +## **Parameters** + + + Name of the context to switch to. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="switch_to_billing", description="Switch to the billing context") +function switchToBilling($args, $raw_data) +{ + return (; + new FunctionResult("Let me connect you with billing.") + .swmlChangeContext("billing") + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/swml-change-step.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/swml-change-step.mdx new file mode 100644 index 000000000..057817772 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/swml-change-step.mdx @@ -0,0 +1,49 @@ +--- +title: "swmlChangeStep" +slug: /reference/php/agents/function-result/swml-change-step +description: Transition to a different step within the current conversation context. +max-toc-depth: 3 +--- + +[contextbuilder]: /docs/sdks/reference/php/agents/context-builder +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Transition to a different step within the current conversation context. Steps +are defined using +[`ContextBuilder`][contextbuilder] and +represent discrete stages in a workflow (e.g., "greeting", "verification", +"checkout"). + +## **Parameters** + + + Name of the step to transition to. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="move_to_checkout", description="Transition to the checkout step") +function moveToCheckout($args, $raw_data) +{ + return (; + new FunctionResult("Moving to checkout.") + .swmlChangeStep("checkout") + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/swml-transfer.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/swml-transfer.mdx new file mode 100644 index 000000000..a0aad3d43 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/swml-transfer.mdx @@ -0,0 +1,66 @@ +--- +title: "swmlTransfer" +slug: /reference/php/agents/function-result/swml-transfer +description: Transfer the call to a SWML endpoint with a return message. +max-toc-depth: 3 +--- + +[connect]: /docs/sdks/reference/php/agents/function-result/connect +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Transfer the call to a SWML endpoint and configure an AI response for when +control returns to the agent (relevant only when `final=False`). + + +For simple phone-number or SIP transfers, use [`connect()`][connect] instead. +Use `swmlTransfer()` when you need to hand off to another SWML document and +set up a return message. + + +## **Parameters** + + + Destination URL for the transfer (a SWML endpoint, SIP address, etc.). + + + + Message the AI speaks when the transfer completes and control returns to the + agent. Only meaningful when `final=False`. + + + + Whether this is a permanent transfer (`True`) or temporary (`False`). + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {12} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="transfer_to_support", description="Transfer to support SWML endpoint") +function transferToSupport($args, $raw_data) +{ + $department = $args["department"] ?? "support"; + return (; + new FunctionResult("Let me connect you.", post_process: true) + .swmlTransfer( + dest: "https://support.example.com/swml", + ai_response: "The support call is complete. How else can I help?", + final: false + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/swml-user-event.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/swml-user-event.mdx new file mode 100644 index 000000000..d89435196 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/swml-user-event.mdx @@ -0,0 +1,52 @@ +--- +title: "swmlUserEvent" +slug: /reference/php/agents/function-result/swml-user-event +description: Send a custom user event through SWML for real-time UI updates. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Send a custom user event through SWML. Events are delivered to connected +clients in real time, commonly used to drive UI updates in interactive +applications (e.g., updating a scoreboard, dealing cards, showing status). + +## **Parameters** + + + Dictionary containing the event payload. Include a `"type"` key to help + clients distinguish between different event types. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="deal_cards", description="Deal cards and notify the UI") +function dealCards($args, $raw_data) +{ + return (; + new FunctionResult("You have blackjack!") + .swmlUserEvent({ + "type": "cards_dealt", + "player_hand": ["Ace", "King"], + "dealer_hand": ["7", "hidden"], + "player_score": 21 + }) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/tap.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/tap.mdx new file mode 100644 index 000000000..942a9f5c6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/tap.mdx @@ -0,0 +1,80 @@ +--- +title: "tap" +slug: /reference/php/agents/function-result/tap +description: Stream call audio to an external endpoint via WebSocket or RTP. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Start a media tap that streams call audio to an external endpoint. Supports +WebSocket (`wss://`, `ws://`) and RTP (`rtp://`) destinations. + +## **Parameters** + + + Destination URI for the media stream. Supported formats: + - `"rtp://IP:port"` — RTP stream + - `"ws://example.com"` — WebSocket stream + - `"wss://example.com"` — Secure WebSocket stream + + + + Identifier for this tap. Pass the same ID to `stop_tap()` to end this + specific tap. If omitted, a default ID is generated. + + + + Audio direction to tap. + + - `"speak"` -- what the party says + - `"hear"` -- what the party hears + - `"both"` -- both directions + + + + Audio codec for the stream. + + - `"PCMU"` -- G.711 mu-law + - `"PCMA"` -- G.711 A-law + + + + Packetization time in milliseconds for RTP streams. Must be a positive integer. + + + + URL to receive tap status change webhooks. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="start_monitoring", description="Start monitoring the call audio") +function startMonitoring($args, $raw_data) +{ + return (; + new FunctionResult("Call monitoring started.") + .$tap( + uri: "wss://monitor.example.com/audio", + control_id: "supervisor_tap", + direction: "both" + ) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/to-array.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/to-array.mdx new file mode 100644 index 000000000..5038a5f90 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/to-array.mdx @@ -0,0 +1,29 @@ +--- +title: "toArray" +slug: /reference/php/agents/function-result/to-array +description: Convert the function result to an array. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/function-result + +Convert the function result to an array. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`array` -- Array representation. + +## **Example** + +```php +toArray(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/to-json.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/to-json.mdx new file mode 100644 index 000000000..964b21446 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/to-json.mdx @@ -0,0 +1,29 @@ +--- +title: "toJson" +slug: /reference/php/agents/function-result/to-json +description: Serialize the function result to JSON. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/function-result + +Serialize the function result to JSON. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- JSON string representation. + +## **Example** + +```php +toJson(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/toggle-functions.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/toggle-functions.mdx new file mode 100644 index 000000000..8cf815315 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/toggle-functions.mdx @@ -0,0 +1,52 @@ +--- +title: "toggleFunctions" +slug: /reference/php/agents/function-result/toggle-functions +description: Enable or disable specific SWAIG functions at runtime. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Enable or disable specific SWAIG functions at runtime. This lets you control +which tools are available to the AI at different points in the conversation +(e.g., enabling payment functions only after identity verification). + +## **Parameters** + + + List of toggle objects. Each object must contain: + - `"function"` — name of the SWAIG function to toggle + - `"active"` — `True` to enable, `False` to disable + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="enable_payment_functions", description="Enable payment tools") +function enablePaymentFunctions($args, $raw_data) +{ + return (; + new FunctionResult("Payment functions are now available.") + .toggleFunctions([ + ["function" => "collect_payment", "active": true], + ["function" => "refund_payment", "active": true], + ["function" => "check_balance", "active": false] + ]) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/update-global-data.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/update-global-data.mdx new file mode 100644 index 000000000..fcefbcb96 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/update-global-data.mdx @@ -0,0 +1,51 @@ +--- +title: "updateGlobalData" +slug: /reference/php/agents/function-result/update-global-data +description: Set or update key-value pairs in the global session data. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Set or update key-value pairs in the global session data. Global data persists +for the entire agent session and is accessible in prompt variable expansion +(`${global_data.key}`) and by all SWAIG functions. + +## **Parameters** + + + Dictionary of key-value pairs to merge into the global data store. Existing + keys are overwritten; new keys are added. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="save_customer_info", description="Save customer information") +function saveCustomerInfo($args, $raw_data) +{ + return (; + new FunctionResult("I've noted your information, {$args['name'] ?? null}.") + .updateGlobalData({ + "customer_id": args.$get("customer_id"), + "customer_name": args.$get("name"), + "verified": true + }) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/update-settings.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/update-settings.mdx new file mode 100644 index 000000000..a7b045597 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/update-settings.mdx @@ -0,0 +1,59 @@ +--- +title: "updateSettings" +slug: /reference/php/agents/function-result/update-settings +description: Update AI runtime settings dynamically during a call. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Update AI runtime settings dynamically during a call. Changes take effect +for subsequent LLM turns. + +## **Parameters** + + + Dictionary of settings to update. Supported keys: + + | Key | Type | Range | + |-----|------|-------| + | `frequency-penalty` | `float` | -2.0 to 2.0 | + | `presence-penalty` | `float` | -2.0 to 2.0 | + | `max-tokens` | `int` | 0 to 4096 | + | `top-p` | `float` | 0.0 to 1.0 | + | `confidence` | `float` | 0.0 to 1.0 | + | `barge-confidence` | `float` | 0.0 to 1.0 | + | `temperature` | `float` | 0.0 to 2.0 (clamped to 1.5) | + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Example** + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="adjust_for_technical_discussion", description="Adjust AI settings for technical topics") +function adjustForTechnicalDiscussion($args, $raw_data) +{ + return (; + new FunctionResult("Adjusting response parameters.") + .updateSettings({ + "temperature": 0.3, + "confidence": 0.9, + "barge-confidence": 0.8 + }) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/function-result/wait-for-user.mdx b/fern/products/sdks/pages/reference/php/agents/function-result/wait-for-user.mdx new file mode 100644 index 000000000..77a050a09 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/function-result/wait-for-user.mdx @@ -0,0 +1,82 @@ +--- +title: "waitForUser" +slug: /reference/php/agents/function-result/wait-for-user +description: Control how the agent pauses and waits for user input. +max-toc-depth: 3 +--- + +[functionresult]: /docs/sdks/reference/php/agents/function-result + +Control how the agent pauses and waits for the user to speak. The arguments +are evaluated in priority order: `answer_first` takes precedence, then +`timeout`, then `enabled`. If none are provided, waiting is enabled with no +timeout. + +## **Parameters** + + + Explicitly enable (`True`) or disable (`False`) waiting for user input. + + + + Number of seconds to wait for the user to speak before the agent continues. + + + + When `True`, activates the special `"answer_first"` mode. This answers the + call and waits for the user to speak before the agent begins its greeting. + + +## **Returns** + +[`FunctionResult`][functionresult] — self, for chaining. + +## **Examples** + +### Wait with Timeout + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="wait_for_confirmation", description="Wait for user confirmation") +function waitForConfirmation($args, $raw_data) +{ + return (; + new FunctionResult("Please respond when you're ready.") + .waitForUser(timeout: 30) + ); +} + +$agent->serve(); + + +``` + +### Disable Waiting + +```php {11} +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(name="disable_wait", description="Continue without waiting for input") +function disableWait($args, $raw_data) +{ + return (; + new FunctionResult("Continuing without waiting.") + .waitForUser(enabled: false) + ); +} + +$agent->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/helpers.mdx b/fern/products/sdks/pages/reference/php/agents/helpers.mdx new file mode 100644 index 000000000..17c415b6a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/helpers.mdx @@ -0,0 +1,328 @@ +--- +title: "Helper Functions" +slug: /reference/php/agents/helpers +description: Top-level convenience functions for creating contexts, data map tools, and managing skills. +max-toc-depth: 3 +--- + +[context]: /docs/sdks/reference/php/agents/context-builder/context +[contextbuilder]: /docs/sdks/reference/php/agents/context-builder +[datamap]: /docs/sdks/reference/php/agents/data-map +[skillbase]: /docs/sdks/reference/php/agents/skill-base +[ref-functionresult]: /docs/sdks/reference/php/agents/function-result + +The SignalWire SDK exports several helper functions at the top level for common +tasks like creating simple contexts, building server-side API tools, and +managing the skill registry. All are imported directly from `signalwire`. + +```php + [`Context`][context] + +Create a standalone [`Context`][context] object +without needing a full [`ContextBuilder`][contextbuilder]. +Useful for quick single-context agents. + +#### Parameters + + + Context name. For single-context agents this must be `"default"`. + + +#### Returns + +[`Context`][context] -- A new Context +object ready for adding steps. + +#### Example + +```php +addStep("greet")->setText("Say hello to the caller."); +$ctx->addStep("help")->setText("Ask how you can help today."); + + +``` + +--- + +## create_simple_api_tool + +**create_simple_api_tool**(`name`, `url`, `response_template`, `parameters=null`, `method="GET"`, `headers=null`, `body=null`, `errorKeys=null`) -> [`DataMap`][datamap] + +Create a server-side API tool with minimal configuration. Returns a configured +[`DataMap`][datamap] that executes an HTTP +request on the SignalWire server without requiring a webhook endpoint. + +#### Parameters + + + Function name for the SWAIG tool. + + + + API endpoint URL. Supports `${variable}` substitution for injecting parameter + values (e.g., `"https://api.example.com/search?q=${args.query}"`). + + + + Template string for formatting the API response. Uses `${response.field}` + syntax to reference fields from the API response JSON. + + + + Parameter definitions. Each key is a parameter name, and each value is a + dictionary with `type`, `description`, and optionally `required`. + + + + HTTP method for the API call. + + + + Optional HTTP headers to include in the request. + + + + Optional request body for POST/PUT requests. + + + + JSON keys whose presence in the response indicates an error. + + +#### Returns + +[`DataMap`][datamap] -- A configured DataMap +ready to be added to an agent. + +#### Example + +```php + +For more complex API integrations with multiple webhooks, fallback outputs, or +array processing, use the [`DataMap`][datamap] +builder directly. + + +--- + +## create_expression_tool + +**create_expression_tool**(`name`, `patterns`, `parameters=null`) -> [`DataMap`][datamap] + +Create a pattern-matching tool that evaluates expressions locally on the +SignalWire server without making any HTTP requests. Useful for command routing +and conditional responses. + +#### Parameters + + + Function name for the SWAIG tool. + + + + Dictionary mapping test values to `(pattern, [FunctionResult][ref-functionresult])` tuples. The test + value is a template string (e.g., `"${args.command}"`), and the pattern is a + regex string matched against it. + + + + Parameter definitions, same format as `createSimpleApiTool`. + + +#### Returns + +[`DataMap`][datamap] -- A configured DataMap +with expression-based routing. + +#### Example + +```php +addAction("start_playbook", ["file" => "${args.filename]"}) + ), + "${args.command}": ( + $r"stop.*", + new FunctionResult()->addAction("stop_playback", true) + ), + }, + parameters: { + "command": ["type" => "string", "description": "Playback command", "required": true], + "filename": ["type" => "string", "description": "File to play"], + } +); + + +``` + + +Since dictionary keys must be unique, use separate `DataMap.expression()` calls +via the [`DataMap`][datamap] builder if you +need multiple patterns against the same test value. + + +--- + +## list_skills_with_params + +**list_skills_with_params**() -> `dict[string, dict[string, mixed]]` + +Return a comprehensive schema for all available skills, including metadata and +parameter definitions. Useful for GUI configuration tools, API documentation, +or programmatic skill discovery. + +#### Returns + +`dict[string, dict[string, mixed]]` -- Dictionary keyed by skill name. Each value +contains the skill's metadata and a `parameters` dictionary describing each +configurable parameter with its `type`, `description`, `required` status, +`hidden` flag, and `env_var` name. + +#### Example + +```php + $skill_info) { + echo "{$skill_name}: {$skill_info['description'] ?? ''}"; + foreach ($skill_info["parameters"] ?? {} as param: > $meta) { + echo " {$param}: {$meta['type']} (required: {$meta['required'] ?? false})"; + } +} + + +``` + +--- + +## register_skill + +**register_skill**(`skill_class`) -> `null` + +Register a custom skill class with the global skill registry. This allows +third-party code to make skills available without placing them in a specific +directory structure. + +#### Parameters + + + A class that inherits from + [`SkillBase`][skillbase]. Must define + `SKILL_NAME` and `SKILL_DESCRIPTION` class attributes. + + +#### Example + +```php +defineTool(name: "get_weather", handler: self.$_get_weather, description: "Get weather"); +} + + public function GetWeather($args, $raw_data) + { + return ["response" => "Sunny, 72F"]; +} + +$register_skill($MyWeatherSkill); + +$agent = new AgentBase(); +$agent->addSkill("my_weather"); + + +``` + +--- + +## add_skill_directory + +**add_skill_directory**(`path`) -> `null` + +Add a directory to the skill search path. Skills in this directory should follow +the same structure as built-in skills (each skill in its own subdirectory with +an `__init__.py` exporting a `SkillBase` subclass). + +#### Parameters + + + Path to a directory containing skill subdirectories. + + +#### Example + +```php +addSkill("my_custom_skill") # $Found $in /$opt/$custom_skills/$my_custom_skill/; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent-server/index.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent-server/index.mdx new file mode 100644 index 000000000..90e354e3a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent-server/index.mdx @@ -0,0 +1,58 @@ +--- +title: "AgentServer" +slug: /reference/php/agents/livewire/agent-server +description: "Server registration and session entrypoint decorator for LiveWire agents." +max-toc-depth: 3 +--- + +[run-app]: /docs/sdks/reference/php/agents/livewire/run-app +[agentserver]: /docs/sdks/reference/php/agents/agent-server +[jobprocess]: /docs/sdks/reference/php/agents/livewire/job-context +[rtcsession]: /docs/sdks/reference/php/agents/livewire/agent-server/rtc-session + +`AgentServer` mirrors a LiveKit `AgentServer` (or `WorkerOptions`). It registers +a session entrypoint and an optional setup function, then is passed to +[`run_app()`][run-app] to start the agent. + + +This is the **LiveWire** `AgentServer`, not the SignalWire +[`AgentServer`][agentserver] used for multi-agent +hosting. The LiveWire version provides LiveKit-compatible registration methods; under +the hood it creates a single-agent SignalWire deployment. + + +```php {3} + + A setup function called before the entrypoint. Receives a + [`JobProcess`][jobprocess] instance. + Assign directly to register. + + +## **Methods** + + + + Decorator that registers the session entrypoint function. + + diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent-server/rtc-session.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent-server/rtc-session.mdx new file mode 100644 index 000000000..87e1acaee --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent-server/rtc-session.mdx @@ -0,0 +1,82 @@ +--- +title: "rtcSession" +slug: /reference/php/agents/livewire/agent-server/rtc-session +description: Decorator that registers the session entrypoint function. +max-toc-depth: 3 +--- + +[jobcontext]: /docs/sdks/reference/php/agents/livewire/job-context +[agent]: /docs/sdks/reference/php/agents/livewire/agent +[agentsession]: /docs/sdks/reference/php/agents/livewire/agent-session + +Decorator that registers the session entrypoint function. The entrypoint receives +a [`JobContext`][jobcontext] and is +responsible for creating an +[`Agent`][agent], +[`AgentSession`][agentsession], and +calling `session.start()`. + +## **Parameters** + + + The entrypoint function. When used as `@server.rtc_session()` with parentheses, + `func` is `null` and the decorator returns a wrapper. When used as + `@server.rtc_session` without parentheses, the function is passed directly. + + + + A name for the agent. Stored on the server for identification. + + + + Session type. Only `"room"` is supported on SignalWire. Other values are accepted + for API compatibility but log an informational message. + + + + Callback for incoming requests. Accepted for API compatibility. + + + + Callback for session end. Accepted for API compatibility. + + +## **Returns** + +`callable` -- The decorated function, unmodified. + +## **Example** + +```php {17} +userdata["api_key"] = "sk-..."; +} + +$server->setup_fnc = $setup; + +// @server.rtc_session(agent_name="support-bot") +function entrypoint(JobContext $ctx) +{ + $ctx->connect(); + $agent = $Agent(instructions: "You are a support bot."); + $session = $AgentSession(); + $session->start($agent, room: ctx.$room); +} + +$run_app($server); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/generate-reply.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/generate-reply.mdx new file mode 100644 index 000000000..64ce9ec41 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/generate-reply.mdx @@ -0,0 +1,47 @@ +--- +title: "generateReply" +slug: /reference/php/agents/livewire/agent-session/generate-reply +description: Trigger the agent to generate a reply. +max-toc-depth: 3 +--- + +Trigger the agent to generate a reply. On SignalWire the prompt handles +generation automatically; when `instructions` is provided, it is queued as +additional text to speak. + +## **Parameters** + + + Optional instructions to include in the reply. + + +## **Returns** + +`null` + +## **Example** + +```php {11} +connect(); + $agent = $Agent(instructions: "You are a helpful assistant."); + $session = $AgentSession(); + $session->start($agent, room: ctx.$room); + $session->generate_reply(instructions: "Please introduce yourself to the caller."); +} + +$run_app($server); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/index.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/index.mdx new file mode 100644 index 000000000..6f79d09fc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/index.mdx @@ -0,0 +1,67 @@ +--- +title: "AgentSession" +slug: /reference/php/agents/livewire/agent-session +description: "Session orchestrator that binds an Agent to the SignalWire platform." +max-toc-depth: 3 +--- + +[agent]: /docs/sdks/reference/php/agents/livewire/agent +[agentbase]: /docs/sdks/reference/php/agents/agent-base +[runcontext-userdata]: /docs/sdks/reference/php/agents/livewire/run-context +[functiontool]: /docs/sdks/reference/php/agents/livewire/function-tool +[start]: /docs/sdks/reference/php/agents/livewire/agent-session/start +[say]: /docs/sdks/reference/php/agents/livewire/agent-session/say +[generatereply]: /docs/sdks/reference/php/agents/livewire/agent-session/generate-reply +[interrupt]: /docs/sdks/reference/php/agents/livewire/agent-session/interrupt +[updateagent]: /docs/sdks/reference/php/agents/livewire/agent-session/update-agent + +`AgentSession` is the orchestrator that binds an +[`Agent`][agent] to the SignalWire platform. +When `start()` is called, it translates the LiveWire agent definition into a SignalWire +[`AgentBase`][agentbase] instance, mapping +instructions to prompts, tools to SWAIG functions, and timing parameters to +SignalWire AI parameters. + +```php {4} +start($agent); + + +``` + +## **Properties** + + + Arbitrary data attached to the session. Accessible from tool handlers via + [`RunContext.userdata`][runcontext-userdata]. + Defaults to an empty dict. + + + + Conversation history as a list of `{"role": ..., "content": ...}` dicts. + + +## **Methods** + + + + Bind an Agent and prepare the underlying SignalWire AgentBase. + + + Queue text to be spoken by the agent. + + + Trigger the agent to generate a reply. + + + No-op. SignalWire handles barge-in automatically. + + + Swap in a new Agent mid-session. + + diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/interrupt.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/interrupt.mdx new file mode 100644 index 000000000..249d0047c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/interrupt.mdx @@ -0,0 +1,47 @@ +--- +title: "interrupt" +slug: /reference/php/agents/livewire/agent-session/interrupt +description: No-op. SignalWire handles barge-in automatically via its control plane. +max-toc-depth: 3 +--- + +No-op. SignalWire handles barge-in automatically via its control plane. + +This method exists for API compatibility with LiveKit's `AgentSession.interrupt()`. +On SignalWire, barge-in is managed automatically by the platform based on the +`allow_interruptions` setting. + +## **Parameters** + +None. + +## **Returns** + +`null` + +## **Example** + +```php {11} +connect(); + $agent = $Agent(instructions: "You are a helpful assistant."); + $session = $AgentSession(allow_interruptions: true); + $session->start($agent, room: ctx.$room); + $session->interrupt() # $No-$op $on $SignalWire; +} + +$run_app($server); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/say.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/say.mdx new file mode 100644 index 000000000..30f819d3b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/say.mdx @@ -0,0 +1,47 @@ +--- +title: "say" +slug: /reference/php/agents/livewire/agent-session/say +description: Queue text to be spoken by the agent. +max-toc-depth: 3 +--- + +Queue text to be spoken by the agent. Text queued before `start()` is used as +an initial greeting in the generated SWML document. Text queued after `start()` +is spoken as soon as the agent is ready. + +## **Parameters** + + + The text for the agent to speak. + + +## **Returns** + +`null` + +## **Example** + +```php {11} +connect(); + $agent = $Agent(instructions: "You are a friendly receptionist."); + $session = $AgentSession(); + $session->start($agent, room: ctx.$room); + $session->say("Welcome! How can I help you today?"); +} + +$run_app($server); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/start.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/start.mdx new file mode 100644 index 000000000..c5d4c4098 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/start.mdx @@ -0,0 +1,68 @@ +--- +title: "start" +slug: /reference/php/agents/livewire/agent-session/start +description: Bind an Agent and prepare the underlying SignalWire AgentBase. +max-toc-depth: 3 +--- + +[agent]: /docs/sdks/reference/php/agents/livewire/agent +[room]: /docs/sdks/reference/php/agents/livewire/job-context + +Bind an [`Agent`][agent] to this session +and prepare the underlying SignalWire infrastructure. This translates the agent's +instructions into a prompt, registers tools as SWAIG functions, and maps timing +parameters to SignalWire AI parameters. + +## **Parameters** + + + The [`Agent`][agent] instance to bind + to this session. + + + + A [`Room`][room] instance. + Accepted for API compatibility. + + + + Whether to record the session. Accepted for API compatibility. + + +## **Returns** + +`null` + +## **Example** + +```php {15} +connect(); + $agent = $Agent(instructions: "You help with weather.", tools: [$get_weather]); + $session = $AgentSession(); + $session->start($agent, room: ctx.$room); +} + +$run_app($server); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/update-agent.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/update-agent.mdx new file mode 100644 index 000000000..a21a68090 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent-session/update-agent.mdx @@ -0,0 +1,65 @@ +--- +title: "updateAgent" +slug: /reference/php/agents/livewire/agent-session/update-agent +description: Swap in a new Agent mid-session. +max-toc-depth: 3 +--- + +[agent]: /docs/sdks/reference/php/agents/livewire/agent + +Swap in a new [`Agent`][agent] mid-session. +The new agent's instructions and tools replace the previous agent's configuration +on the underlying SignalWire platform. + +## **Parameters** + + + The new [`Agent`][agent] to bind to this session. + + +## **Returns** + +`null` + +## **Example** + +```php {22} +50."; +} + +// @function_tool +function transferFunds(string $from_acct, string $to_acct, float $amount): string +{ + """Transfer funds between accounts.""" + return "Transferred ${$amount} from {$from_acct} to {$to_acct}."; +} + +$server = new AgentServer(); + +// @server.rtc_session() +function entrypoint(JobContext $ctx) +{ + $ctx->connect(); + $basic_agent = $Agent(instructions: "You help check balances.", tools: [$check_balance]); + $session = $AgentSession(); + $session->start($basic_agent, room: ctx.$room); + $advanced_agent = $Agent(instructions: "You handle transfers.", tools: [$transfer_funds]); + $session->update_agent($advanced_agent); +} + +$run_app($server); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent/index.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent/index.mdx new file mode 100644 index 000000000..c474b54e9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent/index.mdx @@ -0,0 +1,76 @@ +--- +title: "Agent" +slug: /reference/php/agents/livewire/agent +description: "LiveKit-compatible agent class that holds instructions, tools, and lifecycle hooks." +max-toc-depth: 3 +--- + +[agentsession]: /docs/sdks/reference/php/agents/livewire/agent-session +[agentbase]: /docs/sdks/reference/php/agents/agent-base +[functiontool]: /docs/sdks/reference/php/agents/livewire/function-tool +[onenter]: /docs/sdks/reference/php/agents/livewire/agent/on-enter +[onexit]: /docs/sdks/reference/php/agents/livewire/agent/on-exit +[onuserturncompleted]: /docs/sdks/reference/php/agents/livewire/agent/on-user-turn-completed +[updateinstructions]: /docs/sdks/reference/php/agents/livewire/agent/update-instructions +[updatetools]: /docs/sdks/reference/php/agents/livewire/agent/update-tools +[pipeline-nodes]: /docs/sdks/reference/php/agents/livewire/agent/pipeline-nodes + +The `Agent` class mirrors a LiveKit agent. It holds the system prompt (instructions), +a list of tools, and optional lifecycle hooks. When bound to an +[`AgentSession`][agentsession], the session +translates this into a SignalWire +[`AgentBase`][agentbase] under the hood. + +```php {8} + + The system prompt text for the agent. + + + + The [`AgentSession`][agentsession] this + agent is bound to. Set automatically when `session.start(agent)` is called. + + +## **Methods** + + + + Lifecycle hook called when the agent enters. + + + Lifecycle hook called when the agent exits. + + + Lifecycle hook called when the user finishes speaking. + + + Update the agent's system prompt mid-session. + + + Replace the agent's tool list mid-session. + + + No-op pipeline stubs: stt_node, llm_node, tts_node. + + diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent/on-enter.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent/on-enter.mdx new file mode 100644 index 000000000..5edca53a6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent/on-enter.mdx @@ -0,0 +1,54 @@ +--- +title: "onEnter" +slug: /reference/php/agents/livewire/agent/on-enter +description: Lifecycle hook called when the agent enters a session. +max-toc-depth: 3 +--- + +[agentsession]: /docs/sdks/reference/php/agents/livewire/agent-session + +Lifecycle hook called when the agent enters a session. Override in a subclass to +run custom initialization logic when the agent is first bound to an +[`AgentSession`][agentsession]. + +## **Parameters** + +None. + +## **Returns** + +`null` + +## **Example** + +```php {6} +say("Welcome! I just started up."); + } + +// @server.rtc_session() +function entrypoint(JobContext $ctx) +{ + $ctx->connect(); + $agent = $GreeterAgent(instructions: "You are a friendly greeter."); + $session = $AgentSession(); + $session->start($agent, room: ctx.$room); +} + +$run_app($server); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent/on-exit.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent/on-exit.mdx new file mode 100644 index 000000000..82b2ac722 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent/on-exit.mdx @@ -0,0 +1,50 @@ +--- +title: "onExit" +slug: /reference/php/agents/livewire/agent/on-exit +description: Lifecycle hook called when the agent exits a session. +max-toc-depth: 3 +--- + +Lifecycle hook called when the agent exits a session. Override in a subclass to +run cleanup logic when the agent's session ends. + +## **Parameters** + +None. + +## **Returns** + +`null` + +## **Example** + +```php {6} +connect(); + $agent = $TrackedAgent(instructions: "You are a helpful assistant."); + $session = $AgentSession(); + $session->start($agent, room: ctx.$room); +} + +$run_app($server); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent/on-user-turn-completed.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent/on-user-turn-completed.mdx new file mode 100644 index 000000000..02cebd4ae --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent/on-user-turn-completed.mdx @@ -0,0 +1,57 @@ +--- +title: "onUserTurnCompleted" +slug: /reference/php/agents/livewire/agent/on-user-turn-completed +description: Lifecycle hook called when the user finishes speaking. +max-toc-depth: 3 +--- + +Lifecycle hook called when the user finishes speaking. Override in a subclass to +inspect or modify the conversation before the LLM generates a reply. + +## **Parameters** + + + Turn context object. Accepted for API compatibility. + + + + The new message from the user. Accepted for API compatibility. + + +## **Returns** + +`null` + +## **Example** + +```php {6} +session.history}"; + } + +// @server.rtc_session() +function entrypoint(JobContext $ctx) +{ + $ctx->connect(); + $agent = $LoggingAgent(instructions: "You are a helpful assistant."); + $session = $AgentSession(); + $session->start($agent, room: ctx.$room); +} + +$run_app($server); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent/pipeline-nodes.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent/pipeline-nodes.mdx new file mode 100644 index 000000000..8869e932d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent/pipeline-nodes.mdx @@ -0,0 +1,96 @@ +--- +title: "Pipeline Nodes" +slug: /reference/php/agents/livewire/agent/pipeline-nodes +description: No-op pipeline stubs for LiveKit API compatibility. +max-toc-depth: 3 +--- + +These methods exist for API compatibility with LiveKit's pipeline architecture. +On SignalWire they are no-ops because the control plane handles the full +STT/LLM/TTS pipeline automatically. + + +All three pipeline node methods are no-ops on SignalWire. They are provided solely +so that code written for LiveKit's pipeline architecture does not raise errors when +run on SignalWire via LiveWire. + + +## **stt_node** + +```php +stt_node(audio: null, model_settings: null); + + +``` + +No-op. SignalWire handles speech recognition in its control plane. + + + Audio input. Accepted for API compatibility. + + + + STT model settings. Accepted for API compatibility. + + +**Returns:** `null` + +--- + +## **llm_node** + +```php +llm_node(chat_ctx: null, tools: null, model_settings: null); + + +``` + +No-op. SignalWire handles LLM inference in its control plane. + + + Chat context. Accepted for API compatibility. + + + + Tool list. Accepted for API compatibility. + + + + LLM model settings. Accepted for API compatibility. + + +**Returns:** `null` + +--- + +## **tts_node** + +```php +tts_node(text: null, model_settings: null); + + +``` + +No-op. SignalWire handles text-to-speech in its control plane. + + + Text to synthesize. Accepted for API compatibility. + + + + TTS model settings. Accepted for API compatibility. + + +**Returns:** `null` diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent/update-instructions.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent/update-instructions.mdx new file mode 100644 index 000000000..b2408f2b9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent/update-instructions.mdx @@ -0,0 +1,57 @@ +--- +title: "updateInstructions" +slug: /reference/php/agents/livewire/agent/update-instructions +description: Update the agent's system prompt mid-session. +max-toc-depth: 3 +--- + +Update the agent's system prompt mid-session. The new instructions take effect +immediately for subsequent LLM turns. + +## **Parameters** + + + The new system prompt text. + + +## **Returns** + +`null` + +## **Example** + +```php {18} +connect(); + $agent = $Agent( + instructions: "You are a junior support agent. Help with basic questions.", + tools: [$escalate], + ); + $session = $AgentSession(); + $agent->update_instructions("You are now a senior support agent. Handle complex issues."); + $session->start($agent, room: ctx.$room); +} + +$run_app($server); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/agent/update-tools.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/agent/update-tools.mdx new file mode 100644 index 000000000..b7a958db5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/agent/update-tools.mdx @@ -0,0 +1,55 @@ +--- +title: "updateTools" +slug: /reference/php/agents/livewire/agent/update-tools +description: Replace the agent's tool list mid-session. +max-toc-depth: 3 +--- + +[function-tool]: /docs/sdks/reference/php/agents/livewire/function-tool + +Replace the agent's tool list mid-session. The new tools take effect immediately, +replacing all previously registered tools on this agent. + +## **Parameters** + + + A new list of [`@function_tool`][function-tool]-decorated + functions. + + +## **Returns** + +`null` + +## **Example** + +```php {16} +update_tools([$farewell]); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/livewire/index.mdx b/fern/products/sdks/pages/reference/php/agents/livewire/index.mdx new file mode 100644 index 000000000..368bb9fe2 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/livewire/index.mdx @@ -0,0 +1,150 @@ +--- +title: "LiveWire" +sidebar-title: LiveWire +subtitle: "LiveKit-compatible agents powered by SignalWire infrastructure" +slug: /reference/php/agents/livewire +description: "LiveKit-compatible API layer that maps to SignalWire infrastructure." +max-toc-depth: 3 +--- + +[agent]: /docs/sdks/reference/php/agents/livewire/agent +[agent-session]: /docs/sdks/reference/php/agents/livewire/agent-session +[agent-server]: /docs/sdks/reference/php/agents/livewire/agent-server +[ref-agentsession]: /docs/sdks/reference/php/agents/livewire/agent-session + +LiveWire is a compatibility layer that lets developers familiar with +[livekit-agents](https://docs.livekit.io/agents/) use the same class and function +names while running on SignalWire infrastructure. Change your import path and your +existing code runs on SignalWire with no other modifications. + +```php +agents $import $Agent, $AgentSession, $function_tool; + +// After (SignalWire LiveWire) +use SignalWire\Livewire\Agent; +use SignalWire\Livewire\AgentSession; +use SignalWire\Livewire\function_tool; + +``` + + +SignalWire's control plane handles STT, TTS, VAD, and turn detection automatically. +Pipeline plugin parameters (`stt`, `tts`, `vad`, `turn_detection`) are accepted for +API compatibility but are no-ops. LiveWire logs an informational message the first +time each no-op parameter is used. + + +## Quick Start + +```php +start($agent, room: ctx.$room); +} + +$run_app($server); + +``` + +## Namespace Aliases + +LiveWire provides namespace objects that mirror common livekit-agents import paths: + +| Alias | Contents | Mirrors | +|-------|----------|---------| +| `voice` | `Agent`, [`AgentSession`][ref-agentsession] | `livekit.agents.voice` | +| `llm_ns` | `tool` (alias for `function_tool`), `ToolError`, `ChatContext` | `livekit.agents.llm` | +| `cli_ns` | `run_app` | `livekit.agents.cli` | +| `inference` | `STT`, `LLM`, `TTS` | `livekit.agents.inference` | + +```php +Agent(instructions: "Hello"); +$session = $voice->AgentSession(llm: inference.$LLM(model: "gpt-4o")); + +``` + +## **Learn More** + + + + LiveKit-compatible agent class. Holds instructions, tools, and lifecycle hooks. + + + Session orchestrator that binds an Agent to the SignalWire platform. + + + Context object available inside tool handler functions. + + + Decorator for wrapping plain PHP functions as agent tools. + + + Main entry point that prints the banner, runs setup, and starts the agent. + + + Server registration and session entrypoint decorator. + + + JobContext, JobProcess, and Room stubs for connection lifecycle. + + + StopResponse, ToolError, AgentHandoff, and ChatContext. + + + No-op plugin stubs: DeepgramSTT, OpenAILLM, CartesiaTTS, ElevenLabsTTS, SileroVAD, and Inference classes. + + diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/index.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/index.mdx new file mode 100644 index 000000000..187b4da7f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/index.mdx @@ -0,0 +1,63 @@ +--- +title: "MCP Gateway" +sidebar-title: MCP Gateway +slug: /reference/php/agents/mcp-gateway +description: Bridge MCP servers with SignalWire SWAIG functions via an HTTP gateway. +max-toc-depth: 3 +--- + +[mcp-gateway-cli-command]: /docs/sdks/reference/php/agents/cli/mcp-gateway +[mcp-gateway]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-gateway +[session-manager]: /docs/sdks/reference/php/agents/mcp-gateway/session-manager +[mcp-manager]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-manager + +The MCP Gateway module provides an HTTP/HTTPS server that bridges +[Model Context Protocol](https://modelcontextprotocol.io/) (MCP) servers with +SignalWire SWAIG functions. It manages sessions, handles authentication, and +translates between the MCP JSON-RPC protocol and SignalWire's tool-calling +interface. + +Use the MCP Gateway when you want to expose tools from one or more MCP servers +as SWAIG functions that a SignalWire AI agent can call during a conversation. + +```php +run(); + +``` + + +For the CLI entry point, see the +[`mcp-gateway` CLI command][mcp-gateway-cli-command]. + + +## **Learn More** + + + + The main gateway service class. Loads configuration, sets up routes, and runs the HTTP server. + + + Session and SessionManager classes for tracking MCP session lifecycles. + + + MCPService and MCPManager classes for spawning and managing MCP servers. + + + Client for communicating with a single MCP server subprocess via JSON-RPC. + + diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-gateway/index.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-gateway/index.mdx new file mode 100644 index 000000000..fb70ab2fd --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-gateway/index.mdx @@ -0,0 +1,93 @@ +--- +title: "MCPGateway" +slug: /reference/php/agents/mcp-gateway/mcp-gateway +description: The main HTTP gateway service bridging MCP servers with SignalWire SWAIG functions. +max-toc-depth: 3 +--- + +[mcpmanager]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-manager +[sessionmanager]: /docs/sdks/reference/php/agents/mcp-gateway/session-manager +[securityconfig]: /docs/sdks/reference/php/agents/configuration/security-config +[mcp-gateway-cli-command]: /docs/sdks/reference/php/agents/cli/mcp-gateway +[run]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-gateway/run +[shutdown]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-gateway/shutdown + +MCPGateway is the main service class for the MCP-SWAIG gateway. It loads +configuration from a JSON file, initializes an +[`MCPManager`][mcpmanager] and +[`SessionManager`][sessionmanager], +sets up authenticated HTTP routes, and runs a Flask server that translates +between MCP tool calls and SignalWire SWAIG requests. + +The gateway supports Basic auth and Bearer token authentication, rate limiting, +SSL/TLS, and automatic session cleanup. + +## **Properties** + + + The underlying Flask application instance. + + + + The loaded and environment-variable-substituted configuration dictionary. + + + + The [`MCPManager`][mcpmanager] instance + that manages MCP service definitions and client lifecycles. + + + + The [`SessionManager`][sessionmanager] instance + that tracks active MCP sessions. + + + + The [`SecurityConfig`][securityconfig] instance + for authentication and security headers. + + +## **HTTP Endpoints** + +The gateway exposes the following REST endpoints. All endpoints except `/health` +require authentication. + +| Endpoint | Method | Description | +|----------|--------|-------------| +| `/health` | GET | Health check (no auth required) | +| `/services` | GET | List available MCP services | +| `/services//tools` | GET | Get tools for a specific service | +| `/services//call` | POST | Call a tool on a service | +| `/sessions` | GET | List active sessions | +| `/sessions/` | DELETE | Close a specific session | + +## **`main` Function** + +```php + `null` + +CLI entry point that parses command-line arguments and starts the gateway. Accepts +a `-c` / `--config` flag to specify the configuration file path (defaults to +`config.json`). + + +Use the [`mcp-gateway` CLI command][mcp-gateway-cli-command] +to run the gateway from the command line without writing any Python code. + + +## **Methods** + + + + Start the gateway HTTP server, blocking until shutdown. + + + Gracefully shut down the gateway and all active sessions. + + diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-gateway/run.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-gateway/run.mdx new file mode 100644 index 000000000..58530193b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-gateway/run.mdx @@ -0,0 +1,36 @@ +--- +title: "run" +slug: /reference/php/agents/mcp-gateway/mcp-gateway/run +description: Start the MCP Gateway HTTP server. +max-toc-depth: 3 +--- + +Start the gateway HTTP server. Blocks until a shutdown signal is received. +Automatically detects an SSL certificate at `certs/server.pem` and enables HTTPS +if found. Registers `SIGTERM` and `SIGINT` signal handlers for graceful shutdown. + +Server host and port are read from the `server.host` and `server.port` keys in +the configuration file (defaults to `0.0.0.0:8080`). + +## **Parameters** + +None. + +## **Returns** + +`null` -- This method blocks and does not return until the server is stopped. + +## **Example** + +```php {4} +run(); +// Gateway is now listening on the configured host:port +// Use curl or any HTTP client to interact: +// curl -u admin:changeme http://localhost:8080/services + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-gateway/shutdown.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-gateway/shutdown.mdx new file mode 100644 index 000000000..879863afd --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-gateway/shutdown.mdx @@ -0,0 +1,44 @@ +--- +title: "shutdown" +slug: /reference/php/agents/mcp-gateway/mcp-gateway/shutdown +description: Gracefully shut down the MCP Gateway service. +max-toc-depth: 3 +--- + +[sessionmanager-shutdown]: /docs/sdks/reference/php/agents/mcp-gateway/session-manager/shutdown +[mcpmanager-shutdown]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-manager/shutdown +[run]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-gateway/run + +Gracefully shut down the gateway. Closes all active sessions via +[`SessionManager.shutdown()`][sessionmanager-shutdown], +stops all MCP clients via +[`MCPManager.shutdown()`][mcpmanager-shutdown], +and stops the HTTP server. Session and MCP manager shutdown run in parallel with +a 5-second timeout each. + +Called automatically when the server receives a `SIGTERM` or `SIGINT` signal +during [`run()`][run]. + +## **Parameters** + +None. + +## **Returns** + +`null` + +## **Example** + +```php {7} +Thread(target: gateway.$run); +$server_thread->start(); +$gateway->shutdown(); +$server_thread->join(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/create-client.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/create-client.mdx new file mode 100644 index 000000000..f96da0f3f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/create-client.mdx @@ -0,0 +1,45 @@ +--- +title: "createClient" +slug: /reference/php/agents/mcp-gateway/mcp-manager/create-client +description: Create and start a new MCP client for a service. +max-toc-depth: 3 +--- + +[mcpclient]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-client + +Create and start a new MCP client for the named service. The client spawns a +sandboxed subprocess, initializes the MCP session via JSON-RPC, and retrieves +the list of available tools. Raises `ValueError` if the service is unknown or +disabled, and `RuntimeError` if the MCP process fails to start. + +## **Parameters** + + + Name of the service to create a client for. Must match a key in the + `services` section of the configuration. + + +## **Returns** + +[`MCPClient`][mcpclient] -- A started MCP client connected to the service. + +## **Example** + +```php {10} + ["python3", "todo_mcp.py"], "description": "Todo list", "enabled": true] + } +} + +$manager = $MCPManager($config); +$client = $manager->create_client("todo"); +$tools = $client->get_tools(); +echo "Available tools: {$[t['name'] for t in tools]}"; +$client->stop(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/get-service-tools.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/get-service-tools.mdx new file mode 100644 index 000000000..6398944b5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/get-service-tools.mdx @@ -0,0 +1,41 @@ +--- +title: "getServiceTools" +slug: /reference/php/agents/mcp-gateway/mcp-manager/get-service-tools +description: Discover a service's available tools without maintaining a persistent session. +max-toc-depth: 3 +--- + +Start a temporary MCP client, retrieve the list of available tools, then stop +the client. Useful for discovering a service's capabilities without maintaining +a persistent session. + +## **Parameters** + + + Name of the service to query. + + +## **Returns** + +`list[dict[string, mixed]]` -- List of tool definition dictionaries from the MCP server. + +## **Example** + +```php {10} + ["python3", "todo_mcp.py"], "description": "Todo list", "enabled": true] + } +} + +$manager = $MCPManager($config); +$tools = $manager->get_service_tools("todo"); +foreach ($tools as $tool) { + echo " {$tool['name']}: {$tool['description'] ?? ''}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/index.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/index.mdx new file mode 100644 index 000000000..2efd050f3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/index.mdx @@ -0,0 +1,122 @@ +--- +title: "MCPService, MCPClient & MCPManager" +slug: /reference/php/agents/mcp-gateway/mcp-manager +description: Spawn, communicate with, and manage MCP server processes. +max-toc-depth: 3 +--- + +[mcpclient-reference]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-client +[createclient]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-manager/create-client +[getservicetools]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-manager/get-service-tools +[validateservices]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-manager/validate-services +[shutdown]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-manager/shutdown + +These classes handle the low-level lifecycle of MCP server processes: defining +service configurations, spawning sandboxed subprocesses, communicating over +JSON-RPC, and managing multiple services. + +```php + + Unique name identifying this MCP service. + + + + The command and arguments used to spawn the MCP server process (e.g., + `["python3", "my_server.py"]`). + + + + Human-readable description of what this service provides. + + + + Whether this service is enabled. Disabled services are skipped during loading. + + + + Sandbox configuration controlling process isolation. Defaults to: + ```php + true, "resource_limits": true, "restricted_env": true] + + +``` + + + + + Enable process sandboxing. When `False`, the MCP server runs with full + environment access. + + + + Apply CPU, memory, process count, and file size limits to the spawned process. + + + + Run with a minimal environment (PATH, HOME, TMPDIR only). When `False`, the + full parent environment is inherited. + + + + Drop to the `nobody` user when running as root. + + + + Working directory for the spawned process. Defaults to the current directory. + + + +--- + +## MCPManager + +Manages multiple MCP services and their client lifecycles. Loads service +definitions from the gateway configuration, creates clients on demand, and +handles bulk shutdown. + +### Properties + + + Dictionary mapping service names to their [`MCPService`](#mcpservice) definitions. + + +## **Methods** + + + + Create and start a new MCP client for a service. + + + Discover a service's available tools. + + + Validate that all configured services can start. + + + Stop all active MCP clients. + + + + +For the MCPClient class (created by `create_client()`), see the +[MCPClient reference][mcpclient-reference]. + diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/shutdown.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/shutdown.mdx new file mode 100644 index 000000000..de74405d1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/shutdown.mdx @@ -0,0 +1,42 @@ +--- +title: "shutdown" +slug: /reference/php/agents/mcp-gateway/mcp-manager/shutdown +description: Stop all active MCP clients. +max-toc-depth: 3 +--- + +[create-client]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-manager/create-client +[mcpgateway-shutdown]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-gateway/shutdown + +Stop all active MCP clients that were created via +[`create_client()`][create-client]. +Each client's subprocess is terminated and its sandbox directory cleaned up. +Called automatically during +[`MCPGateway.shutdown()`][mcpgateway-shutdown]. + +## **Parameters** + +None. + +## **Returns** + +`null` + +## **Example** + +```php {11} + ["python3", "todo_mcp.py"], "description": "Todo list", "enabled": true] + } +} + +$manager = $MCPManager($config); +$client = $manager->create_client("todo"); +$manager->shutdown(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/validate-services.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/validate-services.mdx new file mode 100644 index 000000000..a871377cb --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/mcp-manager/validate-services.mdx @@ -0,0 +1,45 @@ +--- +title: "validateServices" +slug: /reference/php/agents/mcp-gateway/mcp-manager/validate-services +description: Validate that all configured services can be started successfully. +max-toc-depth: 3 +--- + +[ref-mcpgateway]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-gateway + +Validate that all configured services can be started successfully. Starts and +immediately stops a client for each service. Returns a dictionary mapping +service names to their validation result (`True` = success). + +This method is called automatically during [MCPGateway][ref-mcpgateway] initialization. + +## **Parameters** + +None. + +## **Returns** + +`dict[string, bool]` -- A dictionary mapping each service name to `True` (valid) or `False` (failed). + +## **Example** + +```php {11} + ["python3", "todo_mcp.py"], "description": "Todo list", "enabled": true], + "search": ["command" => ["node", "search_mcp.js"], "description": "Search", "enabled": true] + } +} + +$manager = $MCPManager($config); +$results = $manager->validate_services(); +foreach ($results as service: > $valid) { + $status = "OK" if $valid else "FAILED"; + echo " {$service}: {$status}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/close-session.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/close-session.mdx new file mode 100644 index 000000000..8ab85eb54 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/close-session.mdx @@ -0,0 +1,38 @@ +--- +title: "closeSession" +slug: /reference/php/agents/mcp-gateway/session-manager/close-session +description: Close and remove a session. +max-toc-depth: 3 +--- + +Close and remove a session. Stops the underlying MCP client process. Returns +`True` if the session was found and closed, `False` if the session did not +exist. + +## **Parameters** + + + The session ID to close. + + +## **Returns** + +`bool` -- `True` if the session was found and closed, `False` otherwise. + +## **Example** + +```php {4} +close_session("call-abc-123"); +if ($closed) { + echo "Session closed successfully"; +} +} else { + echo "Session !found"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/create-session.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/create-session.mdx new file mode 100644 index 000000000..eca44e839 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/create-session.mdx @@ -0,0 +1,65 @@ +--- +title: "createSession" +slug: /reference/php/agents/mcp-gateway/session-manager/create-session +description: Create and register a new MCP session. +max-toc-depth: 3 +--- + +[session]: /docs/sdks/reference/php/agents/mcp-gateway/session-manager + +Create and register a new session. If a session with the same ID already exists, +the old session is closed first. Raises `RuntimeError` if the total session limit +or the per-service session limit is exceeded. + +## **Parameters** + + + Unique session identifier, typically a SignalWire call ID. + + + + Name of the MCP service for this session. + + + + The MCP client process to associate with this session. + + + + Session timeout in seconds. Defaults to the manager's `default_timeout` (300). + + + + Arbitrary metadata to attach to the session. + + +## **Returns** + +[`Session`][session] -- The newly created session object. + +## **Example** + +```php {11} + 300, "max_sessions_per_service": 100], + "services": ["todo" => {"command": ["python3", "todo_mcp.py"], "description": "Todo", "enabled": true]} +} + +$manager = $SessionManager($config); +$mcp = $MCPManager($config); +$client = $mcp->create_client("todo"); +$session = $manager->create_session( + session_id: "call-abc-123", + service_name: "todo", + process: $client, + timeout: 600, + metadata: ["caller" => "+15551234567"] +); +echo $session->session_id; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/get-session.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/get-session.mdx new file mode 100644 index 000000000..23e6f656c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/get-session.mdx @@ -0,0 +1,40 @@ +--- +title: "getSession" +slug: /reference/php/agents/mcp-gateway/session-manager/get-session +description: Retrieve an active session by ID. +max-toc-depth: 3 +--- + +[session]: /docs/sdks/reference/php/agents/mcp-gateway/session-manager + +Retrieve an active session by ID. Returns `null` if the session does not exist, +has expired, or if its underlying process has died. Automatically calls +`touch()` on the session to reset its expiration timer. + +## **Parameters** + + + The session ID to look up. + + +## **Returns** + +[`Session`][session] or `null` + +## **Example** + +```php {4} +get_session("call-abc-123"); +if ($session) { + echo "Session active for service: {$session->service_name}"; +} +} else { + echo "Session !found or expired"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/index.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/index.mdx new file mode 100644 index 000000000..8447aa81c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/index.mdx @@ -0,0 +1,115 @@ +--- +title: "Session & SessionManager" +slug: /reference/php/agents/mcp-gateway/session-manager +description: Manage MCP session lifecycles with automatic timeout and cleanup. +max-toc-depth: 3 +--- + +[mcpclient]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-client +[sessionmanager-createsession]: /docs/sdks/reference/php/agents/mcp-gateway/session-manager/create-session +[getsession]: /docs/sdks/reference/php/agents/mcp-gateway/session-manager/get-session +[createsession]: /docs/sdks/reference/php/agents/mcp-gateway/session-manager/create-session +[closesession]: /docs/sdks/reference/php/agents/mcp-gateway/session-manager/close-session +[listsessions]: /docs/sdks/reference/php/agents/mcp-gateway/session-manager/list-sessions +[shutdown]: /docs/sdks/reference/php/agents/mcp-gateway/session-manager/shutdown + +The session management layer tracks active MCP sessions tied to SignalWire call +IDs. Each session wraps an [`MCPClient`][mcpclient] +process and is automatically cleaned up when it expires or when the underlying +process dies. + +```php + + Unique identifier for the session, typically a SignalWire call ID. + + + + Name of the MCP service this session is connected to. + + + + The [`MCPClient`][mcpclient] instance + managing the MCP server process for this session. + + + + Timestamp when the session was created. + + + + Timestamp of the most recent activity on this session. Updated automatically + when the session is retrieved via + [`get_session()`][getsession]. + + + + Session timeout in seconds. The session is considered expired when + `last_accessed + timeout` is in the past. + + + + Arbitrary metadata attached to the session. + + + + Read-only property. Returns `True` if the session has exceeded its timeout + since the last access. + + + + Read-only property. Returns `True` if the underlying MCP client process is + still running. + + +### touch + +**touch**() -> `null` + +Update `last_accessed` to the current time, resetting the expiration clock. +Called automatically by +[`get_session()`][getsession]. + +--- + +## SessionManager + +Manages the full lifecycle of MCP sessions including creation, retrieval, +cleanup, and resource limits. Runs a background thread that periodically +removes expired or dead sessions. + +## **Methods** + + + + Create and register a new MCP session. + + + Retrieve an active session by ID. + + + Close and remove a session. + + + List all active sessions with metadata. + + + Close all sessions and stop the cleanup thread. + + diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/list-sessions.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/list-sessions.mdx new file mode 100644 index 000000000..0bd0b710b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/list-sessions.mdx @@ -0,0 +1,34 @@ +--- +title: "listSessions" +slug: /reference/php/agents/mcp-gateway/session-manager/list-sessions +description: List all active sessions with their metadata. +max-toc-depth: 3 +--- + +List all active sessions with their metadata. Expired and dead sessions are +automatically cleaned up during this call. Returns a dictionary keyed by +session ID, where each value contains `service_name`, `created_at`, +`last_accessed`, `timeout`, `metadata`, and `time_remaining`. + +## **Parameters** + +None. + +## **Returns** + +`dict[string, dict[string, mixed]]` -- A dictionary mapping session IDs to session info dictionaries. + +## **Example** + +```php {4} +list_sessions(); +foreach ($sessions as session_id: > $info) { + echo "{$session_id}: {$info['service_name']} ({$info['time_remaining']:.0f}s remaining)"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/shutdown.mdx b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/shutdown.mdx new file mode 100644 index 000000000..ab2c6b904 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/mcp-gateway/session-manager/shutdown.mdx @@ -0,0 +1,34 @@ +--- +title: "shutdown" +slug: /reference/php/agents/mcp-gateway/session-manager/shutdown +description: Close all sessions and stop the background cleanup thread. +max-toc-depth: 3 +--- + +[mcpgateway-shutdown]: /docs/sdks/reference/php/agents/mcp-gateway/mcp-gateway/shutdown + +Close all active sessions and stop the background cleanup thread. Each session's +underlying MCP client process is stopped. Called automatically during +[`MCPGateway.shutdown()`][mcpgateway-shutdown]. + +## **Parameters** + +None. + +## **Returns** + +`null` + +## **Example** + +```php {6} + {"default_timeout": 300]}; +$manager = $SessionManager($config); +// ... create and use sessions ... +$manager->shutdown(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/overview.mdx b/fern/products/sdks/pages/reference/php/agents/overview.mdx new file mode 100644 index 000000000..27461934c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/overview.mdx @@ -0,0 +1,202 @@ +--- +title: "Agents" +sidebar-title: Overview +subtitle: "PHP API reference for AgentBase, SWMLService, SWAIG functions, skills, contexts, LiveWire, search, and more" +slug: /reference/php/agents +description: "Core framework for building AI-powered voice agents." +max-toc-depth: 3 +position: 0 +--- + +[swml]: /docs/swml/reference/ai +[agent-base]: /docs/sdks/reference/php/agents/agent-base +[swml-service]: /docs/sdks/reference/php/agents/swml-service +[swml-builder]: /docs/sdks/reference/php/agents/swml-builder +[swaig-function]: /docs/sdks/reference/php/agents/swaig-function +[function-result]: /docs/sdks/reference/php/agents/function-result +[context-builder]: /docs/sdks/reference/php/agents/context-builder +[data-map]: /docs/sdks/reference/php/agents/data-map +[skill-base]: /docs/sdks/reference/php/agents/skill-base +[pom-builder]: /docs/sdks/reference/php/agents/pom-builder +[agent-server]: /docs/sdks/reference/php/agents/agent-server +[bedrock-agent]: /docs/sdks/reference/php/agents/bedrock-agent +[prefabs]: /docs/sdks/reference/php/agents/prefabs +[skills]: /docs/sdks/reference/php/agents/skills +[cli]: /docs/sdks/reference/php/agents/cli +[configuration]: /docs/sdks/reference/php/agents/configuration +[livewire]: /docs/sdks/reference/php/agents/livewire +[search]: /docs/sdks/reference/php/agents/search +[mcp-gateway]: /docs/sdks/reference/php/agents/mcp-gateway +[web-service]: /docs/sdks/reference/php/agents/web-service +[helpers]: /docs/sdks/reference/php/agents/helpers +[ref-agentbase]: /docs/sdks/reference/php/agents/agent-base + +The Agents namespace provides the core framework for building AI-powered voice +agents with SignalWire. It includes the central [`AgentBase`][ref-agentbase] class, SWML document +generation, tool/function definitions, skills, multi-agent hosting, CLI tools +for local testing and deployment, and configuration management for security +and environment settings. + + +The Agents SDK generates [SWML][swml] documents under the hood. +Each agent produces a SWML document with the `ai` verb that the SignalWire platform executes. + + +## Example + +A complete agent that answers calls, uses an AI prompt, and exposes a custom tool: + +```php +setPromptText( + "You are a friendly support agent for Acme Corp. " . + "Help customers check their order status. " . + "Be concise and professional." +); +$agent->setParams(["temperature" => 0.5, "end_of_speech_timeout" => 800]); + +$agent->defineTool( + 'check_order', + 'Look up an order by ID', + ['order_id' => ['type' => 'string', 'description' => 'The order ID']], + function (array $args, array $rawData) { + $orderId = $args['order_id'] ?? 'unknown'; + $result = new FunctionResult(); + $result->setResponse("Order {$orderId} shipped on March 28 and arrives tomorrow."); + return $result; + } +); + +$agent->addSkill("datetime"); + +$agent->serve(); +``` + +## Classes + + + + The central class for building AI agents. Manages prompts, tools, skills, and serving. + + + SWML document generation and FastAPI service base class. + + + Fluent builder for constructing SWML documents programmatically. + + + Wraps PHP functions as callable SWAIG tools with validation and metadata. + + + Fluent interface for returning actions and responses from tool functions. + + + Multi-step agent workflows with context and step navigation. + + + Server-side API tools that execute REST calls without agent webhooks. + + + Base class for building reusable skill plugins. + + + Prompt Object Model builder for structured prompt composition. + + + Host multiple agents on a single FastAPI process with route-based dispatch. + + + Amazon Bedrock voice-to-voice agent extending AgentBase. + + + Pre-built agent templates for common conversational patterns. + + + Built-in skills catalog with 17 pluggable capabilities. + + + Command-line tools for testing, searching, scaffolding, and deployment. + + + Environment variables, config files, security settings, and authentication. + + + LiveKit-compatible API layer — use familiar livekit-agents classes on SignalWire infrastructure. + + + Vector search engine for building knowledge bases with document processing and indexing. + + + Model Context Protocol bridge connecting MCP servers to SWAIG functions. + + + Static file serving with security, CORS, and SSL support. + + + Convenience functions for creating contexts, API tools, and managing skills. + + diff --git a/fern/products/sdks/pages/reference/php/agents/pom-builder/add-section.mdx b/fern/products/sdks/pages/reference/php/agents/pom-builder/add-section.mdx new file mode 100644 index 000000000..05c142918 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/pom-builder/add-section.mdx @@ -0,0 +1,83 @@ +--- +title: "addSection" +slug: /reference/php/agents/pom-builder/add-section +description: Add a new top-level section to the POM. +max-toc-depth: 3 +--- + +[ref-pombuilder]: /docs/sdks/reference/php/agents/pom-builder + +Add a new top-level section to the POM. + +## **Parameters** + + + Section title. + + + + Section body text. + + + + List of bullet points for this section. + + + + Whether to number this section in the rendered output. + + + + Whether to number bullet points instead of using bullet markers. + + + + List of subsection objects, each with `"title"`, optional `"body"`, and + optional `"bullets"` keys. + + +## **Returns** + +[`PomBuilder`][ref-pombuilder] -- Self for method chaining. + +## **Example** + +```php {5,10,19} +addSection( + "Role", + body: "You are a customer service representative for Acme Corp." +); + +$pom->addSection( + "Guidelines", + bullets: [ + "Always greet the customer by name when available", + "Be concise and professional", + "Never make promises about timelines you cannot keep" + ] +); + +$pom->addSection( + "Product Knowledge", + body: "You have access to the product catalog.", + subsections: [ + { + "title": "Pricing", + "body": "Always quote current prices from the catalog." + }, + { + "title": "Returns", + "body": "30-day return policy for all items." + } + ] +); + +echo $pom->render_markdown(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/pom-builder/has-section.mdx b/fern/products/sdks/pages/reference/php/agents/pom-builder/has-section.mdx new file mode 100644 index 000000000..03f252764 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/pom-builder/has-section.mdx @@ -0,0 +1,55 @@ +--- +title: "hasSection / getSection" +slug: /reference/php/agents/pom-builder/has-section +description: Check if a section exists and retrieve it by title. +max-toc-depth: 3 +--- + +## **has_section** + +Check if a section with the given title exists. + +### **Parameters** + + + Section title to check. + + +### **Returns** + +`bool` -- `True` if the section exists, `False` otherwise. + +--- + +## **get_section** + +Get a section by title for direct manipulation. + +### **Parameters** + + + Section title to look up. + + +### **Returns** + +`?Section` -- The POM Section object, or `null` if not found. + +## **Example** + +```php +addSection("Role", body: "You are a helpful assistant."); + +if ($pom->has_section("Role")) { + $section = $pom->get_section("Role"); + echo "Found section: {$section->title}"; +} + +echo $pom->has_section("Missing"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/pom-builder/index.mdx b/fern/products/sdks/pages/reference/php/agents/pom-builder/index.mdx new file mode 100644 index 000000000..96534b0bc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/pom-builder/index.mdx @@ -0,0 +1,141 @@ +--- +title: "PomBuilder" +slug: /reference/php/agents/pom-builder +description: "Build structured Prompt Object Model prompts with sections, subsections, and bullets." +max-toc-depth: 3 +--- + +[agentbase]: /docs/sdks/reference/php/agents/agent-base +[addsection]: /docs/sdks/reference/php/agents/pom-builder/add-section +[getsection]: /docs/sdks/reference/php/agents/pom-builder/has-section +[hassection]: /docs/sdks/reference/php/agents/pom-builder/has-section +[render]: /docs/sdks/reference/php/agents/pom-builder/render +[tojson]: /docs/sdks/reference/php/agents/pom-builder/to-json + +PomBuilder provides a fluent interface for creating structured prompts using +the Prompt Object Model (POM). POM organizes prompt content into titled sections, +subsections, and bullet lists -- producing consistent, well-structured prompts +that the AI can follow reliably. + +Use PomBuilder when you need fine-grained control over prompt structure beyond +what `setPromptText()` and `promptAddSection()` on +[`AgentBase`][agentbase] provide. The builder +can render to Markdown or XML format. + + +PomBuilder requires the `signalwire-pom` package. Install it with: +`composer require signalwire/sdk-pom` + + +## **Methods** + + + + Add a new top-level section to the POM. + + + Get a section by title for direct manipulation. + + + Check if a section with a given title exists. + + + Render the POM as Markdown or XML. + + + Convert the POM to a JSON string. + + + +## **Examples** + +### Building a structured prompt + +```php {3} +addSection( + "Role", + body: "You are a customer service representative for Acme Corp." +); + +$pom->addSection( + "Guidelines", + bullets: [ + "Always greet the customer by name when available", + "Be concise and professional", + "Never make promises about timelines you cannot keep" + ] +); + +$pom->addSection( + "Product Knowledge", + body: "You have access to the product catalog.", + subsections: [ + { + "title": "Pricing", + "body": "Always quote current prices from the catalog." + }, + { + "title": "Returns", + "body": "30-day return policy for all items." + } + ] +); + +// Render as Markdown for use in a prompt +$prompt_text = $pom->render_markdown(); +echo $prompt_text; + +``` + +### Incremental construction + +```php {3} +addSection("Capabilities", body: "You can help with the following:"); + +// Add bullets incrementally as skills are loaded +$pom->add_to_section("Capabilities", bullet: "Weather lookups"); +$pom->add_to_section("Capabilities", bullet: "Calendar scheduling"); +$pom->add_to_section("Capabilities", bullets: [; + "Order tracking", + "Account management" +]); + +// Add a subsection +$pom->add_subsection( + "Capabilities", + "Limitations", + body: "You cannot process payments directly." +); + +echo $pom->render_markdown(); + +``` + +### Reconstructing from data + +```php + "Role", "body": "You are a helpful assistant."], + ["title" => "Rules", "bullets": ["Be concise", "Be accurate"]] +]; + +$pom = PomBuilder.$from_sections($sections); +$xml_prompt = $pom->render_xml(); +echo $xml_prompt; + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/pom-builder/render.mdx b/fern/products/sdks/pages/reference/php/agents/pom-builder/render.mdx new file mode 100644 index 000000000..28d87705a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/pom-builder/render.mdx @@ -0,0 +1,50 @@ +--- +title: "render" +sidebar-title: "render" +slug: /reference/php/agents/pom-builder/render +description: Render the POM as Markdown or XML. +max-toc-depth: 3 +--- + +Render the entire POM as a Markdown string. Sections become `##` headings, +subsections become `###` headings, and bullets render as Markdown lists. + +## **Returns** + +`string` -- The rendered Markdown text. + +--- + +Render the entire POM as an XML string. Useful when the AI benefits from +XML-structured prompts. + +## **Returns** + +`string` -- The rendered XML text. + +## **Example** + +```php {7,17} +addSection("Role", body: "You are a helpful assistant."); +$pom->addSection("Rules", bullets: ["Be concise", "Be accurate"]); + +// Render as Markdown +$md = $pom->render_markdown(); +echo $md; +// ## Role +// You are a helpful assistant. +// +// ## Rules +// - Be concise +// - Be accurate + +// Render as XML +$xml = $pom->render_xml(); +echo $xml; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/pom-builder/to-json.mdx b/fern/products/sdks/pages/reference/php/agents/pom-builder/to-json.mdx new file mode 100644 index 000000000..f03331a90 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/pom-builder/to-json.mdx @@ -0,0 +1,28 @@ +--- +title: "toJson" +slug: /reference/php/agents/pom-builder/to-json +description: Convert the POM to a JSON string. +max-toc-depth: 3 +--- + +Convert the POM to a JSON string. + +## **Returns** + +`string` -- JSON representation of the POM. + +## **Example** + +```php {7} +addSection("Role", body: "You are a helpful assistant."); +$pom->addSection("Rules", bullets: ["Be concise", "Be accurate"]); + +$json_str = $pom->toJson(); +echo $json_str; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/prefabs.mdx b/fern/products/sdks/pages/reference/php/agents/prefabs.mdx new file mode 100644 index 000000000..e7d6b4161 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/prefabs.mdx @@ -0,0 +1,601 @@ +--- +title: "Prefabs" +slug: /reference/php/agents/prefabs +description: Pre-built agent templates for common conversational patterns. +max-toc-depth: 3 +--- + +[agentbase]: /docs/sdks/reference/php/agents/agent-base +[skill]: /docs/sdks/reference/php/agents/skills#native_vector_search + +Prefabs are ready-to-use agent classes that implement common conversational patterns. +Each prefab extends [`AgentBase`][agentbase], so you can +customize them with additional prompt sections, tools, skills, and languages. Use them +directly for rapid prototyping or subclass them for production use. + +```php + +All prefabs can be extended by subclassing. Add custom tools with `defineTool()`, extra +prompt sections with `promptAddSection()`, and skills with `addSkill()`. + + +--- + +## ConciergeAgent + +A virtual concierge that provides venue information, answers questions about amenities and +services, helps with bookings, and gives directions. + +```php + + Name of the venue or business. + + + + List of services offered (e.g., `["room service", "spa bookings"]`). + + + + Dictionary of amenities. Each key is an amenity name, and the value is a dict of + details (typically `hours` and `location`, but any key-value pairs are accepted). + + + + Dictionary of operating hours by department or service. Defaults to `{"default": "9 AM - 5 PM"}`. + + + + Additional instructions appended to the agent's prompt (e.g., `["Mention the daily happy hour."]`). + + + + Custom greeting spoken when the call begins. When set, configures `static_greeting` with no-barge mode. + + + + Agent name for identification and logging. + + + + HTTP route for this agent. + + +### Built-in Tools + +| Tool | Description | Parameters | +|------|-------------|------------| +| `check_availability` | Check service availability for a date and time | `service` (str), `date` (str, YYYY-MM-DD), `time` (str, HH:MM) | +| `get_directions` | Get directions to an amenity or location | `location` (str) | + +### Example + +```php + "6 AM - 10 PM", "location": "Ground Floor, East Wing"], + "spa": ["hours" => "9 AM - 9 PM", "location": "Level 3, East Wing"], + "restaurant": ["hours" => "7 AM - 10 PM", "location": "Lobby Level"] + }, + hours_of_operation: { + "front desk": "24 hours", + "concierge": "7 AM - 11 PM" + }, + special_instructions: ["Mention the daily happy hour at the pool bar (4-6 PM)."], + welcome_message: "Welcome to The Riverside Resort! How may I assist you today?" +); + + $agent->run(); + + +``` + +--- + +## FAQBotAgent + +Answers frequently asked questions by matching user queries against a provided knowledge base. +Optionally suggests related questions from the database. + +```php + + List of FAQ items. Each dict must have `question` and `answer` keys; an optional + `categories` key (list of strings) enables category-based filtering. + + + + When `True`, the agent suggests related questions from the FAQ database after answering. + + + + Custom personality description for the bot. Defaults to a generic helpful FAQ bot persona. + + + + Agent name for identification and logging. + + + + HTTP route for this agent. + + +### Built-in Tools + +| Tool | Description | Parameters | +|------|-------------|------------| +| `search_faqs` | Search FAQs by query or category | `query` (str), `category` (str, optional) | + + +FAQBot works best with up to 50 FAQs. For larger knowledge bases, use the +`native_vector_search` [skill][skill] instead. + + +### Example + +```php +run(); + + +``` + +--- + +## InfoGathererAgent + +Collects answers to a series of questions in sequence, with optional confirmation for +critical fields. Supports both static questions (defined at construction) and dynamic +questions (determined at runtime via a callback). + +```php + + List of question dictionaries. If `null`, the agent operates in dynamic mode where + questions are determined by a callback at request time. Each question dict has: + + + + + Identifier for storing the answer (e.g., `"email"`). + + + + The question to ask the user. + + + + If `True`, the agent confirms the answer with the user before proceeding. Use for + critical data like email addresses and phone numbers. + + + + + Agent name for identification and logging. + + + + HTTP route for this agent. + + +### Built-in Tools + +| Tool | Description | Parameters | +|------|-------------|------------| +| `start_questions` | Begin the question sequence | (none) | +| `submit_answer` | Submit an answer and advance to the next question | `answer` (str) | + +### Dynamic Questions + +Instead of static questions, use `set_question_callback()` to determine questions at +request time based on query parameters, headers, or request body: + +```php + "name", "question_text": "What is your name?"], + ["key_name" => "issue", "question_text": "Describe your issue."] + ]; + } + return [; + ["key_name" => "name", "question_text": "What is your name?"], + ["key_name" => "message", "question_text": "How can I help?"] + ]; +} + +$agent = $InfoGathererAgent() # $No static $questions; +$agent->set_question_callback($get_questions); + + $agent->run(); + + +``` + +### set_question_callback + + + A function receiving `(query_params, body_params, headers)` that returns a list of + question dictionaries in the same format as the `questions` constructor parameter. + + +### Accessing Collected Data + +Answers are stored in `global_data` and available in SWAIG function handlers: + +```php +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(description="Process collected answers") +function processAnswers($args, raw_data: null) +{ + // Inside a tool handler + $global_data = $raw_data["global_data"] ?? {}; + $answers = $global_data["answers"] ?? []; + // [["key_name" => "name", "answer": "John Doe"], ...] + return new FunctionResult("Processed {$len(answers)} answers."); +} + +$agent->serve(); + + +``` + +### Example + +```php + "name", "question_text": "What is your name?"], + ["key_name" => "phone", "question_text": "What is your phone number?", "confirm": true], + ["key_name" => "date", "question_text": "What date would you like to schedule?"], + ["key_name" => "time", "question_text": "What time works best for you?"] + ], + name: "appointment-scheduler" +); + +$agent->addLanguage("English", "en-US", "rime.spore"); +$agent->promptAddSection("Brand", "You are scheduling appointments for Dr. Smith's office."); + + $agent->run(); + + +``` + +--- + +## ReceptionistAgent + +Greets callers, collects basic information about their needs, and transfers them to the +appropriate department. Uses `FunctionResult.connect()` for call transfers. + +```php + + List of departments. At least one department is required. Each dict must have: + + + + + Department identifier (e.g., `"sales"`). Used in the transfer tool's enum. + + + + Description of what the department handles. Guides the AI in routing decisions. + + + + Phone number for call transfer (e.g., `"+15551234567"`). + + + + + Initial greeting spoken to the caller. + + + + Voice ID for the agent's language configuration. + + + + Agent name for identification and logging. + + + + HTTP route for this agent. + + +### Built-in Tools + +| Tool | Description | Parameters | +|------|-------------|------------| +| `collect_caller_info` | Record the caller's name and reason for calling | `name` (str), `reason` (str) | +| `transfer_call` | Transfer the caller to a department | `department` (str, one of the registered department names) | + + +The `transfer_call` tool uses `FunctionResult.connect()` with `final=True`, which +permanently transfers the call out of the agent. The AI speaks a goodbye message +before the transfer executes. + + +### Example + +```php + "sales", "description": "New orders, pricing, and product information", "number": "+15551001001"], + ["name" => "support", "description": "Technical issues and troubleshooting", "number": "+15551001002"], + ["name" => "billing", "description": "Invoices, payments, and refunds", "number": "+15551001003"], + ["name" => "hr", "description": "Employment, careers, and benefits", "number": "+15551001004"] + ], + greeting: "Thank you for calling Acme Corporation. How may I direct your call?", + voice: "rime.spore", + name: "acme-receptionist" +); + +$agent->promptAddSection("Company", "You are the receptionist for Acme Corporation."); + + $agent->run(); + + +``` + +--- + +## SurveyAgent + +Conducts automated surveys with support for multiple question types, response validation, +and structured result summaries. The agent guides users through each question in sequence, +validates answers based on the question type, and retries on invalid responses. + +```php + + Name of the survey. Used in the agent's prompt and summary output. + + + + List of survey questions. Each dict must have `id`, `text`, and `type`: + + + + + Unique identifier for the question (e.g., `"satisfaction"`). Auto-generated as + `question_N` if omitted. + + + + The question text to ask the user. + + + + Question type. Valid values: + - `"rating"` -- numeric scale (1 to `scale`) + - `"multiple_choice"` -- select from `options` list + - `"yes_no"` -- accepts yes/no/y/n + - `"open_ended"` -- free text response + + + + Required for `multiple_choice` questions. List of valid answer options. + + + + For `rating` questions, the maximum value on the scale (e.g., `5` for 1-5). + + + + Whether the question requires an answer. Non-required `open_ended` questions accept + empty responses. + + + + + Custom introduction message. Defaults to `"Welcome to our {survey_name}."`. + + + + Custom conclusion message. Defaults to `"Thank you for completing our survey."`. + + + + Company or brand name used in the agent's persona. + + + + Maximum number of times to re-ask a question after an invalid response. + + + + Agent name for identification and logging. + + + + HTTP route for this agent. + + +### Built-in Tools + +| Tool | Description | Parameters | +|------|-------------|------------| +| `validate_response` | Check if a response meets the question's requirements | `question_id` (str), `response` (str) | +| `log_response` | Record a validated response | `question_id` (str), `response` (str) | + +### Example + +```php +addLanguage("English", "en-US", "rime.spore"); + + $agent->run(); + + +``` + +--- + +## Extending Prefabs + +All prefabs inherit from [`AgentBase`][agentbase], +so you can add custom tools, prompt sections, and skills: + +```php + "What is your return policy?", "answer": "30-day returns."] + ] + ); + } + + self->promptAddSection("Brand", "You represent Acme Corp."); + self->addSkill("datetime"); + + self->defineTool( + name: "escalate", + description: "Escalate to human agent", + parameters: {}, + handler: self.$escalate + ); + + public function escalate($args, $raw_data) + { + return new FunctionResult("Transferring to agent...").$connect("+15551234567"); +} + + $MyFAQBot()->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/search/document-processor/create-chunks.mdx b/fern/products/sdks/pages/reference/php/agents/search/document-processor/create-chunks.mdx new file mode 100644 index 000000000..9299f13ad --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/document-processor/create-chunks.mdx @@ -0,0 +1,58 @@ +--- +title: "createChunks" +slug: /reference/php/agents/search/document-processor/create-chunks +description: Split document content into chunks using the configured chunking strategy. +max-toc-depth: 3 +--- + +Split document content into chunks using the configured chunking strategy. +Each chunk includes metadata about its source file, section, and position +within the original document. + + +The `content` parameter should be the actual text content of the document, +not a file path. Use the appropriate extraction method first for binary formats. + + +## **Parameters** + + + Document text content to chunk. + + + + Name of the source file, used for metadata in each chunk. + + + + File extension or type (e.g., `"md"`, `"py"`, `"txt"`). + + +## **Returns** + +`list[dict]` -- A list of chunk dictionaries, each containing: +- `content` (str) -- the chunk text +- `filename` (str) -- source filename +- `section` (str | None) -- section name or hierarchy path +- `start_line` (int | None) -- starting line number in the source +- `end_line` (int | None) -- ending line number in the source +- `metadata` (dict) -- additional metadata (file type, word count, chunk method, etc.) + +## **Example** + +```php {8} +read(); + +$chunks = $processor->create_chunks($content, "README.md", "md"); +foreach ($chunks as $chunk) { + echo "[{$chunk['section']}] {$len(chunk['content'])} chars"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/search/document-processor/index.mdx b/fern/products/sdks/pages/reference/php/agents/search/document-processor/index.mdx new file mode 100644 index 000000000..c4c4f2237 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/document-processor/index.mdx @@ -0,0 +1,64 @@ +--- +title: "DocumentProcessor" +slug: /reference/php/agents/search/document-processor +description: "Process and chunk documents for search indexing with multiple strategies." +max-toc-depth: 3 +--- + +[createchunks]: /docs/sdks/reference/php/agents/search/document-processor/create-chunks + +`DocumentProcessor` handles document text extraction and chunking for search index +construction. It supports multiple file formats (PDF, DOCX, HTML, Markdown, Excel, +PowerPoint, RTF) and provides several chunking strategies optimized for different +content types and search use cases. + +```php + +Full document processing requires additional dependencies. Install with +`composer require signalwire/sdk[search-full]` for PDF, DOCX, and other format support. + + +## **Properties** + + + The active chunking strategy. + + + + Maximum sentences per chunk when using the `sentence` strategy. + + + + Word count per chunk when using the `sliding` strategy. + + + + Word overlap between chunks when using the `sliding` strategy. + + + + Number of consecutive newlines that trigger a split before sentence tokenization + in the `sentence` strategy. `null` when not explicitly set. + + + + Similarity threshold for the `semantic` chunking strategy. + + + + Similarity threshold for the `topic` chunking strategy. + + +## **Methods** + + + + Split document content into chunks using the configured chunking strategy. + + diff --git a/fern/products/sdks/pages/reference/php/agents/search/index-builder/build-index-from-sources.mdx b/fern/products/sdks/pages/reference/php/agents/search/index-builder/build-index-from-sources.mdx new file mode 100644 index 000000000..512461505 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/index-builder/build-index-from-sources.mdx @@ -0,0 +1,63 @@ +--- +title: "buildIndexFromSources" +slug: /reference/php/agents/search/index-builder/build-index-from-sources +description: Build a complete search index from multiple source files and directories. +max-toc-depth: 3 +--- + +Build a complete search index from multiple source files and directories. +This is the primary method for index construction. It handles file discovery, +text extraction, chunking, embedding generation, and storage. + +## **Parameters** + + + List of `Path` objects pointing to files and/or directories to index. + + + + Output path for the `.swsearch` file (SQLite backend) or collection name (pgvector). + + + + File extensions to include when scanning directories (e.g., `["md", "txt", "py"]`). + + + + Glob patterns for files to exclude (e.g., `["**/node_modules/**"]`). + + + + List of language codes to support. Defaults to `["en"]`. + + + + Global tags to add to every chunk in the index. + + + + For the pgvector backend, drop and recreate the collection if it already exists. + + +## **Returns** + +`null` + +## **Example** + +```php {5} +build_index_from_sources( + sources: [$Path("./docs"), $Path("./examples")], + output_file: "knowledge.swsearch", + file_types: ["md", "txt", "py"], + exclude_patterns: ["**/test_*"], + tags: ["documentation"], +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/search/index-builder/build-index.mdx b/fern/products/sdks/pages/reference/php/agents/search/index-builder/build-index.mdx new file mode 100644 index 000000000..e36b3f086 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/index-builder/build-index.mdx @@ -0,0 +1,58 @@ +--- +title: "buildIndex" +slug: /reference/php/agents/search/index-builder/build-index +description: Build a search index from a single directory. +max-toc-depth: 3 +--- + +[build-index-from-sources]: /docs/sdks/reference/php/agents/search/index-builder/build-index-from-sources + +Build a search index from a single directory. This is a convenience wrapper +around [`build_index_from_sources()`][build-index-from-sources] +for the common case of indexing one directory. + +## **Parameters** + + + Directory to scan for documents. + + + + Output `.swsearch` file path. + + + + File extensions to include. + + + + Glob patterns to exclude. + + + + Language codes. Defaults to `["en"]`. + + + + Global tags for all chunks. + + +## **Returns** + +`null` + +## **Example** + +```php {4} +build_index( + source_dir: "./docs", + output_file: "docs.swsearch", + file_types: ["md", "txt"], +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/search/index-builder/index.mdx b/fern/products/sdks/pages/reference/php/agents/search/index-builder/index.mdx new file mode 100644 index 000000000..5bdf4926d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/index-builder/index.mdx @@ -0,0 +1,68 @@ +--- +title: "IndexBuilder" +slug: /reference/php/agents/search/index-builder +description: "Build searchable vector indexes from document directories." +max-toc-depth: 3 +--- + +[sw-search]: /docs/sdks/reference/php/agents/cli/sw-search +[documentprocessor]: /docs/sdks/reference/php/agents/search/document-processor +[resolvemodelalias]: /docs/sdks/reference/php/agents/search/helpers +[buildindexfromsources]: /docs/sdks/reference/php/agents/search/index-builder/build-index-from-sources +[buildindex]: /docs/sdks/reference/php/agents/search/index-builder/build-index +[validateindex]: /docs/sdks/reference/php/agents/search/index-builder/validate-index + +`IndexBuilder` processes document directories into searchable indexes. It handles +file discovery, text extraction, chunking, embedding generation, and storage into +either SQLite (`.swsearch` files) or pgvector backends. This is the programmatic +equivalent of the [`sw-search`][sw-search] CLI tool. + +```php + +Requires search dependencies. Install with `composer require signalwire/sdk[search-full]` +for full document processing support. + + +## **Properties** + + + Name of the sentence transformer model used for embeddings. + + + + Active chunking strategy passed to the internal `DocumentProcessor`. + + + + Storage backend. Either `"sqlite"` or `"pgvector"`. + + + + The [`DocumentProcessor`][documentprocessor] + instance used for chunking. + + + + The loaded sentence transformer model. `null` until the first call to + `build_index()` or `build_index_from_sources()`. + + +## **Methods** + + + + Build a complete search index from multiple source files and directories. + + + Build a search index from a single directory. + + + Validate an existing .swsearch index file. + + diff --git a/fern/products/sdks/pages/reference/php/agents/search/index-builder/validate-index.mdx b/fern/products/sdks/pages/reference/php/agents/search/index-builder/validate-index.mdx new file mode 100644 index 000000000..2788992d1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/index-builder/validate-index.mdx @@ -0,0 +1,44 @@ +--- +title: "validateIndex" +slug: /reference/php/agents/search/index-builder/validate-index +description: Validate an existing .swsearch index file. +max-toc-depth: 3 +--- + +Validate an existing `.swsearch` index file, checking schema integrity and +returning summary statistics. Use this to verify that an index was built +correctly before deploying it. + +## **Parameters** + + + Path to the `.swsearch` file to validate. + + +## **Returns** + +`dict[string, mixed]` -- A dictionary with: +- `valid` (bool) -- whether the index is valid +- `error` (str) -- error message if invalid +- `chunk_count` (int) -- number of chunks (if valid) +- `file_count` (int) -- number of source files (if valid) +- `config` (dict) -- index configuration (if valid) + +## **Example** + +```php {4} +validate_index("knowledge.swsearch"); + +if ($result["valid"]) { + echo "Index OK: {$result['chunk_count']} chunks, {$result['file_count']} files"; +} +} else { + echo "Invalid index: {$result['error']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/search/index.mdx b/fern/products/sdks/pages/reference/php/agents/search/index.mdx new file mode 100644 index 000000000..b2ff14cf7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/index.mdx @@ -0,0 +1,106 @@ +--- +title: "Search" +sidebar-title: Search +subtitle: "Vector search and knowledge base capabilities for SignalWire AI agents" +slug: /reference/php/agents/search +description: "Build, query, and manage vector search indexes for agent knowledge bases." +max-toc-depth: 3 +--- + +[sw-search-cli-reference]: /docs/sdks/reference/php/agents/cli/sw-search +[search-engine]: /docs/sdks/reference/php/agents/search/search-engine +[document-processor]: /docs/sdks/reference/php/agents/search/document-processor +[index-builder]: /docs/sdks/reference/php/agents/search/index-builder +[search-service]: /docs/sdks/reference/php/agents/search/search-service +[migrator]: /docs/sdks/reference/php/agents/search/migrator + +The Search module provides local vector search capabilities for building knowledge bases +that power SignalWire AI agents. It supports hybrid search combining vector similarity +with keyword matching, multiple document formats, configurable chunking strategies, +and both SQLite and PostgreSQL (pgvector) storage backends. + + +The search module requires additional dependencies not included in the base SDK install. +Choose the install level that matches your use case: + +```bash +composer require signalwire/sdk[search] # Basic search (~500MB) +composer require signalwire/sdk[search-full] # + Document processing (~600MB) +composer require signalwire/sdk[search-nlp] # + Advanced NLP features (~600MB) +composer require signalwire/sdk[search-all] # All search features (~700MB) +``` + +For querying pre-built `.swsearch` indexes only (smallest footprint): + +```bash +composer require signalwire/sdk[search-queryonly] # ~400MB +``` + + +All classes and functions are imported from the `signalwire.search` namespace: + +```php + +The `sw-search` CLI tool provides command-line access to index building, validation, +and querying. See the [sw-search CLI reference][sw-search-cli-reference] +for details. + + +## **Learn More** + + + + Hybrid search engine combining vector similarity with keyword matching. + + + Process and chunk documents for indexing with multiple strategies. + + + Build searchable indexes from document directories. + + + HTTP API service for serving search queries with authentication and caching. + + + Migrate search indexes between SQLite and pgvector backends. + + + Query preprocessing, document preprocessing, model alias resolution, and constants. + + diff --git a/fern/products/sdks/pages/reference/php/agents/search/migrator/get-index-info.mdx b/fern/products/sdks/pages/reference/php/agents/search/migrator/get-index-info.mdx new file mode 100644 index 000000000..65175c9cf --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/migrator/get-index-info.mdx @@ -0,0 +1,40 @@ +--- +title: "getIndexInfo" +slug: /reference/php/agents/search/migrator/get-index-info +description: Retrieve information about a search index. +max-toc-depth: 3 +--- + +Retrieve information about a search index, including its type, configuration, +and chunk/file counts. Use this to inspect an index before migrating it. + +## **Parameters** + + + Path to a `.swsearch` file or pgvector collection identifier. + + +## **Returns** + +`dict[string, mixed]` -- A dictionary containing: +- `type` (str) -- `"sqlite"` or `"unknown"` +- `path` (str) -- the provided path +- `config` (dict) -- index configuration (SQLite only) +- `total_chunks` (int) -- chunk count (SQLite only) +- `total_files` (int) -- file count (SQLite only) + +## **Example** + +```php {4} +get_index_info("knowledge.swsearch"); + +echo "Type: {$info['type']}"; +echo "Chunks: {$info['total_chunks'] ?? 'N/A'}"; +echo "Files: {$info['total_files'] ?? 'N/A'}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/search/migrator/index.mdx b/fern/products/sdks/pages/reference/php/agents/search/migrator/index.mdx new file mode 100644 index 000000000..be803e9d5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/migrator/index.mdx @@ -0,0 +1,40 @@ +--- +title: "SearchIndexMigrator" +slug: /reference/php/agents/search/migrator +description: "Migrate search indexes between SQLite and pgvector backends." +max-toc-depth: 3 +--- + +[migratesqlitetopgvector]: /docs/sdks/reference/php/agents/search/migrator/migrate-sqlite-to-pgvector +[migratepgvectortosqlite]: /docs/sdks/reference/php/agents/search/migrator/migrate-pgvector-to-sqlite +[getindexinfo]: /docs/sdks/reference/php/agents/search/migrator/get-index-info + +`SearchIndexMigrator` converts search indexes between the SQLite (`.swsearch`) +and pgvector (PostgreSQL) backends. This is useful when moving from local +development to production, or when changing infrastructure. + +```php + +Requires search dependencies and the pgvector backend package. +Install with `composer require signalwire/sdk[search-all]`. + + +## **Methods** + + + + Migrate a .swsearch SQLite index to a pgvector collection in PostgreSQL. + + + Migrate a pgvector collection to a SQLite .swsearch file. + + + Retrieve information about a search index. + + diff --git a/fern/products/sdks/pages/reference/php/agents/search/migrator/migrate-pgvector-to-sqlite.mdx b/fern/products/sdks/pages/reference/php/agents/search/migrator/migrate-pgvector-to-sqlite.mdx new file mode 100644 index 000000000..46a8eda03 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/migrator/migrate-pgvector-to-sqlite.mdx @@ -0,0 +1,57 @@ +--- +title: "migratePgvectorToSqlite" +slug: /reference/php/agents/search/migrator/migrate-pgvector-to-sqlite +description: Migrate a pgvector collection to a SQLite .swsearch file. +max-toc-depth: 3 +--- + +Migrate a pgvector collection to a SQLite `.swsearch` file. This is useful +for creating local backups or moving from a PostgreSQL deployment to a +portable file-based index. + + +This method creates the SQLite schema and copies configuration, but full chunk +migration from pgvector to SQLite is planned for a future release. + + +## **Parameters** + + + PostgreSQL connection string. + + + + Name of the source pgvector collection. + + + + Output path for the `.swsearch` file. The `.swsearch` extension is appended + automatically if not present. + + + + Number of chunks to fetch per batch. + + +## **Returns** + +`dict[string, mixed]` -- Migration statistics with `source`, `target`, `chunks_migrated`, +`errors`, and `config` fields. + +## **Example** + +```php {4} +migrate_pgvector_to_sqlite( + connection_string: "postgresql://user:pass@localhost/mydb", + collection_name: "knowledge", + output_path: "./knowledge-backup.swsearch", +); + +echo "Migrated {$stats['chunks_migrated']} chunks to {$stats['target']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/search/migrator/migrate-sqlite-to-pgvector.mdx b/fern/products/sdks/pages/reference/php/agents/search/migrator/migrate-sqlite-to-pgvector.mdx new file mode 100644 index 000000000..d809ecbb4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/migrator/migrate-sqlite-to-pgvector.mdx @@ -0,0 +1,59 @@ +--- +title: "migrateSqliteToPgvector" +slug: /reference/php/agents/search/migrator/migrate-sqlite-to-pgvector +description: Migrate a .swsearch SQLite index to a pgvector collection in PostgreSQL. +max-toc-depth: 3 +--- + +Migrate a `.swsearch` SQLite index to a pgvector collection in PostgreSQL. +Chunks are transferred in batches with their embeddings, metadata, and tags preserved. + +## **Parameters** + + + Path to the source `.swsearch` file. + + + + PostgreSQL connection string (e.g., `"postgresql://user:pass@host/db"`). + + + + Name for the target pgvector collection. + + + + Drop and recreate the collection if it already exists. + + + + Number of chunks to insert per batch. + + +## **Returns** + +`dict[string, mixed]` -- Migration statistics containing: +- `source` (str) -- source file path +- `target` (str) -- target collection name +- `chunks_migrated` (int) -- number of successfully migrated chunks +- `errors` (int) -- number of failed chunks +- `config` (dict) -- source index configuration + +## **Example** + +```php {4} +migrate_sqlite_to_pgvector( + sqlite_path: "./knowledge.swsearch", + connection_string: "postgresql://user:pass@localhost/mydb", + collection_name: "knowledge", + overwrite: true, +); + +echo "Migrated {$stats['chunks_migrated']} chunks with {$stats['errors']} errors"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/search/search-engine/get-stats.mdx b/fern/products/sdks/pages/reference/php/agents/search/search-engine/get-stats.mdx new file mode 100644 index 000000000..ec42dfaff --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/search-engine/get-stats.mdx @@ -0,0 +1,42 @@ +--- +title: "getStats" +slug: /reference/php/agents/search/search-engine/get-stats +description: Return statistics about the search index. +max-toc-depth: 3 +--- + +Return statistics about the search index, including chunk counts, file counts, +average chunk size, file type distribution, language distribution, and index +configuration. + +## **Parameters** + +None. + +## **Returns** + +`dict[string, mixed]` -- A dictionary containing: +- `total_chunks` (int) -- total number of chunks in the index +- `total_files` (int) -- number of distinct source files +- `avg_chunk_size` (int) -- average chunk size in characters +- `file_types` (dict) -- count of files by type (markdown, python, etc.) +- `languages` (dict) -- count of chunks by language +- `config` (dict) -- index configuration + +## **Example** + +```php {4} +get_stats(); + +echo "Index contains {$stats['total_chunks']} chunks from {$stats['total_files']} files"; +echo "Average chunk size: {$stats['avg_chunk_size']} characters"; +foreach ($stats["file_types"] as ftype: > $count) { + echo " {$ftype}: {$count} files"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/search/search-engine/index.mdx b/fern/products/sdks/pages/reference/php/agents/search/search-engine/index.mdx new file mode 100644 index 000000000..6fd0f6fa0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/search-engine/index.mdx @@ -0,0 +1,58 @@ +--- +title: "SearchEngine" +slug: /reference/php/agents/search/search-engine +description: "Hybrid search engine for vector and keyword search over indexed documents." +max-toc-depth: 3 +--- + +[search]: /docs/sdks/reference/php/agents/search/search-engine/search +[getstats]: /docs/sdks/reference/php/agents/search/search-engine/get-stats + +`SearchEngine` performs hybrid search over indexed documents by combining vector +similarity search with keyword matching, filename search, and metadata search. +Results from all search strategies are merged and ranked using a max-signal-wins +scoring approach, with diversity penalties to prevent single-file dominance. + +The engine supports two storage backends: SQLite (`.swsearch` files) for local +use, and pgvector for PostgreSQL-based deployments. + +```php + +Requires search dependencies. Install with `composer require signalwire/sdk[search]`. + + +## **Properties** + + + Storage backend in use. Either `"sqlite"` or `"pgvector"`. + + + + Index configuration loaded from the backend, including model name, embedding + dimensions, and creation metadata. + + + + Dimensionality of the embedding vectors in the index. Defaults to `768`. + + + + Optional sentence transformer model instance passed at construction time. + + +## **Methods** + + + + Perform a hybrid search combining vector similarity, keyword matching, and metadata search. + + + Return statistics about the search index. + + diff --git a/fern/products/sdks/pages/reference/php/agents/search/search-engine/search.mdx b/fern/products/sdks/pages/reference/php/agents/search/search-engine/search.mdx new file mode 100644 index 000000000..3cfa88185 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/search-engine/search.mdx @@ -0,0 +1,83 @@ +--- +title: "search" +slug: /reference/php/agents/search/search-engine/search +description: Perform a hybrid search query against the indexed documents. +max-toc-depth: 3 +--- + +[preprocess-query]: /docs/sdks/reference/php/agents/search/helpers + +Perform a hybrid search combining vector similarity, keyword matching, filename +search, and metadata search. Candidates from all strategies are merged, scored, +filtered, and ranked. + +The search pipeline works in three stages: +1. **Candidate collection** -- run vector, filename, metadata, and keyword searches in parallel +2. **Scoring** -- combine signals using max-signal-wins with agreement boosts +3. **Ranking** -- apply diversity penalties, exact-match boosts, and tag filtering + +## **Parameters** + + + Embedding vector for the query, produced by encoding the query text with + the same model used to build the index. + + + + Preprocessed query text for keyword and full-text search. Typically the output + of [`preprocess_query()`][preprocess-query]. + + + + Maximum number of results to return. + + + + Minimum combined score for a result to be included. Results below this + threshold are filtered out. + + + + Filter results to only those containing at least one of the specified tags. + + + + Manual weight for keyword vs. vector scoring. When not set, the engine + uses its internal max-signal-wins scoring. + + + + The original unprocessed query string. Used for exact-match boosting. + + +## **Returns** + +`list[dict]` -- A list of result dictionaries, each containing: +- `content` (str) -- the chunk text +- `score` (float) -- the final combined score +- `metadata` (dict) -- chunk metadata including `filename`, `section`, `tags` +- `search_type` (str) -- the primary search strategy that found the result + +## **Example** + +```php {5} +search( + query_vector: $enhanced["vector"], + enhanced_text: $enhanced["enhanced_text"], + count: 5, + original_query: "How do I configure an agent?", +); + +foreach ($results as $result) { + echo "[{$result['score']:.3f}] {$result['metadata']['filename']}"; + echo " {$result['content'][:120]}..."; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/search/search-service/index.mdx b/fern/products/sdks/pages/reference/php/agents/search/search-service/index.mdx new file mode 100644 index 000000000..6f34d890c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/search-service/index.mdx @@ -0,0 +1,74 @@ +--- +title: "SearchService" +slug: /reference/php/agents/search/search-service +description: "HTTP API service for serving search queries with authentication and caching." +max-toc-depth: 3 +--- + +[searchengine]: /docs/sdks/reference/php/agents/search/search-engine +[start]: /docs/sdks/reference/php/agents/search/search-service/start +[searchdirect]: /docs/sdks/reference/php/agents/search/search-service/search-direct +[stop]: /docs/sdks/reference/php/agents/search/search-service/stop + +`SearchService` wraps one or more search indexes behind a FastAPI HTTP service +with basic authentication, CORS, query caching, and optional HTTPS support. +It can serve both SQLite and pgvector backends simultaneously. + +```php + +Requires FastAPI and uvicorn in addition to search dependencies: +`composer require signalwire/sdk[search]`. + + +## **Properties** + + + The FastAPI application instance. `null` if FastAPI is not installed. + + + + Mapping of index names to file paths (SQLite) or collection names (pgvector). + + + + Mapping of index names to loaded + [`SearchEngine`][searchengine] instances. + + + + Storage backend in use. `"sqlite"` or `"pgvector"`. + + + + Port the service listens on. + + +## **Methods** + + + + Start the HTTP service. Blocks until the server is shut down. + + + Perform a search programmatically without going through the HTTP API. + + + Stop the service and perform cleanup. + + + +## **HTTP Endpoints** + +When running, the service exposes the following endpoints: + +| Endpoint | Method | Auth | Description | +|----------|--------|------|-------------| +| `/search` | POST | Required | Submit a search query. Request body accepts `query`, `index_name`, `count`, `similarity_threshold`, `tags`, and `language`. | +| `/health` | GET | None | Health check. Returns backend type, loaded indexes, and SSL status. | +| `/reload_index` | POST | Required | Reload or add a new index at runtime. | diff --git a/fern/products/sdks/pages/reference/php/agents/search/search-service/search-direct.mdx b/fern/products/sdks/pages/reference/php/agents/search/search-service/search-direct.mdx new file mode 100644 index 000000000..7e6afe157 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/search-service/search-direct.mdx @@ -0,0 +1,62 @@ +--- +title: "searchDirect" +slug: /reference/php/agents/search/search-service/search-direct +description: Perform a search programmatically without going through the HTTP API. +max-toc-depth: 3 +--- + +Perform a search programmatically without going through the HTTP API. +This is useful for embedding search in application code where you want +the full preprocessing pipeline but do not need network overhead. + +## **Parameters** + + + The search query text. + + + + Name of the index to search. + + + + Maximum number of results to return. + + + + Minimum similarity threshold for results. + + + + Filter results by tags. + + + + Language code for query processing, or `null` for auto-detection. + + +## **Returns** + +`dict[string, mixed]` -- A dictionary with: +- `results` (list) -- list of result dicts, each with `content`, `score`, and `metadata` +- `query_analysis` (dict) -- information about query preprocessing + +## **Example** + +```php {4} + "./docs.swsearch"]); +$response = $service->search_direct( + query: "How do I set up an agent?", + index_name: "docs", + count: 5, +); + +foreach ($response["results"] as $result) { + echo "[{$result['score']:.3f}] {$result['content'][:100]}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/search/search-service/start.mdx b/fern/products/sdks/pages/reference/php/agents/search/search-service/start.mdx new file mode 100644 index 000000000..58971bb18 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/search-service/start.mdx @@ -0,0 +1,47 @@ +--- +title: "start" +slug: /reference/php/agents/search/search-service/start +description: Start the HTTP search service. +max-toc-depth: 3 +--- + +Start the HTTP service. This method blocks until the server is shut down +(e.g., via SIGINT). The service exposes search, health check, and index +reload endpoints. + +## **Parameters** + + + Host address to bind to. + + + + Port to bind to. Defaults to the port set in the constructor. + + + + Path to an SSL certificate file for HTTPS. Overrides environment settings. + + + + Path to an SSL key file for HTTPS. Overrides environment settings. + + +## **Returns** + +`null` -- This method blocks and does not return until the server is stopped. + +## **Example** + +```php {7} + "./docs.swsearch"], + basic_auth: ("admin", "secret"), +); +$service->start(port: 8001) # $Blocks $here, $serving $at $http://0.0.0.0:8001/; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/search/search-service/stop.mdx b/fern/products/sdks/pages/reference/php/agents/search/search-service/stop.mdx new file mode 100644 index 000000000..a81c93c8d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/search/search-service/stop.mdx @@ -0,0 +1,38 @@ +--- +title: "stop" +slug: /reference/php/agents/search/search-service/stop +description: Stop the search service and perform cleanup. +max-toc-depth: 3 +--- + +Stop the service and perform cleanup. Call this method to gracefully shut down +the HTTP server and release resources. + +## **Parameters** + +None. + +## **Returns** + +`null` + +## **Example** + +```php {9} + "./docs.swsearch"]); + +// In a signal handler or shutdown hook: +// import signal + +function shutdown($sig, $frame) +{ + $service->stop(); +} + +$signal->signal($signal->SIGTERM, $shutdown); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/skill-base/cleanup.mdx b/fern/products/sdks/pages/reference/php/agents/skill-base/cleanup.mdx new file mode 100644 index 000000000..0510aeff6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/skill-base/cleanup.mdx @@ -0,0 +1,46 @@ +--- +title: "cleanup" +slug: /reference/php/agents/skill-base/cleanup +description: Release resources when the skill is removed or the agent shuts down. +max-toc-depth: 3 +--- + +Called when the skill is removed or the agent shuts down. Override to release +resources, close connections, cancel background tasks, etc. + +## **Returns** + +`null` + +## **Example** + +```php {11} +close(); + self.$logger->info("Database connection closed"); + } + + public function registerTools() + { + // no-op +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/skill-base/define-tool.mdx b/fern/products/sdks/pages/reference/php/agents/skill-base/define-tool.mdx new file mode 100644 index 000000000..505b2be92 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/skill-base/define-tool.mdx @@ -0,0 +1,67 @@ +--- +title: "defineTool" +slug: /reference/php/agents/skill-base/define-tool +description: Register a tool with automatic swaig_fields merging. +max-toc-depth: 3 +--- + +Register a tool with the parent agent, automatically merging any `swaig_fields` +configured for this skill. Skills should use this method instead of calling +`self.agent.defineTool()` directly. + +## **Parameters** + + + All arguments supported by `agent.defineTool()`: `name`, `description`, + `parameters`, `handler`, `secure`, `fillers`, `wait_file`, etc. Explicit + values take precedence over `swaig_fields`. + + +## **Returns** + +`null` + +## **Example** + +```php {12} +defineTool( + name: "search_web", + description: "Search the web for information", + handler: self.$_handle_search, + parameters: { + "type": "object", + "properties": { + "query": ["type" => "string", "description": "Search query"] + }, + "required": ["query"] + }, + secure: true, + fillers: ["en-US" => ["Let me search for that..."]] + ); +} + + public function HandleSearch($args, $raw_data) + { + $query = $args["query"] ?? ""; + return new FunctionResult("Results for: {$query}"); +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/skill-base/get-description.mdx b/fern/products/sdks/pages/reference/php/agents/skill-base/get-description.mdx new file mode 100644 index 000000000..ce00b2520 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/skill-base/get-description.mdx @@ -0,0 +1,33 @@ +--- +title: "getDescription" +slug: /reference/php/agents/skill-base/get-description +description: Get the description of the skill. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/skill-base + +Get the description of the skill. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- The description value. + +## **Example** + +```php +getDescription(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/skill-base/get-global-data.mdx b/fern/products/sdks/pages/reference/php/agents/skill-base/get-global-data.mdx new file mode 100644 index 000000000..2b6bc090e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/skill-base/get-global-data.mdx @@ -0,0 +1,46 @@ +--- +title: "getGlobalData" +slug: /reference/php/agents/skill-base/get-global-data +description: Return data to merge into the agent's global_data dictionary. +max-toc-depth: 3 +--- + +Return data to merge into the agent's `global_data` dictionary. Override to +provide skill-specific session data that should be available to all SWAIG +function handlers. + +## **Returns** + +`dict[string, mixed]` -- Key-value pairs (default: empty dict). + +## **Example** + +```php {7} +_"` where `tool_name` comes from `params`. + +## **Example** + +```php +addSkill("notify"); +// Instance key: "notify" + +$agent->addSkill("notify", ["tool_name" => "email"]); +// Instance key: "notify_email" + +$agent->addSkill("notify", ["tool_name" => "sms"]); +// Instance key: "notify_sms" + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/skill-base/get-name.mdx b/fern/products/sdks/pages/reference/php/agents/skill-base/get-name.mdx new file mode 100644 index 000000000..0940825c4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/skill-base/get-name.mdx @@ -0,0 +1,33 @@ +--- +title: "getName" +slug: /reference/php/agents/skill-base/get-name +description: Get the name of the skill. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/skill-base + +Get the name of the skill. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- The name value. + +## **Example** + +```php +getName(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/skill-base/get-parameter-schema.mdx b/fern/products/sdks/pages/reference/php/agents/skill-base/get-parameter-schema.mdx new file mode 100644 index 000000000..1719c635c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/skill-base/get-parameter-schema.mdx @@ -0,0 +1,87 @@ +--- +title: "getParameterSchema" +slug: /reference/php/agents/skill-base/get-parameter-schema +description: Return metadata about all parameters the skill accepts. +max-toc-depth: 3 +--- + +Class method that returns metadata about all parameters the skill accepts. +Subclasses should call `super().get_parameter_schema()` and merge their own +parameters. + +## **Returns** + +`dict[string, dict[string, mixed]]` -- Parameter schema where keys are parameter names +and values describe the parameter. + +**Built-in parameters** (inherited by all skills): + +| Parameter | Type | Default | Description | +|-----------|------|---------|-------------| +| `swaig_fields` | object | `{}` | Additional SWAIG metadata merged into tool definitions | +| `skip_prompt` | bool | `False` | Suppress default prompt section injection | +| `tool_name` | str | `SKILL_NAME` | Custom name for this instance (multi-instance skills only) | + +**Schema value fields:** + +| Field | Type | Description | +|-------|------|-------------| +| `type` | str | `"string"`, `"integer"`, `"number"`, `"boolean"`, `"object"`, `"array"` | +| `description` | str | Human-readable description | +| `default` | Any | Default value | +| `required` | bool | Whether the parameter is required | +| `hidden` | bool | Hide in UIs (for secrets like API keys) | +| `env_var` | str | Environment variable that can provide this value | +| `enum` | list | Allowed values | +| `min` / `max` | number | Bounds for numeric types | + +## **Example** + +```php {8-9,34} +update({ + "units": { + "type": "string", + "description": "Temperature units", + "default": "fahrenheit", + "enum": ["fahrenheit", "celsius"] + }, + "api_key": { + "type": "string", + "description": "Weather API key", + "required": true, + "hidden": true, + "env_var": "WEATHER_API_KEY" + } + }); + return $schema; +} + + public function setup(): bool + { + return true; +} + + public function registerTools() + { + // no-op +} + +// Inspect the schema +echo $WeatherSkill->get_parameter_schema(); +// {'swaig_fields': {...}, 'skip_prompt': {...}, 'units': {...}, 'api_key': {...}} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/skill-base/get-prompt-sections.mdx b/fern/products/sdks/pages/reference/php/agents/skill-base/get-prompt-sections.mdx new file mode 100644 index 000000000..cf9146863 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/skill-base/get-prompt-sections.mdx @@ -0,0 +1,70 @@ +--- +title: "getPromptSections" +slug: /reference/php/agents/skill-base/get-prompt-sections +description: Return POM prompt sections for the agent. +max-toc-depth: 3 +--- + +Return POM prompt sections for the agent. Returns an empty list when the +`skip_prompt` parameter is `True`, otherwise delegates to `_get_prompt_sections()`. + +## **Returns** + +`list[dict[string, mixed]]` -- List of section dictionaries with `"title"` and +`"body"` or `"bullets"` keys. + + +Override `_get_prompt_sections()` instead of this method so your skill +automatically respects the `skip_prompt` configuration parameter. + + +--- + +Override this in subclasses to provide prompt sections. This is the recommended +override target rather than `get_prompt_sections()`. + +## **Returns** + +`list[dict[string, mixed]]` -- List of section dictionaries (default: empty list). + +## **Example** + +```php {7-8} +getRequiredEnvVars(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/skill-base/get-version.mdx b/fern/products/sdks/pages/reference/php/agents/skill-base/get-version.mdx new file mode 100644 index 000000000..e854bfe73 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/skill-base/get-version.mdx @@ -0,0 +1,33 @@ +--- +title: "getVersion" +slug: /reference/php/agents/skill-base/get-version +description: Get the version of the skill. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/skill-base + +Get the version of the skill. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- The version value. + +## **Example** + +```php +getVersion(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/skill-base/index.mdx b/fern/products/sdks/pages/reference/php/agents/skill-base/index.mdx new file mode 100644 index 000000000..7109c7404 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/skill-base/index.mdx @@ -0,0 +1,243 @@ +--- +title: "SkillBase" +slug: /reference/php/agents/skill-base +description: "Abstract base class for creating reusable, pluggable agent skills." +max-toc-depth: 3 +--- + +[agentbase]: /docs/sdks/reference/php/agents/agent-base +[skills]: /docs/sdks/reference/php/agents/skills +[cleanup]: /docs/sdks/reference/php/agents/skill-base/cleanup +[definetool]: /docs/sdks/reference/php/agents/skill-base/define-tool +[getglobaldata]: /docs/sdks/reference/php/agents/skill-base/get-global-data +[gethints]: /docs/sdks/reference/php/agents/skill-base/get-hints +[getinstancekey]: /docs/sdks/reference/php/agents/skill-base/get-instance-key +[getparameterschema]: /docs/sdks/reference/php/agents/skill-base/get-parameter-schema +[getpromptsections]: /docs/sdks/reference/php/agents/skill-base/get-prompt-sections +[registertools]: /docs/sdks/reference/php/agents/skill-base/register-tools +[setup]: /docs/sdks/reference/php/agents/skill-base/setup +[validate]: /docs/sdks/reference/php/agents/skill-base/validate + +SkillBase is the abstract base class for all agent skills. Skills are modular, +reusable capabilities -- such as weather lookup, web search, or calendar access -- +that can be added to any [`AgentBase`][agentbase] +agent with a single call to `agent.addSkill()`. + +Extend SkillBase to create custom skills. The SDK discovers skills automatically +from the `signalwire/skills/` directory and validates dependencies on load. + + +For the catalog of 17+ built-in skills and their configuration parameters, see +the [Skills][skills] page. + + +## **Class Attributes** + +Define these on your subclass to configure the skill: + + + Unique identifier for the skill (e.g., `"weather"`, `"web_search"`). Used as + the key when calling `agent.addSkill()`. + + + + Human-readable description of the skill. + + + + Semantic version string. + + + + Python packages the skill needs. Checked on setup with `validate_packages()`. + + + + Environment variables the skill needs. Checked on setup with `validate_env_vars()`. + + + + When `True`, the same skill can be added to an agent multiple times with + different configurations (distinguished by a `tool_name` parameter). + + +## **Instance Properties** + + + Reference to the parent agent. + + + + Configuration parameters (with `swaig_fields` removed). + + + + Skill-specific logger namespaced as `signalwire.skills.`. + + + + SWAIG metadata extracted from params, automatically merged into tool + definitions when using `defineTool()`. + + +## **Methods** + + + + Release resources when the skill is removed or the agent shuts down. + + + Register a tool with automatic swaig_fields merging. + + + Return data to merge into the agent's global_data dictionary. + + + Return speech recognition hints for this skill. + + + Get the unique key used to track this skill instance. + + + Return metadata about all parameters the skill accepts. + + + Return POM prompt sections for the agent. + + + Register SWAIG tools with the parent agent. + + + Initialize the skill and validate dependencies. + + + Validate environment variables and package dependencies. + + + Get the skill description. + + + Get the skill name. + + + Get the list of required environment variables. + + + Get the skill version. + + + Check if the skill supports multiple instances. + + + Validate that all required environment variables are set. + + + +## **Examples** + +### Custom skill + +```php +getenv("WEATHER_API_KEY"); + return true; +} + + public function registerTools() + { + self->defineTool( + name: "get_weather", + description: "Get current weather for a location", + handler: self.$_get_weather, + parameters: { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "City name or zip code" + } + }, + "required": ["location"] + } + ); +} + + public function GetWeather($args, $raw_data) + { +// import requests + $location = $args["location"] ?? null; + $resp = $requests->get( + "https://api.weather.com/v1/current?q={$location}&key={$self->api_key}" . + ); + $data = $resp->json(); + return new FunctionResult(; + "Weather in {$location}: {$data['condition']}, {$data['temp']}F" . + ); +} + + public function getHints() + { + return ["weather", "temperature", "forecast"]; +} + + public function GetPromptSections() + { + return [{; + "title": "Weather Information", + "body": "You can check weather for any location." + }]; + + // @classmethod + public function getParameterSchema() + { + $schema = $super().$get_parameter_schema(); + $schema->update({ + "units": { + "type": "string", + "description": "Temperature units", + "default": "fahrenheit", + "enum": ["fahrenheit", "celsius"] + } + }); + return $schema; +} + +``` + +### Using a skill + +```php +setPromptText("You are a helpful assistant."); +$agent->addSkill("weather"); + +// Or with custom configuration +$agent->addSkill("weather", ["units" => "celsius"]); + + $agent->run(); + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/skill-base/register-tools.mdx b/fern/products/sdks/pages/reference/php/agents/skill-base/register-tools.mdx new file mode 100644 index 000000000..b27e40971 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/skill-base/register-tools.mdx @@ -0,0 +1,63 @@ +--- +title: "registerTools" +slug: /reference/php/agents/skill-base/register-tools +description: Register SWAIG tools with the parent agent. +max-toc-depth: 3 +--- + +[ref-skillbase]: /docs/sdks/reference/php/agents/skill-base + +Register SWAIG tools with the parent agent. Called after `setup()` returns `True`. +Use `self.defineTool()` to register each tool. + +This is an abstract method -- you **must** implement it in every [SkillBase][ref-skillbase] subclass. + +## **Returns** + +`null` + +## **Example** + +```php {11} +defineTool( + name: "get_weather", + description: "Get current weather for a location", + handler: self.$_handle_weather, + parameters: { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "City name" + } + }, + "required": ["location"] + } + ); +} + + public function HandleWeather($args, $raw_data) + { + $location = $args["location"] ?? null; + return new FunctionResult("Weather in {$location}: sunny, 72F"); +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/skill-base/setup.mdx b/fern/products/sdks/pages/reference/php/agents/skill-base/setup.mdx new file mode 100644 index 000000000..aefcf30b4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/skill-base/setup.mdx @@ -0,0 +1,53 @@ +--- +title: "setup" +slug: /reference/php/agents/skill-base/setup +description: Initialize the skill and validate dependencies. +max-toc-depth: 3 +--- + +[ref-skillbase]: /docs/sdks/reference/php/agents/skill-base + +Initialize the skill: validate environment variables, check packages, initialize +API clients, and prepare resources. Called once when the skill is loaded. + +This is an abstract method -- you **must** implement it in every [SkillBase][ref-skillbase] subclass. + +## **Returns** + +`bool` -- `True` if setup succeeded, `False` to indicate the skill should not +be loaded. + +## **Example** + +```php {10} +getenv("WEATHER_API_KEY"); + return true; +} + + public function registerTools() + { + $pass # $See $register_tools $page; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/skill-base/supports-multiple-instances.mdx b/fern/products/sdks/pages/reference/php/agents/skill-base/supports-multiple-instances.mdx new file mode 100644 index 000000000..209ea402b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/skill-base/supports-multiple-instances.mdx @@ -0,0 +1,33 @@ +--- +title: "supportsMultipleInstances" +slug: /reference/php/agents/skill-base/supports-multiple-instances +description: Check whether multiple instances is supported. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/skill-base + +Check whether multiple instances is supported. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`bool` -- Whether the condition is true. + +## **Example** + +```php +supportsMultipleInstances(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/skill-base/validate-env-vars.mdx b/fern/products/sdks/pages/reference/php/agents/skill-base/validate-env-vars.mdx new file mode 100644 index 000000000..17117d6ae --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/skill-base/validate-env-vars.mdx @@ -0,0 +1,33 @@ +--- +title: "validateEnvVars" +slug: /reference/php/agents/skill-base/validate-env-vars +description: Validate env vars. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/skill-base + +Validate env vars. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`array` -- The result array. + +## **Example** + +```php +validateEnvVars(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/skill-base/validate.mdx b/fern/products/sdks/pages/reference/php/agents/skill-base/validate.mdx new file mode 100644 index 000000000..fbecb4203 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/skill-base/validate.mdx @@ -0,0 +1,55 @@ +--- +title: "validate" +slug: /reference/php/agents/skill-base/validate +description: Validate environment variables and package dependencies. +max-toc-depth: 3 +--- + +Check whether all `REQUIRED_ENV_VARS` are set in the environment. + +## **Returns** + +`bool` -- `True` if all required variables are present, `False` with error +logging otherwise. + +--- + +Check whether all `REQUIRED_PACKAGES` can be imported. + +## **Returns** + +`bool` -- `True` if all required packages are available, `False` with error +logging otherwise. + +## **Example** + +```php {9-12} +setPromptText("You are a helpful assistant."); + } + + // No-config skill + self->addSkill("datetime"); + + // Skill with parameters + self->addSkill("web_search", { + "api_key": "YOUR_KEY", + "search_engine_id": "YOUR_ENGINE_ID" + }); + + $MyAgent()->run(); + + +``` + +## Skills Summary + +| Skill | Functions | API Required | Multi-Instance | +|-------|-----------|--------------|----------------| +| [`datetime`](#datetime) | 2 | No | No | +| [`math`](#math) | 1 | No | No | +| [`web_search`](#web_search) | 1 | Yes | Yes | +| [`wikipedia_search`](#wikipedia_search) | 1 | No | No | +| [`weather_api`](#weather_api) | 1 | Yes | No | +| [`joke`](#joke) | 1 | Yes | No | +| [`playBackgroundFile`](#play_background_file) | 1 | No | Yes | +| [`swmlTransfer`](#swml_transfer) | 1 | No | Yes | +| [`datasphere`](#datasphere) | 1 | Yes | Yes | +| [`datasphere_serverless`](#datasphere_serverless) | 1 | Yes | Yes | +| [`native_vector_search`](#native_vector_search) | 1 | No | Yes | +| [`mcp_gateway`](#mcp_gateway) | Dynamic | No | Yes | +| [`google_maps`](#google_maps) | 2 | Yes | No | +| [`info_gatherer`](#info_gatherer) | 2 | No | Yes | +| [`claude_skills`](#claude_skills) | Dynamic | No | Yes | +| [`spider`](#spider) | 3 | No | Yes | +| [`api_ninjas_trivia`](#api_ninjas_trivia) | 1 | Yes | Yes | + +## Configuration + +All skills accept configuration via a dictionary passed to `addSkill()`. Skills can also +read values from environment variables when a parameter defines an `env_var` fallback. + +```php +addSkill("web_search", ["api_key" => "KEY", "search_engine_id": "ID"]); + +// Environment variable fallback +// import os +self->addSkill("web_search", { + "api_key": os->getenv("GOOGLE_API_KEY"), + "search_engine_id": os->getenv("SEARCH_ENGINE_ID") +}); + + +``` + +### SWAIG Field Overrides + +Override SWAIG function metadata for any skill by including a `swaig_fields` key: + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("datetime", { + "swaig_fields": { + "fillers": ["en-US" => ["Let me check the time...", "One moment..."]], + "secure": false + } + }); + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +### Multi-Instance Skills + +Skills that support multiple instances require unique `tool_name` values: + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("native_vector_search", { + "tool_name": "search_products", + "index_file": "/data/products.swsearch" + }); + self->addSkill("native_vector_search", { + "tool_name": "search_faqs", + "index_file": "/data/faqs.swsearch" + }); + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## datetime + +Get current date and time information with timezone support. + +**Tools:** `get_current_time`, `get_current_date` + +**Requirements:** `pytz` + +No custom parameters. This skill inherits only the base parameters (`swaig_fields`, `skip_prompt`). + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("datetime"); + } + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## math + +Perform mathematical calculations using a secure expression evaluator. Supports basic +arithmetic, common functions (`sqrt`, `sin`, `cos`, `log`, `abs`, `round`), and constants +(`pi`, `e`). + +**Tools:** `calculate` + +**Requirements:** None + + + Custom function name. + + + + Custom function description. + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("math"); + } + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## web_search + +Search the web using the Google Custom Search API. Results are filtered for quality and +summarized for voice delivery. + +**Tools:** `web_search` + +**Requirements:** Google Custom Search API key + Search Engine ID + +**Multi-instance:** Yes (use different `tool_name` and `search_engine_id` per instance) + + + Google API key with Custom Search JSON API enabled. + + + + Programmable Search Engine ID from Google. + + + + Number of search results to return (1-10). + + + + Delay between scraping pages in seconds. + + + + Maximum total response size in characters. + + + + How many extra results to fetch for quality filtering (e.g., `2.5` fetches 2.5x the + requested number). Range: 1.0-3.5. + + + + Quality threshold for filtering results (0.0-1.0). + + + + Message to show when no quality results are found. Use `{query}` as a placeholder + for the search query. + + + + Custom function name. + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("web_search", { + "api_key": "YOUR_GOOGLE_API_KEY", + "search_engine_id": "YOUR_SEARCH_ENGINE_ID", + "num_results": 3 + }); + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## wikipedia_search + +Search Wikipedia for factual information. No API key required. + +**Tools:** `search_wikipedia` + +**Requirements:** None (uses the public Wikipedia API) + + + Wikipedia language code (e.g., `"en"`, `"es"`, `"fr"`). + + + + Number of sentences to return per result. + + + + Custom function name. + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("wikipedia_search", ["sentences" => 5]); + } + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## weather_api + +Get current weather conditions for locations worldwide using WeatherAPI.com. + +**Tools:** `get_weather` + +**Requirements:** WeatherAPI.com API key (free tier available at https://www.weatherapi.com/) + + + WeatherAPI.com API key. + + + + Custom function name. + + + + Custom function description. + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("weather_api", ["api_key" => "YOUR_WEATHER_API_KEY"]); + } + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## joke + +Tell jokes using the API Ninjas joke API. Uses a [DataMap][ref-datamap] for serverless execution. + +**Tools:** `get_joke` (default, customizable via `tool_name`) + +**Requirements:** API Ninjas API key + + + API Ninjas API key for the joke service. Can also be set via the `API_NINJAS_KEY` + environment variable. + + + + Custom function name. + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("joke", { + "api_key": "YOUR_API_NINJAS_KEY" + }); + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## play_background_file + +Control background file playback during calls. A single tool handles both starting and +stopping playback via an `action` parameter with dynamic enum values generated from the +configured file list. Supports audio and video files. + +**Tools:** `playBackgroundFile` (default, customizable via `tool_name`) + +**Requirements:** None (files must be accessible via URL) + +**Multi-instance:** Yes (use different `tool_name` per instance) + + + Array of file configurations to make available for playback. Each object must include: + - `key` (str, required) -- Unique identifier for the file (alphanumeric, underscores, hyphens). + - `description` (str, required) -- Human-readable description of the file. + - `url` (str, required) -- URL of the audio/video file to play. + - `wait` (bool, optional, default `False`) -- Whether to wait for the file to finish playing. + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("playBackgroundFile", { + "tool_name": "play_testimonial", + "files": [ + { + "key": "massey", + "description": "Customer success story from Massey Energy", + "url": "https://example.com/massey.mp4", + "wait": true + } + ] + }); + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## swml_transfer + +Transfer calls between agents using SWML or direct connect, with regex pattern matching +to route to different destinations from a single tool. Each transfer destination can use +either a SWML endpoint URL or a phone number / SIP address. + +**Tools:** `transfer_call` (default, customizable via `tool_name`) + +**Requirements:** None + +**Multi-instance:** Yes + + + Transfer configurations mapping regex patterns to destinations. Each key is a regex + pattern (e.g., `/sales/i`) and each value is an object with: + - `url` (str) -- SWML endpoint URL for agent transfer. Mutually exclusive with `address`. + - `address` (str) -- Phone number or SIP address for direct connect. Mutually exclusive with `url`. + - `message` (str, default `"Transferring you now..."`) -- Message to say before transferring. + - `return_message` (str, default `"The transfer is complete. How else can I help you?"`) -- Message when returning from transfer. + - `post_process` (bool, default `True`) -- Whether to process message with AI before saying. + - `final` (bool, default `True`) -- Whether transfer is permanent (`True`) or temporary (`False`). + - `from_addr` (str, optional) -- Caller ID for connect action. + + + + Description for the transfer tool. + + + + Name of the parameter that accepts the transfer type. + + + + Description for the transfer type parameter. + + + + Message when no pattern matches. + + + + Whether to process the default (no-match) message with AI. + + + + Additional required fields to collect before transfer. Keys are field names, values + are descriptions. Collected values are saved under `call_data` in global data. + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("swmlTransfer", { + "tool_name": "route_call", + "transfers": { + "/sales/i": { + "url": "https://your-server.com/sales-agent", + "message": "Let me connect you with our sales team." + }, + "/support/i": { + "address": "+15551234567", + "final": false + } + } + }); + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## datasphere + +Search documents uploaded to SignalWire DataSphere. This skill executes the search +via a webhook call from the agent process. + +**Tools:** `search_datasphere` + +**Requirements:** SignalWire DataSphere credentials + +**Multi-instance:** Yes + + + SignalWire space name (e.g., `"mycompany"` from `mycompany.signalwire.com`). + + + + SignalWire project ID. + + + + SignalWire API token. + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("datasphere", { + "space_name": "your-space", + "project_id": "YOUR_PROJECT_ID", + "api_token": "YOUR_API_TOKEN" + }); + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## datasphere_serverless + +Search SignalWire DataSphere documents using a DataMap for serverless execution. +Unlike the standard `datasphere` skill, this version executes entirely server-side +without a webhook round-trip, making it suitable for serverless deployments. + +**Tools:** `search_datasphere` (default, customizable via `tool_name`) + +**Requirements:** SignalWire DataSphere credentials + +**Multi-instance:** Yes + + + SignalWire space name. + + + + SignalWire project ID. + + + + SignalWire API token. + + + + DataSphere document ID to search within. + + + + Number of search results to return. + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("datasphere_serverless", { + "space_name": "your-space", + "project_id": "YOUR_PROJECT_ID", + "token": "YOUR_API_TOKEN", + "document_id": "YOUR_DOCUMENT_ID", + "count": 3 + }); + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## native_vector_search + +Search local `.swsearch` vector index files built with the +[`sw-search`][sw-search] CLI tool. + +**Tools:** `search_knowledge` (default, customizable via `tool_name`) + +**Requirements:** Search extras installed (`composer require "signalwire[search]"`) + +**Multi-instance:** Yes + + + Path to the `.swsearch` index file. + + + + Custom function name. Required when using multiple instances. + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("native_vector_search", { + "index_file": "/path/to/knowledge.swsearch", + "tool_name": "search_docs" + }); + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## mcp_gateway + +Connect to MCP (Model Context Protocol) servers via the MCP Gateway service. Each MCP +tool is dynamically registered as a SWAIG function, enabling your agent to use any +MCP-compatible tool. + +**Tools:** Dynamically created from connected MCP services + +**Requirements:** Running MCP Gateway service + +**Multi-instance:** Yes + + + MCP Gateway service URL. + + + + Basic auth username for the gateway. + + + + Basic auth password for the gateway. + + + + Bearer token (alternative to basic auth). + + + + Specific services and tools to enable. Each dict has `name` (str) and `tools` (str `"*"` + or list of tool names). If omitted, all available services are enabled. + + + + Session timeout in seconds. + + + + Prefix for generated function names (e.g., `mcp_todo_add_todo`). + + + + Number of connection retry attempts. + + + + Individual request timeout in seconds. + + + + Whether to verify SSL certificates. + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("mcp_gateway", { + "gateway_url": "http://localhost:8080", + "auth_user": "admin", + "auth_password": "secure-password", + "services": [ + ["name" => "todo", "tools": "*"], + ["name" => "calculator", "tools": ["add", "multiply"]] + ] + }); + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## google_maps + +Validate addresses and compute driving routes using Google Maps. Handles spoken number +normalization (e.g., "seven one four" becomes "714") and location-biased search. + +**Tools:** `lookup_address`, `compute_route` + +**Requirements:** Google Maps API key with Geocoding and Routes APIs enabled + + + Google Maps API key. + + + + Custom name for the address lookup function. + + + + Custom name for the route computation function. + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("google_maps", ["api_key" => "YOUR_GOOGLE_MAPS_API_KEY"]); + } + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## info_gatherer + +Skill version of the [`InfoGathererAgent`][infogathereragent] +prefab. Collects answers to a configurable list of questions. Designed to be embedded +within larger agents as a reusable capability. + +**Tools:** `start_questions`, `submit_answer` (prefixed when using `prefix` parameter) + +**Requirements:** None + +**Multi-instance:** Yes (use `prefix` for unique tool names and state namespacing) + + + List of question dictionaries with `key_name`, `question_text`, and optional `confirm`. + + + + Prefix for tool names and state namespace. With `prefix="intake"`, tools become + `intake_start_questions` and `intake_submit_answer`, and state is stored under + `skill:intake` in global_data. + + +```php +setPromptText("You are a helpful assistant."); + // Two independent question sets on one agent + self->addSkill("info_gatherer", { + "prefix": "contact", + "questions": [ + ["key_name" => "name", "question_text": "What is your name?"], + ["key_name" => "email", "question_text": "What is your email?", "confirm": true] + ] + }); + + self->addSkill("info_gatherer", { + "prefix": "feedback", + "questions": [ + ["key_name" => "rating", "question_text": "How would you rate our service?"], + ["key_name" => "comments", "question_text": "Any additional comments?"] + ] + }); + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## claude_skills + +Load Claude Code-style SKILL.md files as agent tools. Each SKILL.md file in the +configured directory becomes a SWAIG function, with YAML frontmatter parsed for +metadata. + +**Tools:** Dynamically created from SKILL.md files + +**Requirements:** `PyYAML` + +**Multi-instance:** Yes + + + Path to the directory containing SKILL.md files. + + + + Prefix for generated function names. + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("claude_skills", { + "skills_path": "/path/to/skills/directory", + "tool_prefix": "skill_" + }); + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## spider + +Fast web scraping and crawling. Fetches web pages and extracts content optimized +for token efficiency. + +**Tools:** `scrape_url`, `crawl_site`, `extract_structured_data` (each prefixed with `tool_name` + `_` when set) + +**Requirements:** `lxml` + +**Multi-instance:** Yes + + + Delay between requests in seconds. + + + + Number of concurrent requests allowed (1-20). + + + + Request timeout in seconds. + + + + Maximum number of pages to scrape (1-100). + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("spider", { + "timeout": 10, + "concurrent_requests": 3, + "max_pages": 5 + }); + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## api_ninjas_trivia + +Get trivia questions from API Ninjas with configurable categories. Uses DataMap for +serverless execution. + +**Tools:** Configurable via `tool_name` + +**Requirements:** API Ninjas API key + +**Multi-instance:** Yes + + + API Ninjas API key. + + + + Custom name for the trivia function. + + + + List of trivia categories to enable. Available categories: `artliterature`, `language`, + `sciencenature`, `general`, `fooddrink`, `peopleplaces`, `geography`, `historyholidays`, + `entertainment`, `toysgames`, `music`, `mathematics`, `religionmythology`, `sportsleisure`. + + +```php +setPromptText("You are a helpful assistant."); + self->addSkill("api_ninjas_trivia", { + "tool_name": "get_science_trivia", + "api_key": "YOUR_API_NINJAS_KEY", + "categories": ["sciencenature", "mathematics", "general"] + }); + +$agent = $MyAgent(); +$agent->serve(); + + +``` + +--- + +## Custom Skills + +You can create custom skills and register them from external directories or via pip packages. + +### External Directory + +```php +add_skill_directory("/opt/custom_skills"); + + +``` + +Or set the `SIGNALWIRE_SKILL_PATHS` environment variable (colon-separated paths): + +```bash +export SIGNALWIRE_SKILL_PATHS=/path/to/skills1:/path/to/skills2 +``` + +### Entry Points + +Install skills as pip packages by defining entry points: + +```php + +Entry-point skills cannot override built-in skills. If an entry-point skill uses the +same `SKILL_NAME` as a built-in skill, it is skipped with an error log. + + +### Listing Available Skills + +```php +listSkills(); +foreach ($skills as $skill) { + echo "{$skill['name']}: {$skill['description']}"; +} + +// Get complete schema for all skills (includes parameters) +$schema = $skill_registry->get_all_skills_schema(); + + +``` + +For creating custom skills, see [`SkillBase`][skillbase]. diff --git a/fern/products/sdks/pages/reference/php/agents/swaig-function/execute.mdx b/fern/products/sdks/pages/reference/php/agents/swaig-function/execute.mdx new file mode 100644 index 000000000..f856d1200 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swaig-function/execute.mdx @@ -0,0 +1,66 @@ +--- +title: "execute" +slug: /reference/php/agents/swaig-function/execute +description: Execute the function with the given arguments. +max-toc-depth: 3 +--- + +[ref-functionresult]: /docs/sdks/reference/php/agents/function-result + +Execute the function with the given arguments. Calls the handler and normalizes +the return value into a FunctionResult dictionary. + +## **Parameters** + + + Parsed arguments for the function, matching the parameter schema. + + + + Full raw request data including `global_data`, `call_id`, `caller_id_number`, + `meta_data`, and `ai_session_id`. + + +## **Returns** + +`dict[string, mixed]` -- The function result as a dictionary (from +`FunctionResult.to_dict()`). If the handler raises an exception, returns a +generic error message rather than exposing internal details. + + +The handler can return a [`FunctionResult`][ref-functionresult], a `dict` with a `"response"` key, +or a plain string. All formats are normalized to a FunctionResult dictionary. + + +## **Example** + +```php {21} + "string", "description": "Account ID"] + }, + "required": ["account_id"] + } +); + +$result = $func->execute(["account_id" => "12345"], raw_data: {}); +echo $result; +// ["response" => "Account 12345 is active."] + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swaig-function/index.mdx b/fern/products/sdks/pages/reference/php/agents/swaig-function/index.mdx new file mode 100644 index 000000000..52433a663 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swaig-function/index.mdx @@ -0,0 +1,206 @@ +--- +title: "SWAIGFunction" +slug: /reference/php/agents/swaig-function +description: "Wrapper class for SWAIG function definitions with execution and validation." +max-toc-depth: 3 +--- + +[agent-tool-decorator]: /docs/sdks/reference/php/agents/agent-base#tool +[define-tool]: /docs/sdks/reference/php/agents/agent-base/define-tool +[agentbase]: /docs/sdks/reference/php/agents/agent-base +[datamap]: /docs/sdks/reference/php/agents/data-map +[functionresult]: /docs/sdks/reference/php/agents/function-result +[swaig-function-definition]: /docs/swml/reference/ai/swaig/functions +[swml-swaig-functions-reference]: /docs/swml/reference/ai/swaig/functions +[execute]: /docs/sdks/reference/php/agents/swaig-function/execute + +SWAIGFunction wraps a Python callable as a SWAIG (SignalWire AI Gateway) tool +that the AI can invoke during a conversation. It manages the function's name, +description, parameter schema, security settings, and serialization to SWML. + +In most cases you do not create SWAIGFunction instances directly. The +[`@agent.tool()` decorator][agent-tool-decorator] +and [`defineTool()`][define-tool] method +on [`AgentBase`][agentbase] handle construction +internally. This class is documented for advanced use cases such as custom +registration via `registerSwaigFunction()`. + + +For server-side API tools without a Python handler, see +[`DataMap`][datamap]. For building the +response returned from a handler, see +[`FunctionResult`][functionresult]. + + + +SWAIGFunction serializes to a SWML [SWAIG function definition][swaig-function-definition]. +See the [SWML SWAIG functions reference][swml-swaig-functions-reference] for the +full specification. + + +## **Properties** + + + The function name. + + + + The underlying Python handler function. + + + + The function description. + + + + The parameter schema dictionary. + + + + Whether token authentication is required. + + + + Filler phrases by language code to speak while the function executes + (e.g., `{"en-US": ["Let me check on that..."]}`). + + + + URL of an audio file to play while the function executes. Preferred over `fillers`. + + + + Number of times to loop `wait_file`. Defaults to playing once. + + + + External webhook URL. When set, the function call is forwarded to this URL instead + of being handled locally. + + + + List of required parameter names. Merged into the parameter schema's `required` array. + + + + Whether the handler uses type-hinted parameters (auto-wrapped by the `@tool` decorator). + + + + `True` when `webhook_url` is set, indicating the function is handled externally. + + +### \_\_call\_\_ + +The SWAIGFunction object is callable. Calling it directly delegates to the +underlying handler: + +```php +setPromptText("You are a helpful assistant."); + +// Tool decorator: @agent.tool(description="Look up order status") +function checkOrder($args, raw_data: null) +{ + $order_id = $args["order_id"] ?? null; + return new FunctionResult("Order {$order_id} shipped March 28."); +} + +$agent->serve(); + +``` + +This is equivalent to `func.handler(args, raw_data)`. + +## **Methods** + + + + Execute the function with the given arguments. + + + +--- + +## **Examples** + +### Manual registration + +```php {10} + ["Let me check on that..."]] +); + +// Validate before registering +$is_valid, $errors = $func->validate_args(["account_id" => "12345"]); +echo "Valid: {$is_valid}, Errors: {$errors}"; +// Valid: True, Errors: [] + +``` + +### Using the decorator (preferred) + +In most cases, use the `@agent.tool()` decorator instead of constructing +SWAIGFunction directly: + +```php +setPromptText("You are a helpful assistant."); + +// @agent.tool( + description: "Look up account status by ID", + parameters: { + "type": "object", + "properties": { + "account_id": ["type" => "string", "description": "Account ID"] + }, + "required": ["account_id"] + }, + secure: true, + fillers: ["Let me check on that..."] +); +function lookupAccount($args, $raw_data) +{ + $account_id = $args["account_id"] ?? ""; + return new FunctionResult("Account {$account_id} is active."); +} + + $agent->run(); + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-builder/add-raw-verb.mdx b/fern/products/sdks/pages/reference/php/agents/swml-builder/add-raw-verb.mdx new file mode 100644 index 000000000..a36d11822 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-builder/add-raw-verb.mdx @@ -0,0 +1,38 @@ +--- +title: "addRawVerb" +slug: /reference/php/agents/swml-builder/add-raw-verb +description: Add a raw verb. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-builder + +Add a raw verb. + +## **Parameters** + + + The SWML document section name. + + + + Raw verb definition as an associative array. + + +## **Returns** + +`void` -- + +## **Example** + +```php +addRawVerb( + section: "main", + verbHash: [] +); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-builder/add-section.mdx b/fern/products/sdks/pages/reference/php/agents/swml-builder/add-section.mdx new file mode 100644 index 000000000..4e5ff3ac7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-builder/add-section.mdx @@ -0,0 +1,43 @@ +--- +title: "addSection" +slug: /reference/php/agents/swml-builder/add-section +description: Add a new named section to the SWML document. +max-toc-depth: 3 +--- + +[swmlservice-add-section]: /docs/sdks/reference/php/agents/swml-service/add-section + +Add a new named section to the SWML document. Delegates to +[`Service.addSection()`][swmlservice-add-section]. + +## **Parameters** + + + Name of the section to create. + + +## **Returns** + +`Self` -- The builder instance for method chaining. + +## **Example** + +```php {10} + + The SWML document section name. + + + + The SWML verb name. + + + + Configuration options. + + +## **Returns** + +`void` -- + +## **Example** + +```php +addVerbToSection( + section: "main", + verbName: "play", + config: "value" +); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-builder/add-verb.mdx b/fern/products/sdks/pages/reference/php/agents/swml-builder/add-verb.mdx new file mode 100644 index 000000000..5a04cc967 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-builder/add-verb.mdx @@ -0,0 +1,38 @@ +--- +title: "addVerb" +slug: /reference/php/agents/swml-builder/add-verb +description: Add a verb. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-builder + +Add a verb. + +## **Parameters** + + + The SWML verb name. + + + + Configuration options. + + +## **Returns** + +`void` -- + +## **Example** + +```php +addVerb( + verbName: "play", + config: "value" +); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-builder/ai.mdx b/fern/products/sdks/pages/reference/php/agents/swml-builder/ai.mdx new file mode 100644 index 000000000..cb44168ca --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-builder/ai.mdx @@ -0,0 +1,90 @@ +--- +title: "ai" +slug: /reference/php/agents/swml-builder/ai +description: Add an AI verb to start an AI-powered conversation. +max-toc-depth: 3 +--- + +Add an `ai` verb to the main section. Starts an AI-powered conversation on the call. + + +`prompt_text` and `prompt_pom` are mutually exclusive. Provide one or the other to +set the AI system prompt, but not both. + + +## **Parameters** + + + Plain text system prompt for the AI. Mutually exclusive with `prompt_pom`. + + + + Prompt Object Model (POM) structure for the AI prompt. A list of section dictionaries + with keys like `"section"`, `"body"`, and `"bullets"`. Mutually exclusive with + `prompt_text`. + + + + Instructions for summarizing the call after the AI conversation ends. + + + + URL where the post-prompt summary is sent via webhook. + + + + SWAIG (SignalWire AI Gateway) configuration with tool function definitions and + defaults. Structure: `{"defaults": {"web_hook_url": "..."}, "functions": [...]}`. + + + + Additional AI verb parameters passed directly into the verb config (e.g., + `hints`, `languages`, `params`, `global_data`). + + +## **Returns** + +`Self` -- The builder instance for method chaining. + +## **Example** + +```php {10} + "https://example.com/swaig"], + "functions": [ + { + "function": "check_order", + "description": "Check order status", + "parameters": { + "type": "object", + "properties": { + "order_id": ["type" => "string", "description": "The order ID"] + }, + "required": ["order_id"] + } + } + ] + }, + hints: ["order", "tracking", "refund"], + params: ["end_of_speech_timeout" => 500] + ) + .render() +); +echo $swml_json; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-builder/answer.mdx b/fern/products/sdks/pages/reference/php/agents/swml-builder/answer.mdx new file mode 100644 index 000000000..3262b9563 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-builder/answer.mdx @@ -0,0 +1,44 @@ +--- +title: "answer" +slug: /reference/php/agents/swml-builder/answer +description: Add an answer verb to the SWML document. +max-toc-depth: 3 +--- + +Add an `answer` verb to the main section. Answers an incoming call. + +## **Parameters** + + + Maximum call duration in seconds. The call is automatically hung up after this + duration elapses. + + + + Comma-separated list of audio codecs to use for the call. + + +## **Returns** + +`Self` -- The builder instance for method chaining. + +## **Example** + +```php {9} + + The SWML document section name. + + +## **Returns** + +`void` -- + +## **Example** + +```php +clearSection("main"); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-builder/get-verbs.mdx b/fern/products/sdks/pages/reference/php/agents/swml-builder/get-verbs.mdx new file mode 100644 index 000000000..a4ea7c9bb --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-builder/get-verbs.mdx @@ -0,0 +1,32 @@ +--- +title: "getVerbs" +slug: /reference/php/agents/swml-builder/get-verbs +description: Get the verbs of the SWML document. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-builder + +Get the verbs of the SWML document. + +## **Parameters** + + + The SWML document section name. + Defaults to `'main'`. + + +## **Returns** + +`array` -- The result array. + +## **Example** + +```php +getVerbs("main"); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-builder/get-version.mdx b/fern/products/sdks/pages/reference/php/agents/swml-builder/get-version.mdx new file mode 100644 index 000000000..b1c249479 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-builder/get-version.mdx @@ -0,0 +1,29 @@ +--- +title: "getVersion" +slug: /reference/php/agents/swml-builder/get-version +description: Get the version of the SWML document. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-builder + +Get the version of the SWML document. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- The version value. + +## **Example** + +```php +getVersion(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-builder/hangup.mdx b/fern/products/sdks/pages/reference/php/agents/swml-builder/hangup.mdx new file mode 100644 index 000000000..975168d15 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-builder/hangup.mdx @@ -0,0 +1,40 @@ +--- +title: "hangup" +slug: /reference/php/agents/swml-builder/hangup +description: Add a hangup verb to end the current call. +max-toc-depth: 3 +--- + +Add a `hangup` verb to the main section. Ends the current call. + +## **Parameters** + + + An optional reason string for the hangup, included in call logs. + + +## **Returns** + +`Self` -- The builder instance for method chaining. + +## **Example** + +```php {11} + + The name identifier. + + +## **Returns** + +`bool` -- Whether the condition is true. + +## **Example** + +```php +hasSection("plant-lookup"); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-builder/index.mdx b/fern/products/sdks/pages/reference/php/agents/swml-builder/index.mdx new file mode 100644 index 000000000..3ddf94e41 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-builder/index.mdx @@ -0,0 +1,232 @@ +--- +title: "SWMLBuilder" +slug: /reference/php/agents/swml-builder +description: "Fluent builder API for constructing SWML documents with method chaining." +max-toc-depth: 3 +--- + +[swmlservice]: /docs/sdks/reference/php/agents/swml-service +[swml]: /docs/swml/reference/ai +[swml-reference]: /docs/swml/reference/ai +[addsection]: /docs/sdks/reference/php/agents/swml-builder/add-section +[ai]: /docs/sdks/reference/php/agents/swml-builder/ai +[answer]: /docs/sdks/reference/php/agents/swml-builder/answer +[hangup]: /docs/sdks/reference/php/agents/swml-builder/hangup +[play]: /docs/sdks/reference/php/agents/swml-builder/play +[render]: /docs/sdks/reference/php/agents/swml-builder/render +[reset]: /docs/sdks/reference/php/agents/swml-builder/reset +[say]: /docs/sdks/reference/php/agents/swml-builder/say + +SWMLBuilder provides a fluent interface for constructing SWML documents by chaining +method calls. It wraps a [`Service`][swmlservice] +instance and delegates all document operations to it, while returning `self` from every +verb method to enable chaining. Use SWMLBuilder when you want concise, readable document +construction in a single expression. + +In addition to the explicitly defined methods below, SWMLBuilder automatically generates +methods for every SWML verb in the schema (e.g., `connect()`, `record()`, `denoise()`, +`goto()`). These dynamic methods accept keyword arguments matching the verb's SWML +parameters and return `self` for chaining. + + +SWMLBuilder constructs [SWML][swml] documents programmatically. See the +[SWML reference][swml-reference] for the full specification of all supported verbs. + + +## **Properties** + + + The [`Service`][swmlservice] instance that + handles actual document storage, validation, and rendering. The builder delegates + all operations to this service. + + +## **Dynamic Verb Methods** + +SWMLBuilder auto-generates chaining methods for every verb defined in the SWML schema +that does not already have an explicit method. These dynamic methods accept keyword +arguments matching the verb's SWML parameters and return `Self`. + +Examples of dynamic verbs: `connect()`, `record()`, `recordCall()`, `denoise()`, +`transfer()`, `goto()`, `cond()`, `execute()`, `tap()`, and many more. + +```php {5} +connect(to: "+15551234567", from_: "+15559876543"); +$builder->recordCall(format: "mp4", stereo: true); +$builder->denoise(); + +echo $builder->build(); + +``` + +The `sleep` verb is a special case -- it accepts a positional `duration` argument +(milliseconds) instead of keyword arguments: + +```php +addSection("main"); +$builder->sleep(duration: 2000); + +echo $builder->render(); + +``` + + +If a verb name is not found in the SWML schema, calling it raises an `AttributeError`. + + +## **Methods** + + + + Add a new named section to the SWML document. + + + Add an AI verb to start an AI-powered conversation. + + + Add an answer verb to the SWML document. + + + Add a hangup verb to end the current call. + + + Add a play verb to play audio or text-to-speech. + + + Build and render the complete SWML document as a JSON string. + + + Reset the SWML document to an empty state. + + + Add text-to-speech playback to the SWML document. + + + Add a raw verb to the SWML document. + + + Add a verb to the SWML document. + + + Add a verb to a specific section. + + + Clear all verbs from a section. + + + Get all verbs in the document. + + + Get the SWML version string. + + + Check if a section exists. + + + Render the document as formatted JSON. + + + Convert the document to an array. + + + +--- + +## **Examples** + +### Basic IVR Flow + +```php {5} + "https://example.com/swaig"], + "functions": [ + { + "function": "check_order", + "description": "Check order status", + "parameters": { + "type": "object", + "properties": { + "order_id": ["type" => "string", "description": "The order ID"] + }, + "required": ["order_id"] + } + } + ] + }, + hints: ["order", "tracking", "refund"], + params: ["end_of_speech_timeout" => 500] + ) + .render() +); +echo $swml_json; + +``` + +### Text-to-Speech Greeting + +```php {5} + +Exactly one of `url` or `urls` must be provided. Calling `play()` without either +raises a `ValueError`. + + +## **Parameters** + + + Single URL to play. Supports audio file URLs and the `say:` prefix for + text-to-speech (e.g., `"say:Hello world"`). Mutually exclusive with `urls`. + + + + List of URLs to play in sequence. Mutually exclusive with `url`. + + + + Volume adjustment level, from `-40` to `40` dB. + + + + Voice name for text-to-speech playback. + + + + Language code for text-to-speech (e.g., `"en-US"`). + + + + Gender for text-to-speech voice selection. + + + + Whether to automatically answer the call before playing audio. + + +## **Returns** + +`Self` -- The builder instance for method chaining. + +## **Example** + +```php {11,21,34} +reset(); +$doc = ( + $builder + .$answer() + .$play(urls: [ + "https://example.com/greeting.mp3", + "https://example.com/menu.mp3" + ]) + .$build() +); +echo $doc; + +// Text-to-speech via say: prefix +$builder->reset(); +$doc = ( + $builder + .$answer() + .$play(url: "say:Welcome to our service.", say_voice: "rime.spore") + .$build() +); +echo $doc; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-builder/render-pretty.mdx b/fern/products/sdks/pages/reference/php/agents/swml-builder/render-pretty.mdx new file mode 100644 index 000000000..93e4ce681 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-builder/render-pretty.mdx @@ -0,0 +1,29 @@ +--- +title: "renderPretty" +slug: /reference/php/agents/swml-builder/render-pretty +description: Render the SWML document as a pretty-printed JSON string. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-builder + +Render the SWML document as a pretty-printed JSON string. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- JSON string representation. + +## **Example** + +```php +renderPretty(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-builder/render.mdx b/fern/products/sdks/pages/reference/php/agents/swml-builder/render.mdx new file mode 100644 index 000000000..ea05c3e76 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-builder/render.mdx @@ -0,0 +1,28 @@ +--- +title: "render" +slug: /reference/php/agents/swml-builder/render +description: Build and render the complete SWML document as a JSON string. +max-toc-depth: 3 +--- + +Build and render the complete SWML document as a JSON string. + +## **Returns** + +`string` -- The SWML document serialized as JSON. + +## **Example** + +```php {7} +answer().$ai(prompt_text: "Hello")->render(); +echo $json_str; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-builder/reset.mdx b/fern/products/sdks/pages/reference/php/agents/swml-builder/reset.mdx new file mode 100644 index 000000000..afd8cf752 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-builder/reset.mdx @@ -0,0 +1,34 @@ +--- +title: "reset" +slug: /reference/php/agents/swml-builder/reset +description: Reset the SWML document to an empty state. +max-toc-depth: 3 +--- + +Reset the document to an empty state and return the builder for continued chaining. + +## **Returns** + +`Self` -- The builder instance for method chaining. + +## **Example** + +```php {12} +answer().$hangup().$build(); +echo $doc1; + +// Reset and build a different document +$builder->reset(); +$doc2 = $builder->answer().$play(url: "say:Goodbye").$hangup().$build(); +echo $doc2; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-builder/say.mdx b/fern/products/sdks/pages/reference/php/agents/swml-builder/say.mdx new file mode 100644 index 000000000..b53331561 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-builder/say.mdx @@ -0,0 +1,61 @@ +--- +title: "say" +slug: /reference/php/agents/swml-builder/say +description: Add text-to-speech playback to the SWML document. +max-toc-depth: 3 +--- + +[play]: /docs/sdks/reference/php/agents/swml-builder/play + +Add a text-to-speech `play` verb using the `say:` URL prefix. This is a convenience +wrapper around [`play()`][play] that +constructs the `say:` URL automatically. + +## **Parameters** + + + The text to speak. + + + + Voice name for text-to-speech. + + + + Language code (e.g., `"en-US"`). + + + + Gender for voice selection. + + + + Volume adjustment level, from `-40` to `40` dB. + + +## **Returns** + +`Self` -- The builder instance for method chaining. + +## **Example** + +```php {10,12} +toArray(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/add-section.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/add-section.mdx new file mode 100644 index 000000000..58af878cf --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/add-section.mdx @@ -0,0 +1,38 @@ +--- +title: "addSection" +slug: /reference/php/agents/swml-service/add-section +description: "Add a new empty section to the SWML document." +max-toc-depth: 3 +--- + +Add a new empty section to the SWML document. Sections are named containers for +ordered lists of verbs. Every document starts with a `main` section. + +## **Parameters** + + + Name of the section to create. Must be unique within the document. + + +## **Returns** + +`bool` — `True` if the section was created, `False` if a section with that name +already exists. + +## **Example** + +```php {4} +addSection("fallback"); +$service->add_verb_to_section("fallback", "play", { + "url": "https://example.com/sorry.mp3" +}); +$service->add_verb_to_section("fallback", "hangup", {}); + +echo $service->render_document(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/add-verb-to-section.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/add-verb-to-section.mdx new file mode 100644 index 000000000..db9b9ded6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/add-verb-to-section.mdx @@ -0,0 +1,52 @@ +--- +title: "addVerbToSection" +slug: /reference/php/agents/swml-service/add-verb-to-section +description: "Add a SWML verb to a specific named section of the document." +max-toc-depth: 3 +--- + +Add a verb to a specific named section of the SWML document. If the section does not +exist, it is created automatically before the verb is appended. Raises +`SchemaValidationError` if validation is enabled and the verb config is invalid. + +## **Parameters** + + + Name of the section to add the verb to (e.g., `"main"`, `"transfer_flow"`). + + + + The SWML verb name. + + + + Configuration dictionary for the verb, or a direct `int` for the `sleep` verb. + + +## **Returns** + +`bool` — `True` if the verb was added successfully, `False` if the config type was +invalid (non-dict for non-sleep verbs). + +## **Example** + +```php {10} +add_verb("answer", {}); +$service->add_verb("ai", ["prompt" => {"text": "You are a helpful assistant"]}); + +// Build a separate transfer section +$service->add_verb_to_section("transfer", "connect", { + "to": "+15551234567", + "from": "+15559876543" +}); + +echo $service->render_document(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/add-verb.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/add-verb.mdx new file mode 100644 index 000000000..829c10baf --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/add-verb.mdx @@ -0,0 +1,53 @@ +--- +title: "addVerb" +slug: /reference/php/agents/swml-service/add-verb +description: "Add a SWML verb to the main section of the document." +max-toc-depth: 3 +--- + +[ref-swmlservice]: /docs/sdks/reference/php/agents/swml-service + +Add a verb to the `main` section of the current SWML document. The verb is validated +against the SWML schema (or a registered custom handler) before being appended. Raises +`SchemaValidationError` if validation is enabled and the verb config is invalid. + + +[SWMLService][ref-swmlservice] also auto-generates convenience methods for every verb defined in the SWML +schema (e.g., `service.play(url=...)`, `service.connect(to=...)`). These call `add_verb` +internally. Use `add_verb` directly when you need to pass a pre-built config dictionary +or work with custom verbs. + + +## **Parameters** + + + The SWML verb name (e.g., `"answer"`, `"play"`, `"ai"`, `"hangup"`, `"connect"`). + + + + Configuration dictionary for the verb. Most verbs accept a dict of parameters. + The `sleep` verb is a special case that accepts a direct `int` value representing + milliseconds. + + +## **Returns** + +`bool` — `True` if the verb was added successfully, `False` if the config type was +invalid (non-dict for non-sleep verbs). + +## **Example** + +```php {4-7} +add_verb("answer", {}); +$service->add_verb("play", ["url" => "https://example.com/greeting.mp3"]); +$service->add_verb("sleep", 2000); +$service->add_verb("hangup", ["reason" => "completed"]); + +echo $service->render_document(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/extract-sip-username.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/extract-sip-username.mdx new file mode 100644 index 000000000..704d36125 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/extract-sip-username.mdx @@ -0,0 +1,31 @@ +--- +title: "extractSipUsername" +slug: /reference/php/agents/swml-service/extract-sip-username +description: Extract the sip username from the request. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-service + +Extract the sip username from the request. + +## **Parameters** + + + The incoming HTTP request body. + + +## **Returns** + +`?string` -- The value, or `null` if not set. + +## **Example** + +```php + + When `True`, returns a 3-tuple that includes the credential source as the third + element. The source is one of: + - `"environment"` — credentials came from `SWML_BASIC_AUTH_USER` and `SWML_BASIC_AUTH_PASSWORD` environment variables + - `"auto-generated"` — credentials were randomly generated at startup + + +## **Returns** + +`tuple[string, string]` — A `(username, password)` tuple when `include_source` is `False`. + +`tuple[string, string, string]` — A `(username, password, source)` tuple when `include_source` is `True`. + +## **Example** + +```php {6,10} +getBasicAuthCredentials(); +echo "Auth: {$username}:{$password}"; + +// Get credentials with source information +$username, $password, $source = $service->getBasicAuthCredentials(include_source: true); +echo "Auth source: {$source}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/get-document.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/get-document.mdx new file mode 100644 index 000000000..0cd1817d9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/get-document.mdx @@ -0,0 +1,42 @@ +--- +title: "getDocument" +slug: /reference/php/agents/swml-service/get-document +description: "Get the current SWML document as a Python dictionary." +max-toc-depth: 3 +--- + +Get the current SWML document as a Python dictionary. The returned structure follows +the standard SWML format with `version` and `sections` keys. + +## **Returns** + +`dict[string, mixed]` — The current SWML document. Structure: + +```json +{ + "version": "1.0.0", + "sections": { + "main": [ + {"answer": {}}, + {"ai": {...}} + ] + } +} +``` + +## **Example** + +```php {7} +add_verb("answer", {}); +$service->add_verb("play", ["url" => "https://example.com/audio.mp3"]); + +$doc = $service->getDocument(); +echo $doc["version"]; +echo $len($doc["sections"]["main"]); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/get-full-url.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/get-full-url.mdx new file mode 100644 index 000000000..8dbf175f3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/get-full-url.mdx @@ -0,0 +1,32 @@ +--- +title: "getFullUrl" +slug: /reference/php/agents/swml-service/get-full-url +description: Get the full url of the SWML service. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-service + +Get the full url of the SWML service. + +## **Parameters** + + + Whether to include authentication credentials in the URL. + Defaults to `false`. + + +## **Returns** + +`string` -- The full url value. + +## **Example** + +```php +getFullUrl(true); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/get-host.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/get-host.mdx new file mode 100644 index 000000000..f53abb88e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/get-host.mdx @@ -0,0 +1,29 @@ +--- +title: "getHost" +slug: /reference/php/agents/swml-service/get-host +description: Get the host of the SWML service. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-service + +Get the host of the SWML service. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- The host value. + +## **Example** + +```php +getHost(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/get-name.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/get-name.mdx new file mode 100644 index 000000000..c831638e9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/get-name.mdx @@ -0,0 +1,29 @@ +--- +title: "getName" +slug: /reference/php/agents/swml-service/get-name +description: Get the name of the SWML service. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-service + +Get the name of the SWML service. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- The name value. + +## **Example** + +```php +getName(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/get-port.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/get-port.mdx new file mode 100644 index 000000000..1310df8c5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/get-port.mdx @@ -0,0 +1,29 @@ +--- +title: "getPort" +slug: /reference/php/agents/swml-service/get-port +description: Get the port of the SWML service. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-service + +Get the port of the SWML service. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`int` -- The integer value. + +## **Example** + +```php +getPort(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/get-proxy-url-base.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/get-proxy-url-base.mdx new file mode 100644 index 000000000..16a094724 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/get-proxy-url-base.mdx @@ -0,0 +1,32 @@ +--- +title: "getProxyUrlBase" +slug: /reference/php/agents/swml-service/get-proxy-url-base +description: Get the proxy url base of the SWML service. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-service + +Get the proxy url base of the SWML service. + +## **Parameters** + + + HTTP headers to include. + Defaults to `[]`. + + +## **Returns** + +`string` -- The proxy url base value. + +## **Example** + +```php +getProxyUrlBase(["Content-Type" => "application/json"]); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/get-route.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/get-route.mdx new file mode 100644 index 000000000..74a9c07f9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/get-route.mdx @@ -0,0 +1,29 @@ +--- +title: "getRoute" +slug: /reference/php/agents/swml-service/get-route +description: Get the route of the SWML service. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-service + +Get the route of the SWML service. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- The route value. + +## **Example** + +```php +getRoute(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/handle-request.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/handle-request.mdx new file mode 100644 index 000000000..56a0ffa20 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/handle-request.mdx @@ -0,0 +1,50 @@ +--- +title: "handleRequest" +slug: /reference/php/agents/swml-service/handle-request +description: Handle an incoming request. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-service + +Handle an incoming request. + +## **Parameters** + + + The HTTP method. + + + + The request path. + + + + HTTP headers to include. + Defaults to `[]`. + + + + The request body. + Defaults to `null`. + + +## **Returns** + +`array` -- The result array. + +## **Example** + +```php +handleRequest( + method: "GET", + path: "/plants", + headers: ["Content-Type" => "application/json"], + body: "Hello" +); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/index.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/index.mdx new file mode 100644 index 000000000..d42476884 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/index.mdx @@ -0,0 +1,204 @@ +--- +title: "SWMLService" +slug: /reference/php/agents/swml-service +description: "SWML document generation and FastAPI service base class." +max-toc-depth: 3 +--- + +[agentbase]: /docs/sdks/reference/php/agents/agent-base +[swml]: /docs/swml/reference/ai +[swml-reference]: /docs/swml/reference/ai +[configloader]: /docs/sdks/reference/php/agents/configuration/config-loader +[addsection]: /docs/sdks/reference/php/agents/swml-service/add-section +[addverb]: /docs/sdks/reference/php/agents/swml-service/add-verb +[addverbtosection]: /docs/sdks/reference/php/agents/swml-service/add-verb-to-section +[getbasicauthcredentials]: /docs/sdks/reference/php/agents/swml-service/get-basic-auth-credentials +[getdocument]: /docs/sdks/reference/php/agents/swml-service/get-document +[manualsetproxyurl]: /docs/sdks/reference/php/agents/swml-service/manual-set-proxy-url +[extractsipusername]: /docs/sdks/reference/php/agents/swml-service/register-routing-callback +[registerroutingcallback]: /docs/sdks/reference/php/agents/swml-service/register-routing-callback +[serve]: /docs/sdks/reference/php/agents/swml-service/serve +[stop]: /docs/sdks/reference/php/agents/swml-service/stop + +SWMLService is the foundation class for creating and serving SWML (SignalWire Markup +Language) documents. It provides SWML document generation with schema validation, +a built-in FastAPI web server for serving documents over HTTP, and basic authentication +for securing endpoints. Most developers will use +[`AgentBase`][agentbase] (which extends SWMLService) +rather than working with SWMLService directly. Use SWMLService when you need +low-level control over SWML document construction without the AI agent abstractions. + +[`AgentBase`][agentbase] extends SWMLService — it +inherits all document generation, serving, and authentication capabilities documented here. + + +SWMLService generates and serves [SWML][swml] documents over HTTP. +See the [SWML reference][swml-reference] for the full document specification. + + +## **Properties** + + + Service name/identifier used in logging and server startup messages. + + + + HTTP route path where this service is accessible. Trailing slashes are stripped + automatically during initialization. + + + + Host address the web server binds to. + + + + Port number the web server binds to. + + + + Schema validation utilities for SWML documents. Provides verb validation, + verb name enumeration, and schema property lookups. + + + + Registry of specialized verb handlers. Manages custom handlers for complex SWML + verbs that require logic beyond generic schema validation (e.g., the `ai` verb). + + + + Structured logger instance bound to this service name. + + + + Unified security configuration loaded from environment variables and optional + config file. Controls SSL, CORS, and host allowlist settings. + + + + Whether SSL/HTTPS is enabled. Mirrors `security.ssl_enabled` for backward compatibility. + + + + Domain name for SSL certificates. Mirrors `security.domain` for backward compatibility. + + + + Read-only property indicating whether full JSON Schema validation is active. + Controlled by the `schema_validation` property or the + `SWML_SKIP_SCHEMA_VALIDATION` environment variable. + + + + Explicit `(username, password)` for HTTP Basic Auth. Falls back to + `SWML_BASIC_AUTH_USER` / `SWML_BASIC_AUTH_PASSWORD` env vars. + + + + Path to a custom SWML JSON schema file. + + + + Path to a JSON config file. See [`ConfigLoader`][configloader]. + + + + Enable SWML schema validation. Disable with `False` or `SWML_SKIP_SCHEMA_VALIDATION=1`. + + +## **Methods** + + + + Add a new empty section to the SWML document. + + + Add a SWML verb to the main section of the document. + + + Add a SWML verb to a specific named section of the document. + + + Retrieve the HTTP Basic Auth credentials for the service. + + + Get the current SWML document as a Python dictionary. + + + Manually set the proxy URL base for webhook callback generation. + + + Static utility to extract the SIP username from request body data. + + + Register routing callbacks for dynamic request handling and SIP routing. + + + Start the FastAPI/Uvicorn web server for the SWML service. + + + Stop the SWML web server. + + + Extract the SIP username from a request. + + + Get the full URL for this service. + + + Get the host the service is bound to. + + + Get the service name. + + + Get the port the service listens on. + + + Get the proxy URL base for webhooks. + + + Get the HTTP route for this service. + + + Handle an incoming HTTP request. + + + Render the SWML document as JSON. + + + Render the document as formatted JSON. + + + Render the complete SWML output. + + + Start the service. + + + +## **Example** + +```php {4,7} +add_verb("answer", {}); +$service->add_verb("play", ["url" => "https://example.com/welcome.mp3"]); +$service->add_verb("hangup", {}); + +// Serve it +$service->serve(); + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/manual-set-proxy-url.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/manual-set-proxy-url.mdx new file mode 100644 index 000000000..edf9f0da7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/manual-set-proxy-url.mdx @@ -0,0 +1,48 @@ +--- +title: "manualSetProxyUrl" +slug: /reference/php/agents/swml-service/manual-set-proxy-url +description: "Manually set the proxy URL base for webhook callback generation." +max-toc-depth: 3 +--- + +Manually set the proxy URL base used for generating webhook callback URLs. Call this +when automatic proxy detection does not work for your deployment (e.g., behind a +custom load balancer or tunneling service). + +This overrides any value set via the `SWML_PROXY_URL_BASE` environment variable or +auto-detected from request headers. + + +The proxy URL affects how webhook URLs are generated for SWAIG function callbacks, +post-prompt URLs, and other webhook endpoints. Without a correct proxy URL, SignalWire +cannot reach your service's webhook endpoints when deployed behind a reverse proxy or +tunnel. + + +## **Parameters** + + + The base URL to use for webhook generation (e.g., `"https://my-agent.ngrok.io"`). + Trailing slashes are stripped automatically. + + +## **Returns** + +`null` + +## **Example** + +```php {6} +manualSetProxyUrl("https://abc123.ngrok.io"); + +$service->add_verb("answer", {}); +$service->serve(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/register-routing-callback.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/register-routing-callback.mdx new file mode 100644 index 000000000..85716b997 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/register-routing-callback.mdx @@ -0,0 +1,108 @@ +--- +title: "registerRoutingCallback" +slug: /reference/php/agents/swml-service/register-routing-callback +description: "Register routing callbacks for dynamic request handling and SIP routing." +max-toc-depth: 3 +--- + +[serve]: /docs/sdks/reference/php/agents/swml-service/serve + +Register a callback function for dynamic request routing. When a request arrives at +the specified path, the callback inspects the POST body and decides whether to route +the request to a different endpoint or let normal processing continue. This is primarily +used for SIP-based routing where the destination depends on the incoming SIP URI. + +An HTTP endpoint is automatically created at the specified path when the service starts. +The callback receives the raw FastAPI `Request` object and the parsed request body as +a dictionary. + + +The callback path is registered at the time of calling this method but the actual +FastAPI route is created when [`serve()`][serve] +is called or when `as_router()` generates the router. Register all callbacks before +starting the server. + + +## **Parameters** + + + A function that receives a FastAPI `Request` and the parsed JSON body as a `dict`. + Return a route string to redirect the request (using HTTP 307 to preserve the POST + method and body), or return `null` to continue with normal SWML document serving. + + + + The URL path where this routing endpoint is created. The path is normalized to start + with `/` and trailing slashes are stripped. + + +## **Returns** + +`null` + +--- + +## **extract_sip_username** (static method) + +Static utility method that extracts the username portion from a SIP URI in the request +body. Handles `sip:username@domain`, `tel:+1234567890`, and plain string formats in +the `call.to` field. + +### **Parameters** + + + The parsed JSON body from an incoming request. Expected to contain a `call.to` + field with a SIP URI, TEL URI, or phone number string. + + +### **Returns** + +`?string` — The extracted username or phone number, or `null` if the `call.to` +field is missing or cannot be parsed. + +### **Examples** + +### Routing callback with SIP username + +```php {15} +extractSipUsername($body); + if ($username == "sales") { + return "/agents/sales"; + } + } elseif ($username == "support") { + return "/agents/support"; + } + return null # $Default $handling; +} + +$service->add_verb("answer", {}); +$service->registerRoutingCallback($route_sip_call, path: "/sip"); +$service->serve(); + + +``` + +### Extracting SIP usernames + +```php + {"to": "sip:sales@example.sip.signalwire.com"]}; +$username = $SWMLService->extractSipUsername($body); +// "sales" + +$body = ["call" => {"to": "tel:+15551234567"]}; +$number = $SWMLService->extractSipUsername($body); +// "+15551234567" + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/render-pretty.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/render-pretty.mdx new file mode 100644 index 000000000..9191c78ae --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/render-pretty.mdx @@ -0,0 +1,29 @@ +--- +title: "renderPretty" +slug: /reference/php/agents/swml-service/render-pretty +description: Render the SWML document as a pretty-printed JSON string. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-service + +Render the SWML document as a pretty-printed JSON string. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- JSON string representation. + +## **Example** + +```php +renderPretty(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/render-swml.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/render-swml.mdx new file mode 100644 index 000000000..22049b8b8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/render-swml.mdx @@ -0,0 +1,40 @@ +--- +title: "renderSwml" +slug: /reference/php/agents/swml-service/render-swml +description: Render the complete SWML response for a request. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-service + +Render the complete SWML response for a request. + +## **Parameters** + + + The incoming HTTP request body. + Defaults to `null`. + + + + HTTP headers to include. + Defaults to `[]`. + + +## **Returns** + +`array` -- The result array. + +## **Example** + +```php +renderSwml( + requestBody: [], + headers: ["Content-Type" => "application/json"] +); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/render.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/render.mdx new file mode 100644 index 000000000..360023d1b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/render.mdx @@ -0,0 +1,29 @@ +--- +title: "render" +slug: /reference/php/agents/swml-service/render +description: Render the SWML document as a JSON string. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-service + +Render the SWML document as a JSON string. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- JSON string representation. + +## **Example** + +```php +render(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/run.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/run.mdx new file mode 100644 index 000000000..f32eecbfb --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/run.mdx @@ -0,0 +1,29 @@ +--- +title: "run" +slug: /reference/php/agents/swml-service/run +description: Start the SWML service. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/agents/swml-service + +Start the SWML service. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`void` -- + +## **Example** + +```php +run(); +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/serve.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/serve.mdx new file mode 100644 index 000000000..6aa4a339e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/serve.mdx @@ -0,0 +1,67 @@ +--- +title: "serve" +slug: /reference/php/agents/swml-service/serve +description: "Start the FastAPI/Uvicorn web server for the SWML service." +max-toc-depth: 3 +--- + +Start the HTTP server that serves the SWML document over HTTP. This is a +blocking call that runs the server until it is stopped. The server responds to both GET +and POST requests at the configured route, returning the current SWML document as JSON. + +On startup, the server prints the service URL and authentication credentials to the +console. If routing callbacks are registered, their endpoint URLs are also displayed. + +## **Parameters** + + + Host to bind to. Overrides the value set in the constructor. When `null`, uses + the constructor's `host` value. + + + + Port to bind to. Overrides the value set in the constructor. When `null`, uses + the constructor's `port` value. + + + + Path to an SSL certificate file. Overrides the `SWML_SSL_CERT_PATH` environment + variable. + + + + Path to an SSL private key file. Overrides the `SWML_SSL_KEY_PATH` environment + variable. + + + + Explicitly enable or disable SSL. Overrides the `SWML_SSL_ENABLED` environment + variable. + + + + Domain name for the SSL certificate. Used for URL generation when SSL is enabled. + + +## **Returns** + +`null` — This method blocks until the server is stopped. + +## **Example** + +```php {8} +add_verb("answer", {}); +$service->add_verb("play", ["url" => "https://example.com/welcome.mp3"]); + +// Start on default host/port (0.0.0.0:3000) +$service->serve(); + +// Or override host and port +// service.serve(host="127.0.0.1", port=8080) + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/swml-service/stop.mdx b/fern/products/sdks/pages/reference/php/agents/swml-service/stop.mdx new file mode 100644 index 000000000..f704d35ca --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/swml-service/stop.mdx @@ -0,0 +1,26 @@ +--- +title: "stop" +slug: /reference/php/agents/swml-service/stop +description: "Stop the SWML web server." +max-toc-depth: 3 +--- + +Stop the web server. Sets the internal running flag to `False`. + +## **Returns** + +`null` + +## **Example** + +```php {6} +stop(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/agents/web-service/index.mdx b/fern/products/sdks/pages/reference/php/agents/web-service/index.mdx new file mode 100644 index 000000000..6cf64de09 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/web-service/index.mdx @@ -0,0 +1,80 @@ +--- +title: "WebService" +slug: /reference/php/agents/web-service +description: Static file serving service with HTTP API, authentication, and security headers. +max-toc-depth: 3 +--- + +[securityconfig]: /docs/sdks/reference/php/agents/configuration/security-config +[stop]: /docs/sdks/reference/php/agents/web-service/stop + +WebService provides a standalone FastAPI-based HTTP server for serving static +files alongside your SignalWire agents. It includes security features such as +Basic authentication, CORS, path traversal prevention, file extension filtering, +and configurable security headers. + +Use WebService when your agent needs to serve audio files, web pages, or other +static assets over HTTP/HTTPS. + +```php {3} + "./audio_files", "/docs": "./public"], + enable_directory_browsing: true +); +$web->start(); + +``` + +## **Properties** + + + The underlying FastAPI application instance. `null` if FastAPI is not installed. + + + + The port the server listens on. + + + + Dictionary mapping URL route paths to local directory paths. + + + + Whether directory listing is enabled for mounted directories. + + + + Maximum file size in bytes that the server will serve (default: 100 MB). + + + + Whether CORS middleware is enabled. + + + + If set, only files with these extensions are served (e.g., `[".html", ".css"]`). + When `null`, all extensions except those in `blocked_extensions` are allowed. + + + + File extensions and names that are never served. Defaults to + `.env`, `.git`, `.gitignore`, `.key`, `.pem`, `.crt`, `.pyc`, `__pycache__`, + `.DS_Store`, `.swp`. + + + + The [`SecurityConfig`][securityconfig] instance + managing authentication and security headers. + + +## **Methods** + + + + Stop the service and run cleanup tasks. + + diff --git a/fern/products/sdks/pages/reference/php/agents/web-service/stop.mdx b/fern/products/sdks/pages/reference/php/agents/web-service/stop.mdx new file mode 100644 index 000000000..7407488f0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/agents/web-service/stop.mdx @@ -0,0 +1,30 @@ +--- +title: "stop" +slug: /reference/php/agents/web-service/stop +description: Stop the service and run cleanup tasks. +max-toc-depth: 3 +--- + +Stop the service and run any cleanup tasks. This is a placeholder for future +cleanup logic and currently performs no action. + +## **Parameters** + +None. + +## **Returns** + +`null` + +## **Example** + +```php {5} + "./audio_files"]); +// ... after server has been running ... +$web->stop(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/ai-action/index.mdx b/fern/products/sdks/pages/reference/php/relay/actions/ai-action/index.mdx new file mode 100644 index 000000000..220c82b34 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/ai-action/index.mdx @@ -0,0 +1,65 @@ +--- +title: "AIAction" +slug: /reference/php/relay/actions/ai-action +description: Action handle for an active AI agent session. +max-toc-depth: 3 +--- + +[call-ai]: /docs/sdks/reference/php/relay/call/ai +[base-action-interface]: /docs/sdks/reference/php/relay/actions +[stop]: /docs/sdks/reference/php/relay/actions/ai-action/stop + +Returned from [`call.ai()`][call-ai]. Tracks +an active AI agent session on the call. Terminal states: `finished`, `error`. + + +AI sessions typically end when the call ends or when explicitly stopped. The +terminal event may not carry a standard `state` field like other actions. + + +Inherits all properties and methods from the +[base Action interface][base-action-interface] (`control_id`, +`is_done`, `completed`, `result`, `wait()`). + +## **Properties** + +No additional properties beyond the [base Action interface][base-action-interface]. + +## **Methods** + + + + Stop the AI agent session. + + + +## **Example** + +```php +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->ai( + prompt: ["text" => "You are a helpful assistant."], + ai_params: ["temperature" => 0.7], + ); +} + + // Wait for it to complete naturally + $event = $await $action->wait(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/ai-action/stop.mdx b/fern/products/sdks/pages/reference/php/relay/actions/ai-action/stop.mdx new file mode 100644 index 000000000..b6d9a03e1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/ai-action/stop.mdx @@ -0,0 +1,43 @@ +--- +title: "stop" +slug: /reference/php/relay/actions/ai-action/stop +description: Stop the AI agent session. +max-toc-depth: 3 +--- + +Stop the AI agent session. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {19} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->ai( + prompt: ["text" => "You are a helpful assistant."], + ai_params: ["temperature" => 0.7], + ); +} + + // Stop the AI session + $action->stop(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/collect-action/index.mdx b/fern/products/sdks/pages/reference/php/relay/actions/collect-action/index.mdx new file mode 100644 index 000000000..b81ff6a00 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/collect-action/index.mdx @@ -0,0 +1,78 @@ +--- +title: "CollectAction" +slug: /reference/php/relay/actions/collect-action +description: Action handle for a play-and-collect operation. +max-toc-depth: 3 +--- + +[call-play-and-collect]: /docs/sdks/reference/php/relay/call/play-and-collect +[base-action-interface]: /docs/sdks/reference/php/relay/actions +[stop]: /docs/sdks/reference/php/relay/actions/collect-action/stop +[volume]: /docs/sdks/reference/php/relay/actions/collect-action/volume +[startinputtimers]: /docs/sdks/reference/php/relay/actions/collect-action/start-input-timers + +Returned from [`call.playAndCollect()`][call-play-and-collect]. +Tracks a combined play-and-collect operation where a prompt is played and user +input (digits or speech) is collected. Terminal states: `finished`, `error`, +`no_input`, `no_match`. + + +`CollectAction` only resolves on collect events. Play events sharing the same +`control_id` are ignored, so `await action.wait()` returns only when input +collection completes. + + +Inherits all properties and methods from the +[base Action interface][base-action-interface] (`control_id`, +`is_done`, `completed`, `result`, `wait()`). + +## **Properties** + +No additional properties beyond the [base Action interface][base-action-interface]. + +## **Methods** + + + + Stop the play-and-collect operation. + + + Adjust the prompt playback volume during a play-and-collect operation. + + + Manually start the initial_timeout timer on an active collect. + + + +## **Example** + +```php +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->playAndCollect( + media: [["type" => "tts", "text": "Press 1 for sales, 2 for support."]], + collect: ["digits" => {"max": 1, "digit_timeout": 5.0]}, + ); +} + + $event = $await $action->wait(); + $result = $event->params["result"] ?? {}; + $digit = $result["digits"] ?? ""; + echo "User pressed: {$digit}"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/collect-action/start-input-timers.mdx b/fern/products/sdks/pages/reference/php/relay/actions/collect-action/start-input-timers.mdx new file mode 100644 index 000000000..4137c7f72 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/collect-action/start-input-timers.mdx @@ -0,0 +1,49 @@ +--- +title: "startInputTimers" +slug: /reference/php/relay/actions/collect-action/start-input-timers +description: Manually start the initial_timeout timer on an active collect. +max-toc-depth: 3 +--- + +Manually start the `initial_timeout` timer on the active collect operation. Useful +when `startInputTimers` was set to `false` during the initial call. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {22} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->playAndCollect( + media: [["type" => "tts", "text": "Press 1 for sales, 2 for support."]], + collect: { + "digits": ["max" => 1, "digit_timeout": 5.0], + "startInputTimers": false, + }, + ); +} + + // Start timers when ready + $action->startInputTimers(); + + $event = $await $action->wait(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/collect-action/stop.mdx b/fern/products/sdks/pages/reference/php/relay/actions/collect-action/stop.mdx new file mode 100644 index 000000000..3d84d87d0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/collect-action/stop.mdx @@ -0,0 +1,43 @@ +--- +title: "stop" +slug: /reference/php/relay/actions/collect-action/stop +description: Stop the play-and-collect operation. +max-toc-depth: 3 +--- + +Stop the play-and-collect operation. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {19} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->playAndCollect( + media: [["type" => "tts", "text": "Press 1 for sales, 2 for support."]], + collect: ["digits" => {"max": 1, "digit_timeout": 5.0]}, + ); +} + + // Cancel the operation + $action->stop(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/collect-action/volume.mdx b/fern/products/sdks/pages/reference/php/relay/actions/collect-action/volume.mdx new file mode 100644 index 000000000..42ce36f47 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/collect-action/volume.mdx @@ -0,0 +1,49 @@ +--- +title: "volume" +slug: /reference/php/relay/actions/collect-action/volume +description: Adjust the prompt playback volume during a play-and-collect operation. +max-toc-depth: 3 +--- + +Adjust the prompt playback volume. + +## **Parameters** + + + Volume adjustment in dB. Range: `-40.0` to `40.0`. + + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {19} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->playAndCollect( + media: [["type" => "tts", "text": "Press 1 for sales, 2 for support."]], + collect: ["digits" => {"max": 1, "digit_timeout": 5.0]}, + ); +} + + // Increase prompt volume + $action->volume(10.0); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/detect-action/index.mdx b/fern/products/sdks/pages/reference/php/relay/actions/detect-action/index.mdx new file mode 100644 index 000000000..be697d931 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/detect-action/index.mdx @@ -0,0 +1,67 @@ +--- +title: "DetectAction" +slug: /reference/php/relay/actions/detect-action +description: Action handle for an active detection operation. +max-toc-depth: 3 +--- + +[call-detect]: /docs/sdks/reference/php/relay/call/detect +[base-action-interface]: /docs/sdks/reference/php/relay/actions +[stop]: /docs/sdks/reference/php/relay/actions/detect-action/stop + +Returned from [`call.detect()`][call-detect]. Tracks +an active detection operation (answering machine, fax tone, or digit detection). +Terminal states: `finished`, `error`. + + +Unlike other actions, `DetectAction` also resolves on the first detection result, +not just on terminal state events. This means `await action.wait()` returns as +soon as a detection is made. + + +Inherits all properties and methods from the +[base Action interface][base-action-interface] (`control_id`, +`is_done`, `completed`, `result`, `wait()`). + +## **Properties** + +No additional properties beyond the [base Action interface][base-action-interface]. + +## **Methods** + + + + Stop detection immediately. + + + +## **Example** + +```php +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->detect( + ["type" => "machine", "params": {"initial_timeout": 5.0]} + ); +} + + $event = $await $action->wait(timeout: 10); + $detect_result = $event->params["detect"] ?? {}; + echo "Detected: {$detect_result}"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/detect-action/stop.mdx b/fern/products/sdks/pages/reference/php/relay/actions/detect-action/stop.mdx new file mode 100644 index 000000000..75c139ab1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/detect-action/stop.mdx @@ -0,0 +1,42 @@ +--- +title: "stop" +slug: /reference/php/relay/actions/detect-action/stop +description: Stop detection immediately. +max-toc-depth: 3 +--- + +Stop detection immediately. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {18} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->detect( + ["type" => "machine", "params": {"initial_timeout": 5.0]} + ); +} + + // Stop detection early + $action->stop(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/fax-action/index.mdx b/fern/products/sdks/pages/reference/php/relay/actions/fax-action/index.mdx new file mode 100644 index 000000000..2abf56c88 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/fax-action/index.mdx @@ -0,0 +1,63 @@ +--- +title: "FaxAction" +slug: /reference/php/relay/actions/fax-action +description: Action handle for an active fax send or receive operation. +max-toc-depth: 3 +--- + +[call-send-fax]: /docs/sdks/reference/php/relay/call/send-fax +[call-receive-fax]: /docs/sdks/reference/php/relay/call/receive-fax +[base-action-interface]: /docs/sdks/reference/php/relay/actions +[stop]: /docs/sdks/reference/php/relay/actions/fax-action/stop + +Returned from [`call.send_fax()`][call-send-fax] or +[`call.receive_fax()`][call-receive-fax]. Tracks +an active fax send or receive operation. Terminal states: `finished`, `error`. + +Inherits all properties and methods from the +[base Action interface][base-action-interface] (`control_id`, +`is_done`, `completed`, `result`, `wait()`). + +## **Properties** + +No additional properties beyond the [base Action interface][base-action-interface]. + +## **Methods** + + + + Stop the fax operation. + + + +## **Example** + +```php +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->send_fax( + document: "https://example.com/invoice.pdf", + identity: "+15559876543", + ); +} + + $event = $await $action->wait(); + $fax_info = $event->params["fax"] ?? {}; + echo "Fax pages: {$fax_info['pages'] ?? null}"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/fax-action/stop.mdx b/fern/products/sdks/pages/reference/php/relay/actions/fax-action/stop.mdx new file mode 100644 index 000000000..2bc852931 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/fax-action/stop.mdx @@ -0,0 +1,43 @@ +--- +title: "stop" +slug: /reference/php/relay/actions/fax-action/stop +description: Stop the fax operation. +max-toc-depth: 3 +--- + +Stop the fax operation. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {19} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->send_fax( + document: "https://example.com/invoice.pdf", + identity: "+15559876543", + ); +} + + // Stop the fax operation + $action->stop(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/index.mdx b/fern/products/sdks/pages/reference/php/relay/actions/index.mdx new file mode 100644 index 000000000..3602af5c8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/index.mdx @@ -0,0 +1,173 @@ +--- +title: "Actions" +slug: /reference/php/relay/actions +description: Action classes returned from call control methods. +max-toc-depth: 3 +--- + +[play]: /docs/sdks/reference/php/relay/call/play +[record]: /docs/sdks/reference/php/relay/call/record +[detect]: /docs/sdks/reference/php/relay/call/detect +[call]: /docs/sdks/reference/php/relay/call +[relayevent]: /docs/sdks/reference/php/relay/events +[play-action]: /docs/sdks/reference/php/relay/actions/play-action +[record-action]: /docs/sdks/reference/php/relay/actions/record-action +[collect-action]: /docs/sdks/reference/php/relay/actions/collect-action +[detect-action]: /docs/sdks/reference/php/relay/actions/detect-action +[standalone-collect-action]: /docs/sdks/reference/php/relay/actions/standalone-collect-action +[fax-action]: /docs/sdks/reference/php/relay/actions/fax-action +[tap-action]: /docs/sdks/reference/php/relay/actions/tap-action +[stream-action]: /docs/sdks/reference/php/relay/actions/stream-action +[pay-action]: /docs/sdks/reference/php/relay/actions/pay-action +[transcribe-action]: /docs/sdks/reference/php/relay/actions/transcribe-action +[ai-action]: /docs/sdks/reference/php/relay/actions/ai-action +[ref-playaction]: /docs/sdks/reference/php/relay/actions/play-action + +Action objects are returned from call control methods like +[`play()`][play], +[`record()`][record], and +[`detect()`][detect]. They provide a common +interface for tracking and controlling in-progress operations on a +[`Call`][call]. + +All action classes extend a shared base that provides `is_done`, `completed`, +`result`, `control_id`, and the `wait()` method. Specific action types add +methods relevant to their operation (e.g., `pause()` and `resume()` on +[`PlayAction`][ref-playaction]). + +```php +onCall() +function onCall($call) +{ + $call->answer(); + $play_action = $await $call->play([["type" => "tts", "text": "Hello!"]]); +} + + // Control the in-progress operation + $play_action->pause(); + $play_action->resume(); + + // Wait for completion + $event = $await $play_action->wait(); + +$client->run(); + + +``` + +## Action (Base Interface) + +All action classes share these properties and methods. + +### Properties + + + Unique identifier for this operation, used to correlate commands and events. + + + + `True` if the underlying future has resolved (the operation has reached a terminal state). + + + + `True` once the action has finished and the terminal event has been processed. + + + + The terminal [`RelayEvent`][relayevent] for this action, + or `null` if the action has not yet completed. + + +### Methods + +#### wait + +**wait**(`timeout=null`) -> [`RelayEvent`][relayevent] + +Block until the action completes and return the terminal event. + + + Maximum seconds to wait. `null` waits indefinitely. Raises `asyncio.TimeoutError` + if exceeded. + + +## Subclasses + + + + Tracks audio playback. Supports pause, resume, volume, and stop. + + + Tracks recording. Supports pause, resume, and stop. + + + Tracks play-and-collect. Supports stop, volume, and input timers. + + + Tracks detection (answering machine, fax, digits). Stop only. + + + Tracks standalone input collection. Stop and input timers. + + + Tracks fax send/receive. Stop only. + + + Tracks media interception. Stop only. + + + Tracks audio streaming to WebSocket. Stop only. + + + Tracks payment collection. Stop only. + + + Tracks transcription. Stop only. + + + Tracks an AI agent session. Stop only. + + diff --git a/fern/products/sdks/pages/reference/php/relay/actions/pay-action/index.mdx b/fern/products/sdks/pages/reference/php/relay/actions/pay-action/index.mdx new file mode 100644 index 000000000..b5cd6e36a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/pay-action/index.mdx @@ -0,0 +1,61 @@ +--- +title: "PayAction" +slug: /reference/php/relay/actions/pay-action +description: Action handle for an active payment collection operation. +max-toc-depth: 3 +--- + +[call-pay]: /docs/sdks/reference/php/relay/call/pay +[base-action-interface]: /docs/sdks/reference/php/relay/actions +[stop]: /docs/sdks/reference/php/relay/actions/pay-action/stop + +Returned from [`call.pay()`][call-pay]. Tracks +an active payment collection operation. Terminal states: `finished`, `error`. + +Inherits all properties and methods from the +[base Action interface][base-action-interface] (`control_id`, +`is_done`, `completed`, `result`, `wait()`). + +## **Properties** + +No additional properties beyond the [base Action interface][base-action-interface]. + +## **Methods** + + + + Stop payment collection. + + + +## **Example** + +```php +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->pay( + payment_connector_url: "https://example.com/payment-connector", + charge_amount: "29.99", + currency: "USD", + ); +} + + $event = $await $action->wait(); + echo "Payment state: {$event->params.get('state')}"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/pay-action/stop.mdx b/fern/products/sdks/pages/reference/php/relay/actions/pay-action/stop.mdx new file mode 100644 index 000000000..9bd3f4581 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/pay-action/stop.mdx @@ -0,0 +1,44 @@ +--- +title: "stop" +slug: /reference/php/relay/actions/pay-action/stop +description: Stop payment collection. +max-toc-depth: 3 +--- + +Stop payment collection. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {20} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->pay( + payment_connector_url: "https://example.com/payment-connector", + charge_amount: "29.99", + currency: "USD", + ); +} + + // Stop payment collection + $action->stop(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/play-action/index.mdx b/fern/products/sdks/pages/reference/php/relay/actions/play-action/index.mdx new file mode 100644 index 000000000..6c97d6cce --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/play-action/index.mdx @@ -0,0 +1,80 @@ +--- +title: "PlayAction" +slug: /reference/php/relay/actions/play-action +description: Action handle for an active audio playback operation. +max-toc-depth: 3 +--- + +[call-play]: /docs/sdks/reference/php/relay/call/play +[base-action-interface]: /docs/sdks/reference/php/relay/actions +[stop]: /docs/sdks/reference/php/relay/actions/play-action/stop +[pause]: /docs/sdks/reference/php/relay/actions/play-action/pause +[resume]: /docs/sdks/reference/php/relay/actions/play-action/resume +[volume]: /docs/sdks/reference/php/relay/actions/play-action/volume + +Returned from [`call.play()`][call-play]. Tracks +an active audio playback operation. Terminal states: `finished`, `error`. + +Inherits all properties and methods from the +[base Action interface][base-action-interface] (`control_id`, +`is_done`, `completed`, `result`, `wait()`). + +## **Properties** + +No additional properties beyond the [base Action interface][base-action-interface]. + +## **Methods** + + + + Stop audio playback immediately. + + + Pause audio playback. + + + Resume paused audio playback. + + + Adjust audio playback volume. + + + +## **Example** + +```php +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->play( + [["type" => "audio", "url": "https://example.com/hold-music.mp3"]], + volume: -5.0, + loop: 0, + ); +} + + // Pause and resume playback + $action->pause(); + $action->resume(); + + // Adjust volume + $action->volume(10.0); + + // Stop playback + $action->stop(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/play-action/pause.mdx b/fern/products/sdks/pages/reference/php/relay/actions/play-action/pause.mdx new file mode 100644 index 000000000..c7e9e38fb --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/play-action/pause.mdx @@ -0,0 +1,44 @@ +--- +title: "pause" +slug: /reference/php/relay/actions/play-action/pause +description: Pause audio playback. +max-toc-depth: 3 +--- + +Pause audio playback. The playback position is preserved. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {18} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->play( + [["type" => "audio", "url": "https://example.com/hold-music.mp3"]], + loop: 0, + ); +} + + $action->pause(); + // ... do something ... + $action->resume(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/play-action/resume.mdx b/fern/products/sdks/pages/reference/php/relay/actions/play-action/resume.mdx new file mode 100644 index 000000000..9d7277136 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/play-action/resume.mdx @@ -0,0 +1,44 @@ +--- +title: "resume" +slug: /reference/php/relay/actions/play-action/resume +description: Resume paused audio playback. +max-toc-depth: 3 +--- + +Resume paused playback from where it was paused. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {20} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->play( + [["type" => "audio", "url": "https://example.com/hold-music.mp3"]], + loop: 0, + ); +} + + $action->pause(); + // ... do something ... + $action->resume(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/play-action/stop.mdx b/fern/products/sdks/pages/reference/php/relay/actions/play-action/stop.mdx new file mode 100644 index 000000000..4fc37e89d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/play-action/stop.mdx @@ -0,0 +1,40 @@ +--- +title: "stop" +slug: /reference/php/relay/actions/play-action/stop +description: Stop audio playback immediately. +max-toc-depth: 3 +--- + +Stop playback immediately. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {16} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->play([["type" => "tts", "text": "Hello!"]]); +} + + // Stop playback early + $action->stop(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/play-action/volume.mdx b/fern/products/sdks/pages/reference/php/relay/actions/play-action/volume.mdx new file mode 100644 index 000000000..957fcaf22 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/play-action/volume.mdx @@ -0,0 +1,52 @@ +--- +title: "volume" +slug: /reference/php/relay/actions/play-action/volume +description: Adjust audio playback volume. +max-toc-depth: 3 +--- + +Adjust the playback volume. + +## **Parameters** + + + Volume adjustment in dB. Range: `-40.0` to `40.0`. + + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {19,22} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->play( + [["type" => "audio", "url": "https://example.com/hold-music.mp3"]], + loop: 0, + ); +} + + // Increase volume + $action->volume(10.0); + + // Decrease volume + $action->volume(-5.0); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/record-action/index.mdx b/fern/products/sdks/pages/reference/php/relay/actions/record-action/index.mdx new file mode 100644 index 000000000..77c9a6aa7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/record-action/index.mdx @@ -0,0 +1,71 @@ +--- +title: "RecordAction" +slug: /reference/php/relay/actions/record-action +description: Action handle for an active recording operation. +max-toc-depth: 3 +--- + +[call-record]: /docs/sdks/reference/php/relay/call/record +[base-action-interface]: /docs/sdks/reference/php/relay/actions +[stop]: /docs/sdks/reference/php/relay/actions/record-action/stop +[pause]: /docs/sdks/reference/php/relay/actions/record-action/pause +[resume]: /docs/sdks/reference/php/relay/actions/record-action/resume + +Returned from [`call.record()`][call-record]. Tracks +an active recording operation. Terminal states: `finished`, `no_input`. + +Inherits all properties and methods from the +[base Action interface][base-action-interface] (`control_id`, +`is_done`, `completed`, `result`, `wait()`). + +## **Properties** + +No additional properties beyond the [base Action interface][base-action-interface]. + +## **Methods** + + + + Stop recording immediately. + + + Pause an active recording. + + + Resume a paused recording. + + + +## **Example** + +```php +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->record(audio: ["direction" => "both", "format": "wav"]); +} + + // Pause during sensitive information + $action->pause(); + // ... sensitive exchange ... + $action->resume(); + + // Wait for the recording to complete + $event = $await $action->wait(); + echo "Recording URL: {$event->params["$record"] ?? {}.get('url')}"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/record-action/pause.mdx b/fern/products/sdks/pages/reference/php/relay/actions/record-action/pause.mdx new file mode 100644 index 000000000..8431c4d70 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/record-action/pause.mdx @@ -0,0 +1,49 @@ +--- +title: "pause" +slug: /reference/php/relay/actions/record-action/pause +description: Pause an active recording. +max-toc-depth: 3 +--- + +Pause the recording. + +## **Parameters** + + + Optional pause behavior. Controls what happens to the audio stream while paused + (e.g., silence insertion). + + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {16} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->record(["direction" => "both", "format": "wav"]); +} + + // Pause during sensitive information + $action->pause(); + // ... sensitive exchange ... + $action->resume(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/record-action/resume.mdx b/fern/products/sdks/pages/reference/php/relay/actions/record-action/resume.mdx new file mode 100644 index 000000000..621915878 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/record-action/resume.mdx @@ -0,0 +1,44 @@ +--- +title: "resume" +slug: /reference/php/relay/actions/record-action/resume +description: Resume a paused recording. +max-toc-depth: 3 +--- + +Resume a paused recording. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {17} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->record(audio: ["direction" => "both", "format": "wav"]); +} + + $action->pause(); + // ... sensitive exchange ... + $action->resume(); + + $event = $await $action->wait(); + echo "Recording URL: {$event->params["$record"] ?? {}.get('url')}"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/record-action/stop.mdx b/fern/products/sdks/pages/reference/php/relay/actions/record-action/stop.mdx new file mode 100644 index 000000000..59662d504 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/record-action/stop.mdx @@ -0,0 +1,40 @@ +--- +title: "stop" +slug: /reference/php/relay/actions/record-action/stop +description: Stop recording immediately. +max-toc-depth: 3 +--- + +Stop recording immediately. The recording file becomes available. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {16} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->record(audio: ["direction" => "both", "format": "wav"]); +} + + // Stop recording early + $action->stop(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/standalone-collect-action/index.mdx b/fern/products/sdks/pages/reference/php/relay/actions/standalone-collect-action/index.mdx new file mode 100644 index 000000000..09658205f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/standalone-collect-action/index.mdx @@ -0,0 +1,66 @@ +--- +title: "StandaloneCollectAction" +slug: /reference/php/relay/actions/standalone-collect-action +description: Action handle for a standalone input collection operation. +max-toc-depth: 3 +--- + +[call-collect]: /docs/sdks/reference/php/relay/call/collect +[base-action-interface]: /docs/sdks/reference/php/relay/actions +[stop]: /docs/sdks/reference/php/relay/actions/standalone-collect-action/stop +[startinputtimers]: /docs/sdks/reference/php/relay/actions/standalone-collect-action/start-input-timers + +Returned from [`call.collect()`][call-collect]. +Tracks a standalone input collection (without an accompanying play prompt). +Terminal states: `finished`, `error`, `no_input`, `no_match`. + +Inherits all properties and methods from the +[base Action interface][base-action-interface] (`control_id`, +`is_done`, `completed`, `result`, `wait()`). + +## **Properties** + +No additional properties beyond the [base Action interface][base-action-interface]. + +## **Methods** + + + + Stop the collect operation. + + + Manually start the initial_timeout timer on an active collect. + + + +## **Example** + +```php +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->collect( + speech: ["end_silence_timeout" => 2.0], + initial_timeout: 10.0, + start_input_timers: false, + ); +} + + $event = $await $action->wait(); + $result = $event->params["result"] ?? {}; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/standalone-collect-action/start-input-timers.mdx b/fern/products/sdks/pages/reference/php/relay/actions/standalone-collect-action/start-input-timers.mdx new file mode 100644 index 000000000..3ef8a6440 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/standalone-collect-action/start-input-timers.mdx @@ -0,0 +1,47 @@ +--- +title: "startInputTimers" +slug: /reference/php/relay/actions/standalone-collect-action/start-input-timers +description: Manually start the initial_timeout timer on an active collect. +max-toc-depth: 3 +--- + +Manually start the `initial_timeout` timer on the active collect operation. Useful +when `startInputTimers` was set to `false` during the initial call. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {20} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->collect( + speech: ["end_silence_timeout" => 2.0], + initial_timeout: 10.0, + start_input_timers: false, + ); +} + + // Start timers when ready + $action->startInputTimers(); + + $event = $await $action->wait(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/standalone-collect-action/stop.mdx b/fern/products/sdks/pages/reference/php/relay/actions/standalone-collect-action/stop.mdx new file mode 100644 index 000000000..0d29c5a42 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/standalone-collect-action/stop.mdx @@ -0,0 +1,44 @@ +--- +title: "stop" +slug: /reference/php/relay/actions/standalone-collect-action/stop +description: Stop the collect operation. +max-toc-depth: 3 +--- + +Stop the collect operation. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {20} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->collect( + speech: ["end_silence_timeout" => 2.0], + initial_timeout: 10.0, + start_input_timers: false, + ); +} + + // Stop the collect operation + $action->stop(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/stream-action/index.mdx b/fern/products/sdks/pages/reference/php/relay/actions/stream-action/index.mdx new file mode 100644 index 000000000..96e026bac --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/stream-action/index.mdx @@ -0,0 +1,59 @@ +--- +title: "StreamAction" +slug: /reference/php/relay/actions/stream-action +description: Action handle for an active audio stream operation. +max-toc-depth: 3 +--- + +[call-stream]: /docs/sdks/reference/php/relay/call/stream +[base-action-interface]: /docs/sdks/reference/php/relay/actions +[stop]: /docs/sdks/reference/php/relay/actions/stream-action/stop + +Returned from [`call.stream()`][call-stream]. Tracks +an active audio stream to a WebSocket endpoint. Terminal state: `finished`. + +Inherits all properties and methods from the +[base Action interface][base-action-interface] (`control_id`, +`is_done`, `completed`, `result`, `wait()`). + +## **Properties** + +No additional properties beyond the [base Action interface][base-action-interface]. + +## **Methods** + + + + Stop audio streaming. + + + +## **Example** + +```php +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->stream( + url: "wss://example.com/audio-stream", + track: "inbound", + ); +} + + $event = $await $action->wait(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/stream-action/stop.mdx b/fern/products/sdks/pages/reference/php/relay/actions/stream-action/stop.mdx new file mode 100644 index 000000000..3e9dfc6f0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/stream-action/stop.mdx @@ -0,0 +1,43 @@ +--- +title: "stop" +slug: /reference/php/relay/actions/stream-action/stop +description: Stop audio streaming. +max-toc-depth: 3 +--- + +Stop audio streaming. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {19} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->stream( + url: "wss://example.com/audio-stream", + track: "inbound", + ); +} + + // Stop the stream when done + $action->stop(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/tap-action/index.mdx b/fern/products/sdks/pages/reference/php/relay/actions/tap-action/index.mdx new file mode 100644 index 000000000..77feb24a3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/tap-action/index.mdx @@ -0,0 +1,59 @@ +--- +title: "TapAction" +slug: /reference/php/relay/actions/tap-action +description: Action handle for an active media tap operation. +max-toc-depth: 3 +--- + +[call-tap]: /docs/sdks/reference/php/relay/call/tap +[base-action-interface]: /docs/sdks/reference/php/relay/actions +[stop]: /docs/sdks/reference/php/relay/actions/tap-action/stop + +Returned from [`call.tap()`][call-tap]. Tracks +an active media tap (audio interception) operation. Terminal state: `finished`. + +Inherits all properties and methods from the +[base Action interface][base-action-interface] (`control_id`, +`is_done`, `completed`, `result`, `wait()`). + +## **Properties** + +No additional properties beyond the [base Action interface][base-action-interface]. + +## **Methods** + + + + Stop media interception. + + + +## **Example** + +```php +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->tap( + tap: ["type" => "audio", "params": {"direction": "both"]}, + device: ["type" => "ws", "params": {"uri": "wss://example.com/tap"]}, + ); +} + + $event = $await $action->wait(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/tap-action/stop.mdx b/fern/products/sdks/pages/reference/php/relay/actions/tap-action/stop.mdx new file mode 100644 index 000000000..d7613164d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/tap-action/stop.mdx @@ -0,0 +1,43 @@ +--- +title: "stop" +slug: /reference/php/relay/actions/tap-action/stop +description: Stop media interception. +max-toc-depth: 3 +--- + +Stop media interception. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {19} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->tap( + tap: ["type" => "audio", "params": {"direction": "both"]}, + device: ["type" => "ws", "params": {"uri": "wss://example.com/tap"]}, + ); +} + + // Stop the tap when done + $action->stop(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/transcribe-action/index.mdx b/fern/products/sdks/pages/reference/php/relay/actions/transcribe-action/index.mdx new file mode 100644 index 000000000..1fd7e457a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/transcribe-action/index.mdx @@ -0,0 +1,56 @@ +--- +title: "TranscribeAction" +slug: /reference/php/relay/actions/transcribe-action +description: Action handle for an active transcription operation. +max-toc-depth: 3 +--- + +[call-transcribe]: /docs/sdks/reference/php/relay/call/transcribe +[base-action-interface]: /docs/sdks/reference/php/relay/actions +[stop]: /docs/sdks/reference/php/relay/actions/transcribe-action/stop + +Returned from [`call.transcribe()`][call-transcribe]. +Tracks an active transcription operation. Terminal state: `finished`. + +Inherits all properties and methods from the +[base Action interface][base-action-interface] (`control_id`, +`is_done`, `completed`, `result`, `wait()`). + +## **Properties** + +No additional properties beyond the [base Action interface][base-action-interface]. + +## **Methods** + + + + Stop transcription. + + + +## **Example** + +```php +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->transcribe(); +} + + $event = $await $action->wait(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/actions/transcribe-action/stop.mdx b/fern/products/sdks/pages/reference/php/relay/actions/transcribe-action/stop.mdx new file mode 100644 index 000000000..cd4afbc8f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/actions/transcribe-action/stop.mdx @@ -0,0 +1,40 @@ +--- +title: "stop" +slug: /reference/php/relay/actions/transcribe-action/stop +description: Stop transcription. +max-toc-depth: 3 +--- + +Stop transcription. + +## **Returns** + +`dict` -- Server acknowledgment. + +## **Example** + +```php {16} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->transcribe(); +} + + // Stop transcription early + $action->stop(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/ai-hold.mdx b/fern/products/sdks/pages/reference/php/relay/call/ai-hold.mdx new file mode 100644 index 000000000..109fd4948 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/ai-hold.mdx @@ -0,0 +1,68 @@ +--- +title: "aiHold" +slug: /reference/php/relay/call/ai-hold +description: Put an AI agent session on hold. +max-toc-depth: 3 +--- + +[ai-unhold]: /docs/sdks/reference/php/relay/call/ai-unhold + +Put an active AI agent session on hold. The AI stops processing conversation +while the call remains active. The caller may hear hold music or silence +depending on the configuration. + + +Use [`ai_unhold()`][ai-unhold] to resume the AI session. + + +## **Parameters** + + + Maximum hold duration. The AI session automatically resumes after this timeout. + + + + A prompt for the AI to speak before going on hold (e.g., "Please hold + while I check on that."). + + +## **Returns** + +`dict` -- Server response confirming the AI hold. + +## **Example** + +```php {20} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Start an AI agent + $action = $await $call->ai( + prompt: ["text" => "You are a support agent."], + ); + + // After some event, put the AI on hold + $call->ai_hold( + prompt: "One moment please while I look that up.", + timeout: "30", + ); + + // Do some processing, then resume with ai_unhold() + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/ai-message.mdx b/fern/products/sdks/pages/reference/php/relay/call/ai-message.mdx new file mode 100644 index 000000000..50556c4a5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/ai-message.mdx @@ -0,0 +1,82 @@ +--- +title: "aiMessage" +slug: /reference/php/relay/call/ai-message +description: "Send a message to an active AI agent session." +max-toc-depth: 3 +--- + +[ai]: /docs/sdks/reference/php/relay/call/ai + +Send a message to an active AI agent session on the call. Use this to inject +context, instructions, or simulated user input into a running AI conversation. + + +This method requires an active AI session started via +[`ai()`][ai]. Calling it without +an active session has no effect. + + +## **Parameters** + + + The message text to send to the AI agent. + + + + The role of the message sender. Valid values: + - `"user"` -- simulate user input + - `"system"` -- send a system-level instruction + - `"assistant"` -- inject an assistant response + + + + Reset configuration. Allows resetting AI state such as the conversation + history or functions. + + + + Update the global data accessible to the AI and SWAIG functions. + + +## **Returns** + +`dict` -- Server response confirming the message was sent. + +## **Example** + +```php {22} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Start an AI agent + $action = $await $call->ai( + prompt: ["text" => "You are a helpful assistant."], + ); + + // Inject a system message after 10 seconds + $asyncio->sleep(10); + $call->ai_message( + message_text: "The caller is a VIP customer. Be extra helpful.", + role: "system", + ); + + $action->wait(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/ai-unhold.mdx b/fern/products/sdks/pages/reference/php/relay/call/ai-unhold.mdx new file mode 100644 index 000000000..3b19878dc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/ai-unhold.mdx @@ -0,0 +1,59 @@ +--- +title: "aiUnhold" +slug: /reference/php/relay/call/ai-unhold +description: Resume an AI agent session from hold. +max-toc-depth: 3 +--- + +Resume an AI agent session from hold. The AI resumes processing the +conversation. + +## **Parameters** + + + A prompt for the AI to speak upon resuming (e.g., "Thank you for holding. + I have your information now."). + + +## **Returns** + +`dict` -- Server response confirming the AI unhold. + +## **Example** + +```php {27} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Start an AI agent + $action = $await $call->ai( + prompt: ["text" => "You are a support agent."], + ); + + // Put the AI on hold + $call->ai_hold(prompt: "One moment please."); + + // Do some processing... + $asyncio->sleep(5); + + // Resume the AI + $call->ai_unhold(prompt: "Thanks for waiting. I found your information."); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/ai.mdx b/fern/products/sdks/pages/reference/php/relay/call/ai.mdx new file mode 100644 index 000000000..fc1b84bab --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/ai.mdx @@ -0,0 +1,154 @@ +--- +title: "ai" +slug: /reference/php/relay/call/ai +description: Start an AI agent session on a call. +max-toc-depth: 3 +--- + +[aiaction]: /docs/sdks/reference/php/relay/actions +[agentbase]: /docs/sdks/reference/php/agents/agent-base +[amazon-bedrock]: /docs/sdks/reference/php/relay/call/amazon-bedrock +[ai]: /docs/swml/reference/ai +[swml-ai-reference]: /docs/swml/reference/ai + +Start an AI agent session on the call. The AI agent handles the conversation +using the provided prompt, tools, and configuration. Returns an +[`AIAction`][aiaction] that you can use to stop +the AI session or wait for it to complete. + + +For building AI agents with the full framework (prompts, tools, skills, contexts), +use [`AgentBase`][agentbase]. The `ai()` method +is for lower-level RELAY control where you configure the AI inline. + + + +See also [`amazon_bedrock()`][amazon-bedrock] for using Amazon Bedrock as the LLM backend. + + + +This method executes the SWML [`ai`][ai] verb on the call. See the +[SWML AI reference][swml-ai-reference] for the full specification of all supported +parameters and behaviors. + + +## **Parameters** + + + Custom control ID. Auto-generated if not provided. + + + + Fabric agent resource ID. When set, the AI uses a pre-configured agent + from SignalWire Fabric instead of inline configuration. + + + + The main prompt configuration. + + + + + The system prompt text that defines the AI agent's behavior. + + + + LLM temperature for the main prompt. + + + + LLM top_p sampling parameter. + + + + + Post-prompt configuration for summarization or analysis after the + conversation ends. + + + + + The post-prompt text. + + + + + URL to receive the post-prompt result via webhook. + + + + Username for basic auth on the post-prompt webhook. + + + + Password for basic auth on the post-prompt webhook. + + + + Data accessible to the AI agent and SWAIG functions throughout the session. + + + + Pronunciation rules for words or phrases the TTS engine should handle + specially. + + + + Speech recognition hints to improve accuracy for domain-specific terms. + + + + Language configurations for multilingual support. + + + + SWAIG (SignalWire AI Gateway) configuration for tool/function definitions. + + + + Additional AI parameters such as `barge_confidence`, `end_of_speech_timeout`, + `attention_timeout`, and other LLM tuning settings. + + + + Callback invoked when the AI session ends. + + +## **Returns** + +[`AIAction`][aiaction] -- An action handle with `stop()` and `wait()` methods. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Start an AI agent on the call + $action = $await $call->ai( + prompt: ["text" => "You are a helpful customer support agent for Acme Corp."], + hints: ["Acme", "support", "billing"], + ai_params: ["barge_confidence" => 0.02], + ); + + // Wait for the AI session to end (caller hangs up or AI stops) + $action->wait(); + echo "AI session ended"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/amazon-bedrock.mdx b/fern/products/sdks/pages/reference/php/relay/call/amazon-bedrock.mdx new file mode 100644 index 000000000..49b8985e4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/amazon-bedrock.mdx @@ -0,0 +1,72 @@ +--- +title: "amazonBedrock" +slug: /reference/php/relay/call/amazon-bedrock +description: Connect a call to an Amazon Bedrock AI agent. +max-toc-depth: 3 +--- + +[ai]: /docs/sdks/reference/php/relay/call/ai + +Connect the call to an Amazon Bedrock AI agent. Similar to +[`ai()`][ai] but uses Amazon Bedrock as +the LLM backend. + +## **Parameters** + + + The prompt configuration for the Bedrock agent. + + + + SWAIG configuration for tool/function definitions. + + + + AI parameters for the Bedrock session. + + + + Data accessible to the AI and SWAIG functions. + + + + Post-prompt configuration. + + + + URL to receive the post-prompt result. + + +## **Returns** + +`dict` -- Server response confirming the Bedrock session. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Start an Amazon Bedrock AI agent + $result = $await $call->amazon_bedrock( + prompt: ["text" => "You are a helpful assistant."], + ai_params: ["barge_confidence" => 0.02], + ); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/answer.mdx b/fern/products/sdks/pages/reference/php/relay/call/answer.mdx new file mode 100644 index 000000000..c4a09360b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/answer.mdx @@ -0,0 +1,52 @@ +--- +title: "answer" +slug: /reference/php/relay/call/answer +description: "Answer an inbound RELAY call." +max-toc-depth: 3 +--- + +[client-dial]: /docs/sdks/reference/php/relay/client/dial +[ref-call]: /docs/sdks/reference/php/relay/call + +Answer an inbound call. This must be called before performing any media +operations on the call. For outbound calls created via +[`client.dial()`][client-dial], +the call is already answered when the [`Call`][ref-call] object is returned. + + +Calling `answer()` on an already-answered call is safe and returns the server +response without error. + + +## **Parameters** + +Additional keyword arguments are forwarded to the RELAY `calling.answer` request. + +## **Returns** + +`dict` -- Server response confirming the answer operation. + +## **Example** + +```php {12} +onCall() +function handleCall($call) +{ + $result = $await $call->answer(); + echo "Answered call {$call->call_id}: {$result}"; +} + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/bind-digit.mdx b/fern/products/sdks/pages/reference/php/relay/call/bind-digit.mdx new file mode 100644 index 000000000..cea391f4f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/bind-digit.mdx @@ -0,0 +1,86 @@ +--- +title: "bindDigit" +slug: /reference/php/relay/call/bind-digit +description: Bind a DTMF digit sequence to trigger a RELAY method. +max-toc-depth: 3 +--- + +[clear-digit-bindings]: /docs/sdks/reference/php/relay/call/clear-digit-bindings + +Bind a DTMF digit sequence to automatically trigger a RELAY method when the +caller presses those digits. This enables in-call DTMF shortcuts without +requiring an active collect operation. + + +Use [`clear_digit_bindings()`][clear-digit-bindings] to remove bindings. + + +## **Parameters** + + + The DTMF digit sequence to bind (e.g., `"*1"`, `"##"`). + + + + The RELAY calling method to execute when the digit sequence is detected + (e.g., `"calling.transfer"`, `"calling.play"`). + + + + Parameters to pass to the bound method when triggered. + + + + A namespace for grouping digit bindings. Useful for selectively clearing + bindings by realm. + + + + Maximum number of times this binding can be triggered. After reaching + the limit, the binding is automatically removed. + + +## **Returns** + +`dict` -- Server response confirming the binding. + +## **Example** + +```php {15,24} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Bind *0 to transfer to an operator + $result = $await $call->bind_digit( + digits: "*0", + bind_method: "calling.transfer", + bind_params: ["dest" => "operator"], + realm: "shortcuts", + ); + echo "Digit binding created: {$result}"; + + // Bind *9 to play a help message + $call->bind_digit( + digits: "*9", + bind_method: "calling.play", + bind_params: ["play" => [{"type": "tts", "text": "Press star-zero for an operator."]]}, + realm: "shortcuts", + ); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/clear-digit-bindings.mdx b/fern/products/sdks/pages/reference/php/relay/call/clear-digit-bindings.mdx new file mode 100644 index 000000000..e3992ca89 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/clear-digit-bindings.mdx @@ -0,0 +1,55 @@ +--- +title: "clearDigitBindings" +slug: /reference/php/relay/call/clear-digit-bindings +description: Clear DTMF digit bindings on a call. +max-toc-depth: 3 +--- + +Clear all digit bindings, optionally filtered by realm. + +## **Parameters** + + + If provided, only clear bindings in this realm. If omitted, all bindings + are cleared. + + +## **Returns** + +`dict` -- Server response confirming the bindings were cleared. + +## **Example** + +```php {23} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Bind some digit shortcuts + $call->bind_digit( + digits: "*0", + bind_method: "calling.transfer", + bind_params: ["dest" => "operator"], + realm: "shortcuts", + ); + + // Later, remove all shortcut bindings + $result = $await $call->clear_digit_bindings(realm: "shortcuts"); + echo "Bindings cleared: {$result}"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/collect.mdx b/fern/products/sdks/pages/reference/php/relay/call/collect.mdx new file mode 100644 index 000000000..e721cbe5d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/collect.mdx @@ -0,0 +1,131 @@ +--- +title: "collect" +slug: /reference/php/relay/call/collect +description: "Collect DTMF or speech input without playing media." +max-toc-depth: 3 +--- + +[play-and-collect]: /docs/sdks/reference/php/relay/call/play-and-collect +[calling-call-collect]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events +[standalonecollectaction]: /docs/sdks/reference/php/relay/actions + +Collect DTMF digit or speech input without playing a prompt. Use this when you +want to listen for input silently or after a prompt has already been played +separately. For collecting input with a prompt, use +[`playAndCollect()`][play-and-collect]. + + +This method emits [`calling.call.collect`][calling-call-collect] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + + + DTMF digit collection settings. + + + + + Maximum number of digits to collect. + + + + Seconds to wait between digits before completing. + + + + Characters that terminate digit collection (e.g., `"#"`). + + + + + Speech recognition settings. + + + + + Seconds of silence to wait before finalizing speech input. + + + + Maximum seconds to listen for speech. + + + + Speech recognition language code (e.g., `"en-US"`). + + + + Words or phrases to boost recognition accuracy. + + + + + Seconds to wait for the first input before ending with `no_input`. + + + + Enable partial speech recognition results. + + + + Keep collecting after each result instead of stopping. + + + + Send an event when input is first detected. + + + + Start input timers immediately. If `false`, call + `action.startInputTimers()` to start them manually. + + + + Custom control ID. Auto-generated if not provided. + + + + Callback invoked when collection completes. + + +## **Returns** + +[`StandaloneCollectAction`][standalonecollectaction] -- An action +handle with `stop()`, `startInputTimers()`, and `wait()` methods. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Collect digits silently (e.g., extension entry) + $action = $await $call->collect( + digits: ["max" => 4, "digit_timeout": 3, "terminators": "#"], + initial_timeout: 10, + ); + $event = $await $action->wait(); + + $result = $event->params["result"] ?? {}; + $extension = $result["digits"] ?? ""; + echo "Extension entered: {$extension}"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/connect.mdx b/fern/products/sdks/pages/reference/php/relay/call/connect.mdx new file mode 100644 index 000000000..bf1805857 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/connect.mdx @@ -0,0 +1,94 @@ +--- +title: "connect" +slug: /reference/php/relay/call/connect +description: "Bridge a call to one or more destinations." +max-toc-depth: 3 +--- + +[calling-call-connect]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events +[connect]: /docs/swml/reference/connect +[swml-connect-reference]: /docs/swml/reference/connect +[play]: /docs/sdks/reference/php/relay/call/play + +Bridge the call to one or more destinations. The `devices` parameter supports +both serial (try one at a time) and parallel (ring simultaneously) dialing +strategies. + + +This method emits [`calling.call.connect`][calling-call-connect] events. See [Call Events][call-events] for payload details. + + + +This method corresponds to the SWML [`connect`][connect] verb. See the +[SWML connect reference][swml-connect-reference] for the full specification. + + +## **Parameters** + + + A list of device groups for serial/parallel dialing. The outer list is tried + serially (one group at a time). Each inner list is dialed in parallel + (all devices in the group ring simultaneously). + + Each device dict contains: + - `"type"` -- Device type (`"phone"`, `"sip"`) + - `"params"` -- Type-specific parameters (`to_number`, `from_number`, etc.) + + + + Media items to play to the caller while the destination is ringing. Same + format as [`play()`][play] media items. + + + + Correlation tag for the connected call. + + + + Maximum duration of the connected call in minutes. + + + + Maximum price per minute for the connected call. + + + + URL to receive connection status webhooks. + + +## **Returns** + +`dict` -- Server response confirming the connect operation. + +## **Example** + +```php {16} +onCall() +function handleCall($call) +{ + $call->answer(); + $call->play([["type" => "tts", "text": "Connecting you now..."]]); +} + + // Serial dialing: try first number, then second if no answer + $result = $await $call->connect([ + [["type" => "phone", "params": {"to_number": "+15551234567", "from_number": "+15559876543"]}], + [["type" => "phone", "params": {"to_number": "+15559999999", "from_number": "+15559876543"]}], + ]); + echo "Connect result: {$result}"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/denoise-stop.mdx b/fern/products/sdks/pages/reference/php/relay/call/denoise-stop.mdx new file mode 100644 index 000000000..ab87b35b5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/denoise-stop.mdx @@ -0,0 +1,49 @@ +--- +title: "denoiseStop" +slug: /reference/php/relay/call/denoise-stop +description: Stop noise reduction on a call. +max-toc-depth: 3 +--- + +Stop noise reduction on the call, restoring the original unfiltered audio. + +## **Parameters** + +None. + +## **Returns** + +`dict` -- Server response confirming noise reduction has stopped. + +## **Example** + +```php {20} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Enable noise reduction + $call->denoise(); + + $action = $await $call->play([["type" => "tts", "text": "Noise reduction is now active."]]); + $action->wait(); + + $result = $await $call->denoise_stop(); + echo "Noise reduction stopped: {$result}"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/denoise.mdx b/fern/products/sdks/pages/reference/php/relay/call/denoise.mdx new file mode 100644 index 000000000..67eb2e38d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/denoise.mdx @@ -0,0 +1,59 @@ +--- +title: "denoise" +slug: /reference/php/relay/call/denoise +description: Start noise reduction on a call. +max-toc-depth: 3 +--- + +[denoise-stop]: /docs/sdks/reference/php/relay/call/denoise-stop +[calling-call-denoise]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Start noise reduction on the call. Filters background noise from the audio +to improve clarity. + + +Use [`denoise_stop()`][denoise-stop] to disable noise reduction. + + + +This method emits [`calling.call.denoise`][calling-call-denoise] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + +None. + +## **Returns** + +`dict` -- Server response confirming noise reduction has started. + +## **Example** + +```php {14} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + $result = $await $call->denoise(); + echo "Noise reduction started: {$result}"; + + $action = $await $call->play([["type" => "tts", "text": "Noise reduction is now active."]]); + $action->wait(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/detect.mdx b/fern/products/sdks/pages/reference/php/relay/call/detect.mdx new file mode 100644 index 000000000..cd052d61f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/detect.mdx @@ -0,0 +1,102 @@ +--- +title: "detect" +slug: /reference/php/relay/call/detect +description: "Detect answering machines, fax tones, or digits on a call." +max-toc-depth: 3 +--- + +[detectaction]: /docs/sdks/reference/php/relay/actions +[calling-call-detect]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Start audio detection on the call. Detects answering machines, fax tones, or +DTMF digits. Returns a [`DetectAction`][detectaction] +that resolves on the first detection result or when the operation finishes. + + +The `DetectAction` resolves on the **first detection result**, not when the +detect operation finishes. This means `await action.wait()` returns as soon as +a result is available. + + + +This method emits [`calling.call.detect`][calling-call-detect] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + + + Detection configuration object. + + + + + Detection type. Valid values: + - `"machine"` -- answering machine detection (AMD) + - `"fax"` -- fax tone detection (CNG/CED) + - `"digit"` -- DTMF digit detection + + + + Type-specific detection parameters. + + + + + Maximum seconds to run the detector before stopping. + + + + Custom control ID. Auto-generated if not provided. + + + + Callback invoked when detection completes. + + +## **Returns** + +[`DetectAction`][detectaction] -- An action handle with +`stop()` and `wait()` methods. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Answering machine detection + $action = $await $call->detect( + detect: ["type" => "machine", "params": {]}, + timeout: 30, + ); + $event = $await $action->wait(); + + $detect_result = $event->params["detect"] ?? {}; + if ($detect_result["type"] ?? null == "machine") { + echo "Answering machine detected"; + $call->hangup(); +} + } else { + echo "Human answered"; + $action = $await $call->play([["type" => "tts", "text": "Hello! This is a call from..."]]); + $action->wait(); +} + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/disconnect.mdx b/fern/products/sdks/pages/reference/php/relay/call/disconnect.mdx new file mode 100644 index 000000000..aec3c24b5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/disconnect.mdx @@ -0,0 +1,58 @@ +--- +title: "disconnect" +slug: /reference/php/relay/call/disconnect +description: "Disconnect (unbridge) a connected call." +max-toc-depth: 3 +--- + +[connect]: /docs/sdks/reference/php/relay/call/connect + +Disconnect a previously bridged call, breaking the connection between the two +call legs. Both parties return to their respective RELAY applications for +further processing. Use this after +[`connect()`][connect] to separate +bridged calls. + +## **Parameters** + +None. + +## **Returns** + +`dict` -- Server response confirming the disconnect. + +## **Example** + +```php {20} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Bridge to an agent + $call->connect([; + [["type" => "phone", "params": {"to_number": "+15551234567", "from_number": "+15559876543"]}], + ]); + + // Disconnect (unbridge) the connected call + $result = $await $call->disconnect(); + echo "Disconnected: {$result}"; + + $call->play([["type" => "tts", "text": "The other party has disconnected."]]); + $call->hangup(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/echo.mdx b/fern/products/sdks/pages/reference/php/relay/call/echo.mdx new file mode 100644 index 000000000..dcd1cb21b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/echo.mdx @@ -0,0 +1,63 @@ +--- +title: "echo" +slug: /reference/php/relay/call/echo +description: "Echo call audio back to the caller for testing." +max-toc-depth: 3 +--- + +[calling-call-echo]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Echo audio back to the caller. This is primarily useful for testing audio +quality, latency, and connectivity. The caller hears their own voice repeated +back to them. + + +This method emits [`calling.call.echo`][calling-call-echo] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + + + Maximum duration of the echo in seconds. The echo stops automatically after + this timeout. + + + + URL to receive echo status webhooks. + + +## **Returns** + +`dict` -- Server response confirming the echo operation. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); + $call->play([["type" => "tts", "text": "Starting echo test. You should hear yourself."]]); +} + + $result = $await $call->echo(timeout: 30); + echo "Echo completed: {$result}"; + + $call->play([["type" => "tts", "text": "Echo test complete."]]); + $call->hangup(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/hangup.mdx b/fern/products/sdks/pages/reference/php/relay/call/hangup.mdx new file mode 100644 index 000000000..0bda2932c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/hangup.mdx @@ -0,0 +1,50 @@ +--- +title: "hangup" +slug: /reference/php/relay/call/hangup +description: "End a RELAY call." +max-toc-depth: 3 +--- + +End the call. The call transitions through the `ending` state and then to +`ended`. Any active operations (play, record, etc.) are stopped automatically +when the call ends. + +## **Parameters** + + + The end reason string sent to the server. Valid values: + - `"hangup"` -- normal hangup (default) + - `"cancel"` -- cancel the call + - `"busy"` -- signal busy + - `"decline"` -- decline the call + + +## **Returns** + +`dict` -- Server response confirming the hangup. + +## **Example** + +```php {13} +onCall() +function handleCall($call) +{ + $call->answer(); + $call->hangup(); + echo "Call ended"; +} + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/hold.mdx b/fern/products/sdks/pages/reference/php/relay/call/hold.mdx new file mode 100644 index 000000000..b38cfea9e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/hold.mdx @@ -0,0 +1,64 @@ +--- +title: "hold" +slug: /reference/php/relay/call/hold +description: Put a call on hold. +max-toc-depth: 3 +--- + +[unhold]: /docs/sdks/reference/php/relay/call/unhold +[calling-call-hold]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Put the call on hold. The remote party hears hold music or silence while the +call is held. + + +Use [`unhold()`][unhold] to release the call from hold. + + + +This method emits [`calling.call.hold`][calling-call-hold] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + +None. + +## **Returns** + +`dict` -- Server response confirming the hold operation. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); + $call->play([["type" => "tts", "text": "Please hold while I look that up."]]); +} + + $result = $await $call->hold(); + echo "Hold started: {$result}"; + + // Do some processing... + $asyncio->sleep(5); + + // Take the call off hold + $call->unhold(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/index.mdx b/fern/products/sdks/pages/reference/php/relay/call/index.mdx new file mode 100644 index 000000000..575804c0b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/index.mdx @@ -0,0 +1,280 @@ +--- +title: "Call" +slug: /reference/php/relay/call +description: "Live call control object with media, AI, and event methods." +max-toc-depth: 3 +--- + +[relayclient]: /docs/sdks/reference/php/relay/client +[action]: /docs/sdks/reference/php/relay/actions +[events]: /docs/sdks/reference/php/relay/events#calling-events +[call-on]: /docs/sdks/reference/php/relay/call/on +[on]: /docs/sdks/reference/php/relay/call/on +[answer]: /docs/sdks/reference/php/relay/call/answer +[hangup]: /docs/sdks/reference/php/relay/call/hangup +[pass]: /docs/sdks/reference/php/relay/call/pass +[disconnect]: /docs/sdks/reference/php/relay/call/disconnect +[transfer]: /docs/sdks/reference/php/relay/call/transfer +[connect]: /docs/sdks/reference/php/relay/call/connect +[hold]: /docs/sdks/reference/php/relay/call/hold +[unhold]: /docs/sdks/reference/php/relay/call/unhold +[play]: /docs/sdks/reference/php/relay/call/play +[record]: /docs/sdks/reference/php/relay/call/record +[playandcollect]: /docs/sdks/reference/php/relay/call/play-and-collect +[collect]: /docs/sdks/reference/php/relay/call/collect +[detect]: /docs/sdks/reference/php/relay/call/detect +[ai]: /docs/sdks/reference/php/relay/call/ai +[amazonbedrock]: /docs/sdks/reference/php/relay/call/amazon-bedrock +[aihold]: /docs/sdks/reference/php/relay/call/ai-hold +[aiunhold]: /docs/sdks/reference/php/relay/call/ai-unhold +[aimessage]: /docs/sdks/reference/php/relay/call/ai-message +[denoise]: /docs/sdks/reference/php/relay/call/denoise +[denoisestop]: /docs/sdks/reference/php/relay/call/denoise-stop +[senddigits]: /docs/sdks/reference/php/relay/call/send-digits +[echo]: /docs/sdks/reference/php/relay/call/echo +[binddigit]: /docs/sdks/reference/php/relay/call/bind-digit +[cleardigitbindings]: /docs/sdks/reference/php/relay/call/clear-digit-bindings +[userevent]: /docs/sdks/reference/php/relay/call/user-event +[refer]: /docs/sdks/reference/php/relay/call/refer +[tap]: /docs/sdks/reference/php/relay/call/tap +[stream]: /docs/sdks/reference/php/relay/call/stream +[sendfax]: /docs/sdks/reference/php/relay/call/send-fax +[receivefax]: /docs/sdks/reference/php/relay/call/receive-fax +[pay]: /docs/sdks/reference/php/relay/call/pay +[transcribe]: /docs/sdks/reference/php/relay/call/transcribe +[livetranscribe]: /docs/sdks/reference/php/relay/call/live-transcribe +[livetranslate]: /docs/sdks/reference/php/relay/call/live-translate +[joinconference]: /docs/sdks/reference/php/relay/call/join-conference +[leaveconference]: /docs/sdks/reference/php/relay/call/leave-conference +[joinroom]: /docs/sdks/reference/php/relay/call/join-room +[leaveroom]: /docs/sdks/reference/php/relay/call/leave-room +[queueenter]: /docs/sdks/reference/php/relay/call/queue-enter +[queueleave]: /docs/sdks/reference/php/relay/call/queue-leave + +The `Call` class represents a live RELAY call and provides methods for +controlling every aspect of the call -- answering, playing audio, recording, +collecting input, bridging, conferencing, AI agents, and more. Call objects are +created automatically by [`Client`][relayclient] +when an inbound call arrives or when you dial an outbound call. + +All call control methods are async and communicate with SignalWire over +WebSocket using the RELAY JSON-RPC protocol. Methods that start long-running +operations (play, record, detect, etc.) return [`Action`][action] +objects that let you stop, pause, or wait for the operation to complete. + +## **Properties** + + + Unique identifier for this call, assigned by SignalWire. + + + + Identifier of the RELAY node handling this call. + + + + SignalWire project ID that owns this call. + + + + The context (routing label) the call is associated with. + + + + Correlation tag for tracking related calls. Empty string if not set. + + + + Call direction. Valid values: + - `"inbound"` -- incoming call + - `"outbound"` -- outgoing call + + + + Device information for the call endpoint. Contains `type` (e.g., `"phone"`) and + `params` (e.g., `{"from_number": "+1...", "to_number": "+1..."}`). + + + + Current call state. Valid values: + - `"created"` -- call has been initiated + - `"ringing"` -- ringing at the destination + - `"answered"` -- call is active + - `"ending"` -- hangup in progress + - `"ended"` -- call has terminated + + + + Call segment identifier for tracking call legs. + + +## **Methods** + + + + Register an event listener on a call. + + + Answer an inbound RELAY call. + + + End a RELAY call. + + + Decline control of an inbound call and return it to routing. + + + Disconnect (unbridge) a connected call. + + + Transfer call control to another RELAY application or SWML script. + + + Bridge a call to one or more destinations. + + + Put a call on hold. + + + Release a call from hold. + + + Play audio content on a call. + + + Record audio from a call. + + + Play audio and collect DTMF or speech input. + + + Collect DTMF or speech input without playing media. + + + Detect answering machines, fax tones, or digits on a call. + + + Start an AI agent session on a call. + + + Connect a call to an Amazon Bedrock AI agent. + + + Put an AI agent session on hold. + + + Resume an AI agent session from hold. + + + Send a message to an active AI agent session. + + + Start noise reduction on a call. + + + Stop noise reduction on a call. + + + Send DTMF digits on a call. + + + Echo call audio back to the caller for testing. + + + Bind a DTMF digit sequence to trigger a RELAY method. + + + Clear DTMF digit bindings on a call. + + + Send a custom user-defined event on a call. + + + Transfer a SIP call to an external endpoint via SIP REFER. + + + Intercept call media and stream it to an external destination. + + + Stream call audio to a WebSocket endpoint. + + + Send a fax document on a call. + + + Receive a fax on a call. + + + Collect payment information on a call. + + + Start transcribing call audio. + + + Start or stop live transcription on a call. + + + Start or stop live translation on a call. + + + Join an ad-hoc audio conference. + + + Leave an audio conference. + + + Join a video/audio room. + + + Leave a video/audio room. + + + Place a call into a named queue. + + + Remove a call from a queue. + + + +## **Example** + +```php +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Register an event listener + $call->on("calling.call.play", $lambda event: print("Play state: {$event->params.get('state')}")); + + // Play a greeting + $action = $await $call->play([["type" => "tts", "text": "Hello from RELAY!"]]); + $action->wait(); + + // Wait for the call to end + $call->wait_for_ended(); + echo "Call ended: {$call->call_id}"; + +$client->run(); + +``` + +## **Events** + +Events are emitted during the lifecycle of a call and its operations. Register +handlers using [`call.on()`][call-on] to react +to state changes, errors, and operation completions. + +See the [Events][events] reference +for the full list of calling events, their parameters, and typed event classes. diff --git a/fern/products/sdks/pages/reference/php/relay/call/join-conference.mdx b/fern/products/sdks/pages/reference/php/relay/call/join-conference.mdx new file mode 100644 index 000000000..5f2cfa5ab --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/join-conference.mdx @@ -0,0 +1,158 @@ +--- +title: "joinConference" +slug: /reference/php/relay/call/join-conference +description: Join an ad-hoc audio conference. +max-toc-depth: 3 +--- + +[leave-conference]: /docs/sdks/reference/php/relay/call/leave-conference +[calling-conference]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events +[join-conference]: /docs/swml/reference/join-conference +[swml-join-conference-reference]: /docs/swml/reference/join-conference + +Join an ad-hoc audio conference. The conference is created automatically if it +does not already exist. Multiple calls can join the same conference by name. + + +Use [`leave_conference()`][leave-conference] to remove the call from the conference. + + + +This method emits [`calling.conference`][calling-conference] events. See [Call Events][call-events] for payload details. + + + +This method corresponds to the SWML [`joinConference`][join-conference] +verb. See the [SWML join_conference reference][swml-join-conference-reference] for the +full specification. + + +## **Parameters** + + + Conference name. All calls joining the same name are in the same conference. + + + + Join the conference muted. + + + + Play a beep when joining or leaving. + + - `"true"` -- beep on both enter and exit + - `"false"` -- no beep + - `"onEnter"` -- beep only when a participant joins + - `"onExit"` -- beep only when a participant leaves + + + + Start the conference when this participant enters. If `false`, the + conference waits until a participant with `start_on_enter=true` joins. + + + + End the conference when this participant leaves. + + + + URL of audio to play while waiting for the conference to start. + + + + Maximum number of participants in the conference. + + + + Recording mode. + + - `"record-from-start"` -- begin recording when the conference starts + - `"do-not-record"` -- do not record the conference + + + + Region for the conference media server. + + + + Whether to trim silence from the conference recording. + + + + Call SID to coach (whisper to one participant). + + + + URL to receive conference status webhooks. + + + + Events that trigger status callbacks. + + + + Content type for status callback requests. + + + + HTTP method for status callbacks (e.g., `"POST"`, `"GET"`). + + + + URL to receive recording status webhooks. + + + + Events that trigger recording status callbacks. + + + + Content type for recording status callback requests. + + + + HTTP method for recording status callbacks. + + + + Stream configuration for the conference audio. + + +## **Returns** + +`dict` -- Server response confirming the join. + +## **Example** + +```php {16} +onCall() +function handleCall($call) +{ + $call->answer(); + $call->play([["type" => "tts", "text": "Joining the team conference."]]); +} + + // Join a conference + $call->joinConference( + "team-standup", + beep: "onEnter", + start_on_enter: true, + ); + + // The call is now in the conference until it leaves or the call ends + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/join-room.mdx b/fern/products/sdks/pages/reference/php/relay/call/join-room.mdx new file mode 100644 index 000000000..b6f0a3713 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/join-room.mdx @@ -0,0 +1,58 @@ +--- +title: "joinRoom" +slug: /reference/php/relay/call/join-room +description: Join a video/audio room. +max-toc-depth: 3 +--- + +[leave-room]: /docs/sdks/reference/php/relay/call/leave-room + +Join a video/audio room. Rooms provide multi-party communication with +additional features beyond conferences, including video support. + + +Use [`leave_room()`][leave-room] to leave the room. + + +## **Parameters** + + + Room name to join. + + + + URL to receive room status webhooks. + + +## **Returns** + +`dict` -- Server response confirming the join. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Join a room + $call->joinRoom("meeting-room-1"); + + // The call is now in the room until leave_room() or hangup + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/leave-conference.mdx b/fern/products/sdks/pages/reference/php/relay/call/leave-conference.mdx new file mode 100644 index 000000000..90168817f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/leave-conference.mdx @@ -0,0 +1,48 @@ +--- +title: "leaveConference" +slug: /reference/php/relay/call/leave-conference +description: Leave an audio conference. +max-toc-depth: 3 +--- + +Leave an audio conference. + +## **Parameters** + + + The conference ID to leave. + + +## **Returns** + +`dict` -- Server response confirming the leave. + +## **Example** + +```php {18} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Join a conference + $result = $await $call->joinConference("team-standup", beep: "onEnter"); + + // Later, leave the conference + $call->leave_conference($result["conference_id"] ?? null); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/leave-room.mdx b/fern/products/sdks/pages/reference/php/relay/call/leave-room.mdx new file mode 100644 index 000000000..0f768ae52 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/leave-room.mdx @@ -0,0 +1,47 @@ +--- +title: "leaveRoom" +slug: /reference/php/relay/call/leave-room +description: Leave a video/audio room. +max-toc-depth: 3 +--- + +Leave the current room. + +## **Parameters** + +None. + +## **Returns** + +`dict` -- Server response confirming the leave. + +## **Example** + +```php {18} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Join a room + $call->joinRoom("meeting-room-1"); + + // Later, leave the room + $call->leave_room(); + $call->hangup(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/live-transcribe.mdx b/fern/products/sdks/pages/reference/php/relay/call/live-transcribe.mdx new file mode 100644 index 000000000..6ca1c2b40 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/live-transcribe.mdx @@ -0,0 +1,79 @@ +--- +title: "liveTranscribe" +slug: /reference/php/relay/call/live-transcribe +description: Start or stop live transcription on a call. +max-toc-depth: 3 +--- + +[transcribe]: /docs/sdks/reference/php/relay/call/transcribe +[live-translate]: /docs/sdks/reference/php/relay/call/live-translate + +Start or stop live transcription on the call. Unlike +[`transcribe()`][transcribe] which +provides a post-call result, live transcription delivers text in real-time. + + +See also [`live_translate()`][live-translate] for real-time translation. + + +## **Parameters** + + + Action configuration for the live transcription. + + + + + The action to perform. + + - `"start"` -- begin live transcription + - `"stop"` -- end live transcription + + + + Transcription language code (e.g., `"en-US"`). + + + + URL to receive transcription results via webhook. + + + +## **Returns** + +`dict` -- Server response confirming the operation. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Start live transcription + $result = $await $call->live_transcribe({ + "action": "start", + "language": "en-US", + "status_url": "https://example.com/transcription-results", + }); + echo "Live transcription started: {$result}"; + + // Let the call proceed... + $call->wait_for_ended(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/live-translate.mdx b/fern/products/sdks/pages/reference/php/relay/call/live-translate.mdx new file mode 100644 index 000000000..169188246 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/live-translate.mdx @@ -0,0 +1,74 @@ +--- +title: "liveTranslate" +slug: /reference/php/relay/call/live-translate +description: Start or stop live translation on a call. +max-toc-depth: 3 +--- + +Start or stop live translation on the call. Translates spoken audio into +another language in real-time. + +## **Parameters** + + + Action configuration for the live translation. + + + + + The action to perform. + + - `"start"` -- begin live translation + - `"stop"` -- end live translation + + + + Source language code (e.g., `"en-US"`). + + + + Target language code (e.g., `"es-ES"`). + + + + + URL to receive translation results via webhook. + + +## **Returns** + +`dict` -- Server response confirming the operation. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Start live translation from English to Spanish + $call->live_translate({ + "action": "start", + "source_language": "en-US", + "target_language": "es-ES", + }); + + // Let the call proceed... + $call->wait_for_ended(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/on.mdx b/fern/products/sdks/pages/reference/php/relay/call/on.mdx new file mode 100644 index 000000000..e08b55e01 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/on.mdx @@ -0,0 +1,69 @@ +--- +title: "on" +slug: /reference/php/relay/call/on +description: Register an event listener on a call. +max-toc-depth: 3 +--- + +[events-section]: /docs/sdks/reference/php/relay/call#events +[relayevent]: /docs/sdks/reference/php/relay/events + +Register a listener for events on this call. The handler is called each time +an event of the specified type is received. Handlers can be regular functions +or async coroutines. + +## **Parameters** + + + The event type string to listen for (e.g., `"calling.call.state"`, + `"calling.call.play"`). See the [Events section][events-section] + on the Call page for class-level events, or individual method pages for + method-specific events. + + + + Function or coroutine to invoke when the event fires. Receives a + [`RelayEvent`][relayevent] instance. + + +## **Returns** + +`null` + +## **Example** + +```php {10,15,21} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Register a listener for play events + $call->on("calling.call.play", $lambda event: print("Play state: {$event->params.get('state')}")); + + // Register a listener for state changes + function onStateChange($event) + { + echo "Call state changed: {$event->params.get('call_state')}"; +} + + $call->on("calling.call.state", $on_state_change); + + $action = $await $call->play([["type" => "tts", "text": "Hello!"]]); + $action->wait(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/pass.mdx b/fern/products/sdks/pages/reference/php/relay/call/pass.mdx new file mode 100644 index 000000000..f5af80eaa --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/pass.mdx @@ -0,0 +1,53 @@ +--- +title: "pass" +slug: /reference/php/relay/call/pass +description: "Decline control of an inbound call and return it to routing." +max-toc-depth: 3 +--- + +Decline control of an inbound call, returning it to the SignalWire routing +engine. The call is not ended -- it continues to ring and may be delivered to +another RELAY client or routing rule. + + +The method is named `pass_()` with a trailing underscore because `pass` is a +reserved keyword in PHP. + + +## **Parameters** + +None. + +## **Returns** + +`dict` -- Server response confirming the pass operation. + +## **Example** + +```php {14} +onCall() +function handleCall($call) +{ + // Only handle calls from a specific context + if ($call->context != "sales") { + $call->pass_(); + echo "Call passed back to routing"; + return; + } + + $call->answer(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/pay.mdx b/fern/products/sdks/pages/reference/php/relay/call/pay.mdx new file mode 100644 index 000000000..9c7936bf8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/pay.mdx @@ -0,0 +1,159 @@ +--- +title: "pay" +slug: /reference/php/relay/call/pay +description: "Collect payment information on a call." +max-toc-depth: 3 +--- + +[payaction]: /docs/sdks/reference/php/relay/actions +[calling-call-pay]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Start a payment collection session on the call. Collects credit card or other +payment information from the caller via DTMF. Returns a +[`PayAction`][payaction] that you can use to stop +the payment flow or wait for it to complete. + + +This method emits [`calling.call.pay`][calling-call-pay] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + + + URL of the payment connector service that processes the payment. + + + + Custom control ID. Auto-generated if not provided. + + + + How the caller provides payment info. + + - `"dtmf"` -- caller enters digits on the keypad + - `"speech"` -- caller speaks the payment information + + + + URL to receive payment status webhooks. + + + + Payment method type. Valid values: `"credit-card"`. + + + + Timeout for the payment session. + + + + Maximum number of input attempts before failing. + + + + Whether to collect CVV. + + - `"true"` -- prompt the caller for the security code + - `"false"` -- skip security code collection + + + + Whether to collect postal code. + + - `"true"` -- prompt the caller for the postal code + - `"false"` -- skip postal code collection + + + + Minimum length for the postal code. + + + + Tokenization type for the payment data. + + + + Amount to charge (e.g., `"29.99"`). + + + + Currency code (e.g., `"USD"`, `"EUR"`). + + + + Language for payment prompts (e.g., `"en"`). + + + + Voice for TTS prompts during the payment flow. + + + + Description of the payment/charge. + + + + Comma-separated list of accepted card types (e.g., `"visa,mastercard,amex"`). + + + + Additional parameters to pass to the payment connector. + + + + Custom prompts for the payment flow. + + + + Callback invoked when the payment operation completes. + + +## **Returns** + +[`PayAction`][payaction] -- An action handle with +`stop()` and `wait()` methods. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); + $call->play([["type" => "tts", "text": "We will now collect your payment."]]); +} + + $action = $await $call->pay( + payment_connector_url: "https://example.com/payment-connector", + charge_amount: "29.99", + currency: "USD", + security_code: "true", + postal_code: "true", + ); + $event = $await $action->wait(); + + $state = $event->params["state"] ?? ""; + if ($state == "finished") { + $call->play([["type" => "tts", "text": "Payment processed successfully."]]); +} + } else { + $call->play([["type" => "tts", "text": "Payment failed. Please try again later."]]); +} + + $call->hangup(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/play-and-collect.mdx b/fern/products/sdks/pages/reference/php/relay/call/play-and-collect.mdx new file mode 100644 index 000000000..460677ee3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/play-and-collect.mdx @@ -0,0 +1,140 @@ +--- +title: "playAndCollect" +slug: /reference/php/relay/call/play-and-collect +description: "Play audio and collect DTMF or speech input." +max-toc-depth: 3 +--- + +[collectaction]: /docs/sdks/reference/php/relay/actions +[calling-call-collect]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events +[play]: /docs/sdks/reference/php/relay/call/play + +Play audio content as a prompt and simultaneously collect user input via DTMF +digits or speech recognition. Returns a +[`CollectAction`][collectaction] that resolves when +input is collected, the operation times out, or an error occurs. + + +The `CollectAction` resolves only on collect events, not on play events. This +means `await action.wait()` blocks until the user provides input (or the +operation terminates), not when the audio finishes playing. + + + +This method emits [`calling.call.collect`][calling-call-collect] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + + + List of media items to play as the prompt. Same format as + [`play()`][play] media items. + + + + Input collection configuration. + + + + + DTMF digit collection settings. + + + + + Maximum number of digits to collect. + + + + Seconds to wait between digits before completing. + + + + Characters that terminate digit collection (e.g., `"#"`). + + + + + Speech recognition settings. + + + + + Seconds of silence to wait before finalizing speech input. + + + + Maximum seconds to listen for speech. + + + + Speech recognition language code (e.g., `"en-US"`). + + + + Words or phrases to boost recognition accuracy. + + + + + + Volume adjustment in dB for the prompt audio. + + + + Custom control ID. Auto-generated if not provided. + + + + Callback invoked when collection completes. + + +## **Returns** + +[`CollectAction`][collectaction] -- An action handle with +`stop()`, `volume()`, `startInputTimers()`, and `wait()` methods. + +## **Example** + +```php {14} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + $action = $await $call->playAndCollect( + media: [["type" => "tts", "text": "Press 1 for sales, 2 for support."]], + collect: { + "digits": ["max" => 1, "digit_timeout": 5, "terminators": "#"], + }, + ); + $event = $await $action->wait(); + + $result = $event->params["result"] ?? {}; + $digits = $result["digits"] ?? ""; + if ($digits == "1") { + $call->transfer("sales"); +} + } elseif ($digits == "2") { + $call->transfer("support"); +} + } else { + $call->hangup(); +} + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/play.mdx b/fern/products/sdks/pages/reference/php/relay/call/play.mdx new file mode 100644 index 000000000..77ca55e12 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/play.mdx @@ -0,0 +1,155 @@ +--- +title: "play" +slug: /reference/php/relay/call/play +description: "Play audio content on a call." +max-toc-depth: 3 +--- + +[playaction]: /docs/sdks/reference/php/relay/actions +[calling-call-play]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events +[play]: /docs/swml/reference/play +[swml-play-reference]: /docs/swml/reference/play + +Play audio content on the call. Supports TTS (text-to-speech), audio file URLs, +silence, and ringtone. Returns a [`PlayAction`][playaction] +that you can use to pause, resume, stop, adjust volume, or wait for completion. + + +This method emits [`calling.call.play`][calling-call-play] events. See [Call Events][call-events] for payload details. + + + +This method corresponds to the SWML [`play`][play] verb. See the +[SWML play reference][swml-play-reference] for the full specification. + + +## **Parameters** + + + List of media items to play. Each item is a dict with a `type` key and + type-specific fields: + - `{"type": "tts", "text": "Hello", "language": "en-US", "gender": "female"}` -- text-to-speech + - `{"type": "audio", "url": "https://example.com/audio.mp3"}` -- audio file URL + - `{"type": "silence", "duration": 2}` -- silence for a duration in seconds + - `{"type": "ringtone", "name": "us"}` -- play a standard ringtone + + + + Volume adjustment in dB, from `-40.0` to `40.0`. + + + + Audio direction. Valid values: + - `"listen"` -- play to the caller only + - `"speak"` -- play to the remote party only + - `"both"` -- play to both sides + + + + Number of times to repeat the media. `0` loops indefinitely. + + + + Custom control ID for this operation. Auto-generated if not provided. + + + + Callback invoked when playback reaches a terminal state. Can be a regular + function or async coroutine. + + +## **Returns** + +[`PlayAction`][playaction] -- An action handle with +`stop()`, `pause()`, `resume()`, `volume()`, and `wait()` methods. + +## **Examples** + +### Text-to-Speech + +```php {13} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->play([["type" => "tts", "text": "Welcome to SignalWire!"]]); + $action->wait(); +} + +$client->run(); + + +``` + +### Audio File with Loop + +```php {14} +onCall() +function handleCall($call) +{ + $call->answer(); + // Play hold music on loop + $action = $await $call->play( + [["type" => "audio", "url": "https://example.com/hold-music.mp3"]], + loop: 0, + direction: "listen", + ); + // Later, stop the music + $action->stop(); +} + +$client->run(); + + +``` + +### Multiple Media Items + +```php {13} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->play([ + ["type" => "tts", "text": "Please hold while we connect you."], + ["type" => "silence", "duration": 1], + ["type" => "audio", "url": "https://example.com/hold-music.mp3"], + ]); + $action->wait(); +} + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/queue-enter.mdx b/fern/products/sdks/pages/reference/php/relay/call/queue-enter.mdx new file mode 100644 index 000000000..352273e88 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/queue-enter.mdx @@ -0,0 +1,69 @@ +--- +title: "queueEnter" +slug: /reference/php/relay/call/queue-enter +description: Place a call into a named queue. +max-toc-depth: 3 +--- + +[queue-leave]: /docs/sdks/reference/php/relay/call/queue-leave +[calling-call-queue]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Place the call into a named queue. The caller waits in the queue until they are +dequeued by another operation (such as an agent picking up) or removed via +[`queue_leave()`][queue-leave]. + + +This method emits [`calling.call.queue`][calling-call-queue] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + + + Name of the queue to enter. + + + + Custom control ID. Auto-generated if not provided. + + + + URL to receive queue status webhooks (position updates, dequeue events). + + +## **Returns** + +`dict` -- Server response confirming the call entered the queue. + +## **Example** + +```php {16} +onCall() +function handleCall($call) +{ + $call->answer(); + $call->play([["type" => "tts", "text": "You are being placed in the support queue."]]); +} + + // Enter the queue + $call->queue_enter( + queue_name: "support", + status_url: "https://example.com/queue-status", + ); + + // The call stays in the queue until an agent dequeues it + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/queue-leave.mdx b/fern/products/sdks/pages/reference/php/relay/call/queue-leave.mdx new file mode 100644 index 000000000..e0835a39f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/queue-leave.mdx @@ -0,0 +1,72 @@ +--- +title: "queueLeave" +slug: /reference/php/relay/call/queue-leave +description: Remove a call from a queue. +max-toc-depth: 3 +--- + +[calling-call-queue]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Remove the call from a queue. + + +This method emits [`calling.call.queue`][calling-call-queue] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + + + Name of the queue to leave. + + + + Custom control ID. Auto-generated if not provided. + + + + Specific queue ID to leave (if the call is in multiple queues with the + same name). + + + + URL to receive queue status webhooks. + + +## **Returns** + +`dict` -- Server response confirming the call left the queue. + +## **Example** + +```php {20} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Enter the queue + $call->queue_enter(queue_name: "support"); + + // Remove from queue after a timeout + $asyncio->sleep(300) # 5 $minute $max $wait; + $call->queue_leave(queue_name: "support"); + $call->play([["type" => "tts", "text": "No agents available. Please try again later."]]); + $call->hangup(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/receive-fax.mdx b/fern/products/sdks/pages/reference/php/relay/call/receive-fax.mdx new file mode 100644 index 000000000..f4b3e6e19 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/receive-fax.mdx @@ -0,0 +1,67 @@ +--- +title: "receiveFax" +slug: /reference/php/relay/call/receive-fax +description: "Receive a fax on a call." +max-toc-depth: 3 +--- + +[faxaction]: /docs/sdks/reference/php/relay/actions +[calling-call-fax]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Start receiving a fax on the call. Returns a +[`FaxAction`][faxaction] that resolves when the +fax is fully received or an error occurs. + + +This method emits [`calling.call.fax`][calling-call-fax] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + + + Custom control ID. Auto-generated if not provided. + + + + Callback invoked when the fax reception completes. The event contains + the received document URL and page count. + + +## **Returns** + +[`FaxAction`][faxaction] -- An action handle with +`stop()` and `wait()` methods. + +## **Example** + +```php {14} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + $action = $await $call->receive_fax(); + $event = $await $action->wait(); + + $fax_result = $event->params["fax"] ?? {}; + $document_url = $fax_result["document"] ?? ""; + $pages = $fax_result["pages"] ?? 0; + echo "Received fax: {$pages} pages, document: {$document_url}"; + $call->hangup(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/record.mdx b/fern/products/sdks/pages/reference/php/relay/call/record.mdx new file mode 100644 index 000000000..624038a30 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/record.mdx @@ -0,0 +1,120 @@ +--- +title: "record" +slug: /reference/php/relay/call/record +description: "Record audio from a call." +max-toc-depth: 3 +--- + +[recordaction]: /docs/sdks/reference/php/relay/actions +[calling-call-record]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events +[record]: /docs/swml/reference/record +[swml-record-reference]: /docs/swml/reference/record + +Start recording audio from the call. Returns a +[`RecordAction`][recordaction] that you can use to +pause, resume, stop, or wait for the recording to complete. + + +This method emits [`calling.call.record`][calling-call-record] events. See [Call Events][call-events] for payload details. + + + +This method corresponds to the SWML [`record`][record] verb. See the +[SWML record reference][swml-record-reference] for the full specification. + + +## **Parameters** + + + Audio recording configuration object. + + + + + Which audio to record. + + - `"listen"` -- record audio heard by the caller + - `"speak"` -- record audio spoken by the caller + - `"both"` -- record audio in both directions + + + + Recording file format. + + - `"mp3"` -- compressed MP3 format + - `"wav"` -- uncompressed WAV format + + + + Record in stereo (each side on a separate channel). + + + + Seconds to wait for audio before ending with `no_input`. + + + + Seconds of silence before stopping automatically. + + + + DTMF digits that stop recording (e.g., `"#"`). + + + + Play a beep before recording starts. + + + + Sensitivity threshold for detecting audio input. + + + + + Custom control ID for this operation. Auto-generated if not provided. + + + + Callback invoked when recording reaches a terminal state (`finished` or + `no_input`). The event contains the recording `url`, `duration`, and `size`. + + +## **Returns** + +[`RecordAction`][recordaction] -- An action handle with +`stop()`, `pause()`, `resume()`, and `wait()` methods. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); + $call->play([["type" => "tts", "text": "Leave a message after the beep."]]); +} + + $action = $await $call->record( + audio: ["beep" => true, "end_silence_timeout": 3, "terminators": "#"], + ); + $event = $await $action->wait(); + + $url = $event->params["record"] ?? {}["url"] ?? ""; + echo "Recording saved: {$url}"; + $call->hangup(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/refer.mdx b/fern/products/sdks/pages/reference/php/relay/call/refer.mdx new file mode 100644 index 000000000..8c10c587c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/refer.mdx @@ -0,0 +1,76 @@ +--- +title: "refer" +slug: /reference/php/relay/call/refer +description: "Transfer a SIP call to an external endpoint via SIP REFER." +max-toc-depth: 3 +--- + +[transfer]: /docs/sdks/reference/php/relay/call/transfer +[calling-call-refer]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Transfer a SIP call to an external SIP endpoint using the SIP REFER method. +Unlike [`transfer()`][transfer] +which transfers control within RELAY, `refer()` performs a SIP-level transfer +to an external endpoint. + + +This method emits [`calling.call.refer`][calling-call-refer] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + + + The target SIP device for the REFER. + + + + + Device type. Typically `"sip"`. + + + + SIP parameters including `uri` (the SIP URI to refer to). + + + + + URL to receive REFER status webhooks. + + +## **Returns** + +`dict` -- Server response confirming the refer operation. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); + $call->play([["type" => "tts", "text": "Transferring to another line."]]); +} + + $result = $await $call->refer( + device: { + "type": "sip", + "params": ["uri" => "sip:support@example.com"], + }, + ); + echo "SIP REFER result: {$result}"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/send-digits.mdx b/fern/products/sdks/pages/reference/php/relay/call/send-digits.mdx new file mode 100644 index 000000000..8ce6a7402 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/send-digits.mdx @@ -0,0 +1,58 @@ +--- +title: "sendDigits" +slug: /reference/php/relay/call/send-digits +description: "Send DTMF digits on a call." +max-toc-depth: 3 +--- + +[calling-call-send-digits]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Send DTMF tones on the call. Use this to navigate IVR menus on outbound calls +or to send tone signals. + + +This method emits [`calling.call.send_digits`][calling-call-send-digits] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + + + The DTMF digit string to send. Valid characters: `0-9`, `*`, `#`, + `A-D`, `W` (0.5s pause), `w` (1s pause). + + + + Custom control ID. Auto-generated if not provided. + + +## **Returns** + +`dict` -- Server response confirming the send_digits operation. + +## **Example** + +```php {14} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + $result = $await $call->send_digits("1w2"); + echo "Digits sent: {$result}"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/send-fax.mdx b/fern/products/sdks/pages/reference/php/relay/call/send-fax.mdx new file mode 100644 index 000000000..83a9e34d8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/send-fax.mdx @@ -0,0 +1,80 @@ +--- +title: "sendFax" +slug: /reference/php/relay/call/send-fax +description: "Send a fax document on a call." +max-toc-depth: 3 +--- + +[faxaction]: /docs/sdks/reference/php/relay/actions +[calling-call-fax]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Send a fax document on the call. The document must be accessible via URL. +Returns a [`FaxAction`][faxaction] that you can +use to stop the fax or wait for it to complete. + + +This method emits [`calling.call.fax`][calling-call-fax] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + + + URL of the document to fax (PDF or TIFF format). + + + + Caller identity string (TSI) transmitted with the fax. + + + + Header text printed at the top of each fax page. + + + + Custom control ID. Auto-generated if not provided. + + + + Callback invoked when the fax operation completes. + + +## **Returns** + +[`FaxAction`][faxaction] -- An action handle with +`stop()` and `wait()` methods. + +## **Example** + +```php {14} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + $action = $await $call->send_fax( + document: "https://example.com/invoice.pdf", + identity: "+15559876543", + header_info: "Invoice #12345", + ); + $event = $await $action->wait(); + + $fax_result = $event->params["fax"] ?? {}; + echo "Fax sent: {$fax_result['pages'] ?? 0} pages"; + $call->hangup(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/stream.mdx b/fern/products/sdks/pages/reference/php/relay/call/stream.mdx new file mode 100644 index 000000000..d807374b2 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/stream.mdx @@ -0,0 +1,111 @@ +--- +title: "stream" +slug: /reference/php/relay/call/stream +description: "Stream call audio to a WebSocket endpoint." +max-toc-depth: 3 +--- + +[streamaction]: /docs/sdks/reference/php/relay/actions +[calling-call-stream]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Start streaming call audio to a WebSocket endpoint. Returns a +[`StreamAction`][streamaction] that you can use to +stop the stream or wait for it to finish. + + +This method emits [`calling.call.stream`][calling-call-stream] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + + + WebSocket URL to stream audio to (e.g., `"wss://example.com/stream"`). + + + + A name for this stream, useful for identifying multiple concurrent streams. + + + + Audio codec for the stream. + + - `"PCMU"` -- G.711 mu-law (default for North America) + - `"PCMA"` -- G.711 A-law (default for international) + - `"OPUS"` -- Opus codec (higher quality, variable bitrate) + + + + Which audio track to stream. + + - `"inbound"` -- audio received from the caller + - `"outbound"` -- audio sent to the caller + - `"both"` -- audio in both directions + + + + URL to receive stream status webhooks. + + + + HTTP method for status webhooks. + + - `"GET"` -- send status updates via GET request + - `"POST"` -- send status updates via POST request + + + + Bearer token for authenticating with the WebSocket server. + + + + Custom key-value pairs sent with the stream start message. + + + + Custom control ID. Auto-generated if not provided. + + + + Callback invoked when the stream ends. + + +## **Returns** + +[`StreamAction`][streamaction] -- An action handle with +`stop()` and `wait()` methods. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Stream audio to an external service for real-time processing + $action = $await $call->stream( + url: "wss://example.com/audio-stream", + track: "inbound", + codec: "PCMU", + custom_parameters: ["session_id" => "abc123"], + ); + + // The stream runs until stopped or the call ends + $call->wait_for_ended(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/tap.mdx b/fern/products/sdks/pages/reference/php/relay/call/tap.mdx new file mode 100644 index 000000000..4349b90b0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/tap.mdx @@ -0,0 +1,104 @@ +--- +title: "tap" +slug: /reference/php/relay/call/tap +description: "Intercept call media and stream it to an external destination." +max-toc-depth: 3 +--- + +[tapaction]: /docs/sdks/reference/php/relay/actions +[calling-call-tap]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Intercept call media (audio) and stream it to an external destination such as a +WebSocket or RTP endpoint. Returns a +[`TapAction`][tapaction] that you can use to stop +the tap or wait for it to finish. + + +This method emits [`calling.call.tap`][calling-call-tap] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + + + Tap configuration specifying which audio to intercept. + + + + + Tap type. Valid values: `"audio"`. + + + + Tap parameters. Supports a `direction` key with the following values: + + - `"listen"` -- capture audio heard by the caller + - `"speak"` -- capture audio spoken by the caller + - `"both"` -- capture audio in both directions + + + + + Destination device for the tapped media. + + + + + Device type. + + - `"ws"` -- WebSocket endpoint + - `"rtp"` -- RTP endpoint + + + + Device-specific parameters (e.g., `uri` for WebSocket, `addr`/`port` for RTP). + + + + + Custom control ID. Auto-generated if not provided. + + + + Callback invoked when the tap operation ends. + + +## **Returns** + +[`TapAction`][tapaction] -- An action handle with +`stop()` and `wait()` methods. + +## **Example** + +```php {16} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Tap audio and stream to a WebSocket endpoint + $action = $await $call->tap( + tap: ["type" => "audio", "params": {"direction": "both"]}, + device: ["type" => "ws", "params": {"uri": "wss://example.com/tap"]}, + ); + + // Tap runs in background; stop it later + $asyncio->sleep(30); + $action->stop(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/transcribe.mdx b/fern/products/sdks/pages/reference/php/relay/call/transcribe.mdx new file mode 100644 index 000000000..51e8e76de --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/transcribe.mdx @@ -0,0 +1,83 @@ +--- +title: "transcribe" +slug: /reference/php/relay/call/transcribe +description: "Start transcribing call audio." +max-toc-depth: 3 +--- + +[transcribeaction]: /docs/sdks/reference/php/relay/actions +[live-transcribe]: /docs/sdks/reference/php/relay/call/live-transcribe +[calling-call-transcribe]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Start transcribing call audio. Returns a +[`TranscribeAction`][transcribeaction] that you can use +to stop the transcription or wait for it to complete. + + +For real-time transcription with immediate text output, see +[`live_transcribe()`][live-transcribe]. +The `transcribe()` method provides a post-call transcription result. + + + +This method emits [`calling.call.transcribe`][calling-call-transcribe] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + + + Custom control ID. Auto-generated if not provided. + + + + URL to receive transcription status webhooks. + + + + Callback invoked when transcription completes. The event contains the + transcription `url`, `duration`, and `size`. + + +## **Returns** + +[`TranscribeAction`][transcribeaction] -- An action handle +with `stop()` and `wait()` methods. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Start transcription + $action = $await $call->transcribe( + status_url: "https://example.com/transcription-status", + ); + + // Let the call proceed... + $call->wait_for_ended(); + + // The transcription result is available after the call ends + if ($action->result) { + $url = $action->result->params["url"] ?? ""; + echo "Transcription available at: {$url}"; +} + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/transfer.mdx b/fern/products/sdks/pages/reference/php/relay/call/transfer.mdx new file mode 100644 index 000000000..4a46fa606 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/transfer.mdx @@ -0,0 +1,51 @@ +--- +title: "transfer" +slug: /reference/php/relay/call/transfer +description: "Transfer call control to another RELAY application or SWML script." +max-toc-depth: 3 +--- + +Transfer control of the call to another RELAY application or SWML script. +The current application loses control of the call after a successful transfer. + +## **Parameters** + + + The transfer destination. This can be a RELAY context name or a URL pointing + to a SWML script. + + +Additional keyword arguments are forwarded to the RELAY `calling.transfer` request. + +## **Returns** + +`dict` -- Server response confirming the transfer. + +## **Example** + +```php {16} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->play([["type" => "tts", "text": "Transferring you now..."]]); + $action->wait(); +} + + $result = $await $call->transfer("support-queue"); + echo "Transfer result: {$result}"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/unhold.mdx b/fern/products/sdks/pages/reference/php/relay/call/unhold.mdx new file mode 100644 index 000000000..2226f8e4e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/unhold.mdx @@ -0,0 +1,59 @@ +--- +title: "unhold" +slug: /reference/php/relay/call/unhold +description: Release a call from hold. +max-toc-depth: 3 +--- + +[calling-call-hold]: /docs/sdks/reference/php/relay/call#events +[call-events]: /docs/sdks/reference/php/relay/call#events + +Release the call from hold, resuming normal audio between the parties. + + +This method emits [`calling.call.hold`][calling-call-hold] events. See [Call Events][call-events] for payload details. + + +## **Parameters** + +None. + +## **Returns** + +`dict` -- Server response confirming the unhold operation. + +## **Example** + +```php {21} +onCall() +function handleCall($call) +{ + $call->answer(); + $call->play([["type" => "tts", "text": "Please hold while I look that up."]]); +} + + // Put the call on hold + $call->hold(); + + // Do some processing... + $asyncio->sleep(5); + + $result = $await $call->unhold(); + echo "Call resumed from hold: {$result}"; + $call->play([["type" => "tts", "text": "Thanks for holding. I have your answer."]]); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/call/user-event.mdx b/fern/products/sdks/pages/reference/php/relay/call/user-event.mdx new file mode 100644 index 000000000..90a5e9a36 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/call/user-event.mdx @@ -0,0 +1,54 @@ +--- +title: "userEvent" +slug: /reference/php/relay/call/user-event +description: "Send a custom user-defined event on a call." +max-toc-depth: 3 +--- + +Send a custom user-defined event on the call. User events allow you to pass +application-specific data through the RELAY event system. Other listeners on +the same call can receive and react to these events. + +## **Parameters** + + + The event name or identifier. + + +Additional keyword arguments are forwarded as event parameters. + +## **Returns** + +`dict` -- Server response confirming the event was sent. + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Send a custom event with metadata + $result = $await $call->user_event( + event: "customer_identified", + customer_id: "cust-12345", + tier: "premium", + ); + echo "User event sent: {$result}"; + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/client/connect.mdx b/fern/products/sdks/pages/reference/php/relay/client/connect.mdx new file mode 100644 index 000000000..e52dde052 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/client/connect.mdx @@ -0,0 +1,95 @@ +--- +title: "connect" +slug: /reference/php/relay/client/connect +description: "Establish the WebSocket connection and authenticate." +max-toc-depth: 3 +--- + +[run]: /docs/sdks/reference/php/relay/client/run +[ref-relayclient]: /docs/sdks/reference/php/relay/client + +Establish a WebSocket connection to SignalWire RELAY and authenticate. This method +connects to `wss://`, sends a `signalwire.connect` authentication request, +subscribes to the configured contexts, and starts the internal receive loop. + + +For most use cases, prefer [`run()`][run] +which calls `connect()` internally and adds automatic reconnection. Use `connect()` +directly only when you need manual control over the event loop or are using the +async context manager. + + + +By default, only one [`Client`][ref-relayclient] connection is allowed per process. Calling +`connect()` on a second instance without disconnecting the first raises +`RuntimeError`. Set the `RELAY_MAX_CONNECTIONS` environment variable to allow +multiple concurrent connections. + + +## **Parameters** + +None. + +## **Returns** + +`null` + +## **Examples** + +### Manual connect/disconnect + +```php {12} +connect(); + // Connected and authenticated -- do work here + $call = $await $client->dial( + devices: [[["type" => "phone", "params": {"to_number": "+15559876543", "from_number": "+15551234567"]}]] + ); + $call->hangup(); + $client->disconnect(); +} + +$asyncio->run($main()); + + +``` + +### Async context manager + +```php +dial( + devices: [[["type" => "phone", "params": {"to_number": "+15559876543", "from_number": "+15551234567"]}]] + ); + $call->hangup(); +} + +$asyncio->run($main()); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/client/dial.mdx b/fern/products/sdks/pages/reference/php/relay/client/dial.mdx new file mode 100644 index 000000000..dc69ea6dc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/client/dial.mdx @@ -0,0 +1,179 @@ +--- +title: "dial" +slug: /reference/php/relay/client/dial +description: "Initiate an outbound call." +max-toc-depth: 3 +--- + +[call]: /docs/sdks/reference/php/relay/call + +Initiate an outbound call. Sends a `calling.dial` JSON-RPC request and waits for the +server to return a `calling.call.dial` event confirming the call was answered or failed. +Returns a fully-initialized [`Call`][call] object +with valid `call_id` and `node_id`. + +The `devices` parameter supports both serial and parallel dialing strategies. Each +inner list represents a set of devices to ring simultaneously (parallel). The outer +list represents sequential attempts -- if the first group fails, the next group is +tried. + + +Raises `RelayError` if the dial fails or if no answer is received within the +`dial_timeout` period. The default timeout is 120 seconds. + + +## **Parameters** + + + Nested array of device definitions for serial and parallel dialing. Each device is + a dict with `type` and `params` keys. + + - **Serial dial** (try one after another): each inner list has one device + - **Parallel dial** (ring simultaneously): one inner list with multiple devices + + + + + Device type. Valid values: + - `"phone"` -- PSTN phone number + - `"sip"` -- SIP endpoint + + + + Device-specific parameters. + + + + + Destination phone number in E.164 format (for `"phone"` type). + + + + Caller ID phone number in E.164 format (for `"phone"` type). + + + + Per-device ring timeout in seconds. + + + + + + Client-provided correlation tag for event matching. Auto-generated as a UUID if + not supplied. + + + + Maximum call duration in minutes. The call is automatically ended when this + limit is reached. + + + + How long in seconds to wait for the dial to complete (answer or failure) before + raising a timeout error. + + +## **Returns** + +[`Call`][call] -- A call object with all properties populated and ready for call control operations. + +## **Examples** + +### Simple outbound call + +```php {13} +dial( + devices: [[{ + "type": "phone", + "params": { + "from_number": "+15551234567", + "to_number": "+15559876543", + "timeout": 30, + }, + }]], + ); + $action = $await $call->play([["type" => "tts", "text": "Hello!"]]); + $action->wait(); + $call->hangup(); +} + +$asyncio->run($main()); + + +``` + +### Serial dial (failover) + +```php {14} +dial( + devices: [ + [["type" => "phone", "params": {"to_number": "+15551111111", "from_number": "+15550000000"]}], + [["type" => "phone", "params": {"to_number": "+15552222222", "from_number": "+15550000000"]}], + ], + ); +} + +$asyncio->run($main()); + + +``` + +### Parallel dial (ring all) + +```php {14} +dial( + devices: [[ + ["type" => "phone", "params": {"to_number": "+15551111111", "from_number": "+15550000000"]}, + ["type" => "phone", "params": {"to_number": "+15552222222", "from_number": "+15550000000"]}, + ]], + ); +} + +$asyncio->run($main()); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/client/disconnect.mdx b/fern/products/sdks/pages/reference/php/relay/client/disconnect.mdx new file mode 100644 index 000000000..5d5e2747b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/client/disconnect.mdx @@ -0,0 +1,64 @@ +--- +title: "disconnect" +slug: /reference/php/relay/client/disconnect +description: "Close the WebSocket connection cleanly." +max-toc-depth: 3 +--- + +[connect]: /docs/sdks/reference/php/relay/client/connect +[run]: /docs/sdks/reference/php/relay/client/run + +Cleanly close the WebSocket connection to SignalWire RELAY. This cancels the +internal receive loop, ping monitor, all pending JSON-RPC requests, any queued +requests waiting for reconnection, and any in-progress dial operations. The +client is fully reset and can be reconnected with +[`connect()`][connect]. + + +When using the async context manager (`async with client:`), `disconnect()` is +called automatically on exit. When using +[`run()`][run], disconnection happens +automatically on `Ctrl+C` or when the event loop is stopped. + + +## **Parameters** + +None. + +## **Returns** + +`null` + +## **Example** + +```php {22} +connect(); +} + + // Do work ... + $message = $await $client->sendMessage( + to_number: "+15559876543", + from_number: "+15551234567", + body: "Hello!", + ); + $message->wait(); + + $client->disconnect(); + +$asyncio->run($main()); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/client/execute.mdx b/fern/products/sdks/pages/reference/php/relay/client/execute.mdx new file mode 100644 index 000000000..c2977111e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/client/execute.mdx @@ -0,0 +1,77 @@ +--- +title: "execute" +slug: /reference/php/relay/client/execute +description: "Send a raw JSON-RPC request to RELAY." +max-toc-depth: 3 +--- + +[dial]: /docs/sdks/reference/php/relay/client/dial +[send-message]: /docs/sdks/reference/php/relay/client/send-message +[call]: /docs/sdks/reference/php/relay/call + +Send a raw JSON-RPC 2.0 request to the RELAY server and return the parsed +response. This is the low-level RPC method that all other client and call +control methods are built on. + +If the client is not currently connected (e.g., during a reconnect cycle), +the request is automatically queued and sent after re-authentication completes. + + +This method has a default timeout of 10 seconds. If no response is received +within that window, it raises `RelayError` and forces a reconnection attempt, +as the timeout may indicate a half-open WebSocket connection. + + + +Most developers should use the higher-level methods like +[`dial()`][dial], +[`sendMessage()`][send-message], +and the [`Call`][call] control methods +instead of calling `execute()` directly. Use `execute()` only for custom +or unsupported RPC methods. + + +## **Parameters** + + + Full JSON-RPC method name (e.g., `"calling.answer"`, `"calling.play"`, + `"messaging.send"`). The method name must include the namespace prefix. + + + + Parameters for the RPC call. Typically includes `node_id` and `call_id` + for calling methods, along with method-specific parameters. + + +## **Returns** + +`dict` -- The `result` object from the JSON-RPC response. Structure depends on the method called. + +## **Example** + +```php {13} +onCall() +function handleCall($call) +{ + // Send a custom RPC request using the call's identifiers + $result = $await $client->execute("calling.answer", {; + "node_id": call.$node_id, + "call_id": call.$call_id, + }); + echo "Answer result: {$result}"; +} + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/client/index.mdx b/fern/products/sdks/pages/reference/php/relay/client/index.mdx new file mode 100644 index 000000000..ad85f6a13 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/client/index.mdx @@ -0,0 +1,215 @@ +--- +title: "RelayClient" +slug: /reference/php/relay/client +description: "WebSocket client for real-time call and message control." +max-toc-depth: 3 +--- + +[call]: /docs/sdks/reference/php/relay/call +[message]: /docs/sdks/reference/php/relay/message +[connect]: /docs/sdks/reference/php/relay/client/connect +[disconnect]: /docs/sdks/reference/php/relay/client/disconnect +[run]: /docs/sdks/reference/php/relay/client/run +[dial]: /docs/sdks/reference/php/relay/client/dial +[sendmessage]: /docs/sdks/reference/php/relay/client/send-message +[receive]: /docs/sdks/reference/php/relay/client/receive +[unreceive]: /docs/sdks/reference/php/relay/client/unreceive +[execute]: /docs/sdks/reference/php/relay/client/execute + +`Client` manages a persistent WebSocket connection to SignalWire's RELAY +service. It handles authentication, automatic reconnection with exponential +backoff, inbound event dispatch, outbound dialing, and SMS/MMS messaging. +Use it when you need imperative, event-driven control over calls rather than +the declarative AI agent approach. + +The client supports two authentication modes: project ID + API token, or JWT +token. Credentials can be passed directly or read from environment variables. + +## **Properties** + + + SignalWire project ID. Set via constructor or `SIGNALWIRE_PROJECT_ID` environment variable. + + + + API token for authentication. Set via constructor or `SIGNALWIRE_API_TOKEN` environment variable. + + + + JWT token for alternative authentication. Set via constructor or `SIGNALWIRE_JWT_TOKEN` environment variable. + When provided, `project` and `token` are not required. + + + + SignalWire space hostname (e.g., `your-space.signalwire.com`). Set via constructor or `SIGNALWIRE_SPACE` + environment variable. Defaults to `relay.signalwire.com`. + + + + List of contexts to subscribe to for inbound call and message events. + + + + Maximum number of concurrent inbound calls the client will track. Calls + arriving beyond this limit are dropped with a log warning. Set via constructor + or `RELAY_MAX_ACTIVE_CALLS` environment variable. + + + + Server-assigned protocol string from the connect response. Read-only. Used internally + for session resumption on reconnect. + + +## **Decorators** + +### on_call + +```php +onCall() +function handleCall(Call $call): null +{ + $call->answer(); + echo "Received call: {$call->call_id}"; +} + +$client->run(); + + +``` + +Register the inbound call handler. The decorated function is called once for each +`calling.call.receive` event on the subscribed contexts. The function receives a +[`Call`][call] object with all call properties +and control methods. + +### on_message + +```php +onMessage() +function handleMessage(Message $message): null +{ + echo "Received message: {$message->body}"; +} + +$client->run(); + + +``` + +Register the inbound SMS/MMS message handler. The decorated function is called for +each `messaging.receive` event. The function receives a +[`Message`][message] object with message +properties and state tracking. + +## **Methods** + + + + Establish the WebSocket connection and authenticate. + + + Close the WebSocket connection cleanly. + + + Start the client with automatic reconnection. + + + Initiate an outbound call. + + + Send an outbound SMS or MMS message. + + + Subscribe to additional contexts for inbound events. + + + Unsubscribe from inbound event contexts. + + + Send a raw JSON-RPC request to RELAY. + + + +## **Async Context Manager** + +`Client` supports `async with` for scoped connections: + +```php +dial( + to: "+15559876543", + from_number: "+15551234567", + ); + // Automatically disconnects on exit +} + +$asyncio->run($main()); + + +``` + +## **Example** + +```php {3} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->play([["type" => "tts", "text": "Hello from RELAY!"]]); + $action->wait(); + $call->hangup(); +} + +// Handler: $client->onMessage() +function handleMessage($message) +{ + echo "SMS from {$message->from_number}: {$message->body}"; +} + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/client/receive.mdx b/fern/products/sdks/pages/reference/php/relay/client/receive.mdx new file mode 100644 index 000000000..a927898c8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/client/receive.mdx @@ -0,0 +1,91 @@ +--- +title: "receive" +slug: /reference/php/relay/client/receive +description: "Subscribe to additional contexts for inbound events." +max-toc-depth: 3 +--- + +[relayclient-constructor]: /docs/sdks/reference/php/relay/client + +Subscribe to additional contexts for inbound call and message events. Sends a +`signalwire.receive` request on the assigned protocol to start receiving events +on the specified contexts without reconnecting. + +Use this to dynamically expand the set of contexts after the initial connection. +Contexts passed to the [`Client` constructor][relayclient-constructor] +are subscribed automatically at connect time -- this method is for adding more +at runtime. + + +Contexts are strings that act as routing labels. A phone number configured in +your SignalWire dashboard sends calls to a specific context. Subscribe to that +context to receive those calls. + + +## **Parameters** + + + List of context names to subscribe to. If the list is empty, the method + returns immediately without sending a request. + + +## **Returns** + +`null` + +## **Examples** + +### Add contexts at runtime + +```php {14} +receive(["support", "billing"]); + echo "Now receiving calls on sales, support, and billing"; +} + +$asyncio->run($main()); + + +``` + +### With inbound call handler + +```php {17-18} +onCall() +function handleCall($call) +{ + echo "Call on context: {$call->context}"; + $call->answer(); + $call->hangup(); +} + +// Subscribe to additional contexts at startup via constructor +// For runtime subscription after connect, use await client.receive(["support"]) +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/client/run.mdx b/fern/products/sdks/pages/reference/php/relay/client/run.mdx new file mode 100644 index 000000000..28aa05ca4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/client/run.mdx @@ -0,0 +1,62 @@ +--- +title: "run" +slug: /reference/php/relay/client/run +description: "Start the client with automatic reconnection." +max-toc-depth: 3 +--- + +[connect]: /docs/sdks/reference/php/relay/client/connect +[disconnect]: /docs/sdks/reference/php/relay/client/disconnect +[ref-relayclient]: /docs/sdks/reference/php/relay/client + +Blocking entry point that connects to RELAY and runs the event loop until +interrupted. This is the recommended way to start a [`Client`][ref-relayclient] for long-running +services. It calls [`connect()`][connect] +internally and automatically reconnects with exponential backoff (1 second initial +delay, up to 30 seconds maximum) if the connection is lost. + +The method blocks the current thread. Press `Ctrl+C` to trigger a clean shutdown -- +the client handles `SIGINT` gracefully without dumping a stack trace. + + +`run()` is synchronous and creates its own `asyncio` event loop via `asyncio.run()`. +Do not call it from inside an already-running async event loop. For async contexts, +use [`connect()`][connect] and +[`disconnect()`][disconnect] directly. + + +## **Parameters** + +None. + +## **Returns** + +`null` -- blocks until the client is stopped via `Ctrl+C` or a programmatic shutdown. + +## **Example** + +```php {18} +onCall() +function handleCall($call) +{ + $call->answer(); + $action = $await $call->play([["type" => "tts", "text": "Welcome! Goodbye."]]); + $action->wait(); + $call->hangup(); +} + +// Blocks forever, reconnects on connection loss +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/client/send-message.mdx b/fern/products/sdks/pages/reference/php/relay/client/send-message.mdx new file mode 100644 index 000000000..0f9659033 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/client/send-message.mdx @@ -0,0 +1,164 @@ +--- +title: "sendMessage" +slug: /reference/php/relay/client/send-message +description: "Send an outbound SMS or MMS message." +max-toc-depth: 3 +--- + +[message]: /docs/sdks/reference/php/relay/message + +Send an outbound SMS or MMS message. Returns a +[`Message`][message] object that tracks delivery +state changes. Use `await message.wait()` to block until the message reaches a +terminal state (delivered, undelivered, or failed). + +All parameters are keyword-only. + + +At least one of `body` or `media` must be provided. Providing both sends an MMS +with text and attached media. + + +## **Parameters** + + + Destination phone number in E.164 format (e.g., `"+15559876543"`). + + + + Sender phone number in E.164 format. Must be a number owned by your SignalWire project. + + + + Context for receiving state-change events for this message. Defaults to the + server-assigned relay protocol string, or `"default"` if no protocol has been + assigned yet. + + + + Text body of the message. Required for SMS. Optional for MMS if `media` is provided. + + + + List of publicly accessible media URLs for MMS attachments (e.g., images, audio files). + + + + Optional tags to attach to the message for filtering or tracking. + + + + Origination region for the message. + + + + Callback function invoked when the message reaches a terminal state + (`delivered`, `undelivered`, or `failed`). Receives the terminal + event as its argument. + + +## **Returns** + +[`Message`][message] -- A message object in the `"queued"` state. Use `await message.wait()` to block until delivery confirmation. + +## **Examples** + +### Send SMS + +```php {13} +sendMessage( + to_number: "+15559876543", + from_number: "+15551234567", + body: "Hello from SignalWire RELAY!", + ); + echo "Message ID: {$message->message_id}"; +} + + // Wait for delivery confirmation + $result = $await $message->wait(timeout: 30.0); + echo "Final state: {$message->state}"; + +$asyncio->run(sendSms()); + + +``` + +### Send MMS with media + +```php {13} +sendMessage( + to_number: "+15559876543", + from_number: "+15551234567", + body: "Check out this image!", + media: ["https://example.com/photo.jpg"], + ); +} + +$asyncio->run($send_mms()); + + +``` + +### With completion callback + +```php {16} +params}"; +} + +function sendWithCallback() +{ + $async $with $client:; + $message = $await $client->sendMessage( + to_number: "+15559876543", + from_number: "+15551234567", + body: "Important notification", + on_completed: $on_delivered, + ); + // No need to await -- callback fires automatically +} + +$asyncio->run($send_with_callback()); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/client/unreceive.mdx b/fern/products/sdks/pages/reference/php/relay/client/unreceive.mdx new file mode 100644 index 000000000..2266a5da0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/client/unreceive.mdx @@ -0,0 +1,59 @@ +--- +title: "unreceive" +slug: /reference/php/relay/client/unreceive +description: "Unsubscribe from inbound event contexts." +max-toc-depth: 3 +--- + +[receive]: /docs/sdks/reference/php/relay/client/receive +[on-call]: /docs/sdks/reference/php/relay/client + +Unsubscribe from contexts for inbound call and message events. Sends a +`signalwire.unreceive` request to stop receiving events on the specified +contexts. This is the inverse of +[`receive()`][receive]. + +After unsubscribing, inbound calls routed to those contexts will no longer +trigger the [`@onCall`][on-call] handler +on this client. + +## **Parameters** + + + List of context names to unsubscribe from. If the list is empty, the method + returns immediately without sending a request. + + +## **Returns** + +`null` + +## **Example** + +```php {15} +onCall() +function handleCall($call) +{ + $call->answer(); +} + + // Dynamically unsubscribe from "billing" after the first call + $client->unreceive(["billing"]); + echo "Unsubscribed from billing context"; + + $call->hangup(); + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/constants.mdx b/fern/products/sdks/pages/reference/php/relay/constants.mdx new file mode 100644 index 000000000..6d38b9541 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/constants.mdx @@ -0,0 +1,278 @@ +--- +title: "Constants" +slug: /reference/php/relay/constants +description: "RELAY constants for call states, events, and message states." +max-toc-depth: 3 +--- + +[callstateevent-endreason]: /docs/sdks/reference/php/relay/events +[connectevent-connectstate]: /docs/sdks/reference/php/relay/events +[call-on]: /docs/sdks/reference/php/relay/call +[relayevent-eventtype]: /docs/sdks/reference/php/relay/events +[message-wait]: /docs/sdks/reference/php/relay/message +[playevent-state]: /docs/sdks/reference/php/relay/events +[recordevent-state]: /docs/sdks/reference/php/relay/events +[call-detect]: /docs/sdks/reference/php/relay/call/detect + +The `signalwire.relay.constants` module defines string and numeric constants used +throughout the RELAY namespace for call states, end reasons, connect states, event +types, message states, media operation states, and protocol settings. + +```php + + RELAY protocol version. Value: `{"major": 2, "minor": 0, "revision": 0}`. + + + + User agent string sent during connection. Value: `"signalwire-agents-python/1.0"`. + + + + Default WebSocket host for RELAY connections. Value: `"relay.signalwire.com"`. + + +## JSON-RPC Methods + +Internal method identifiers used by the RELAY WebSocket protocol. + +| Constant | Value | +|----------|-------| +| `METHOD_SIGNALWIRE_CONNECT` | `"signalwire.connect"` | +| `METHOD_SIGNALWIRE_EVENT` | `"signalwire.event"` | +| `METHOD_SIGNALWIRE_PING` | `"signalwire.ping"` | +| `METHOD_SIGNALWIRE_DISCONNECT` | `"signalwire.disconnect"` | +| `METHOD_SIGNALWIRE_RECEIVE` | `"signalwire.receive"` | +| `METHOD_SIGNALWIRE_UNRECEIVE` | `"signalwire.unreceive"` | + +--- + +## Call States + +Constants representing the lifecycle states of a RELAY call. A call progresses +through these states in order: `created` -> `ringing` -> `answered` -> `ending` -> `ended`. + +| Constant | Value | Description | +|----------|-------|-------------| +| `CALL_STATE_CREATED` | `"created"` | Call object has been created | +| `CALL_STATE_RINGING` | `"ringing"` | Call is ringing at the destination | +| `CALL_STATE_ANSWERED` | `"answered"` | Call has been answered | +| `CALL_STATE_ENDING` | `"ending"` | Call is in the process of ending | +| `CALL_STATE_ENDED` | `"ended"` | Call has ended | + + + Tuple of all call states in lifecycle order: + `("created", "ringing", "answered", "ending", "ended")`. + + +## End Reasons + +Constants for the reason a call ended. Available in +[`CallStateEvent.end_reason`][callstateevent-endreason] when the call +reaches the `ended` state. + +| Constant | Value | Description | +|----------|-------|-------------| +| `END_REASON_HANGUP` | `"hangup"` | Normal hangup by either party | +| `END_REASON_CANCEL` | `"cancel"` | Call was cancelled before answer | +| `END_REASON_BUSY` | `"busy"` | Destination returned busy | +| `END_REASON_NO_ANSWER` | `"noAnswer"` | No answer within timeout | +| `END_REASON_DECLINE` | `"decline"` | Call was declined | +| `END_REASON_ERROR` | `"error"` | An error occurred | +| `END_REASON_ABANDONED` | `"abandoned"` | Call was abandoned (e.g., caller hung up in queue) | +| `END_REASON_MAX_DURATION` | `"max_duration"` | Call exceeded maximum allowed duration | +| `END_REASON_NOT_FOUND` | `"not_found"` | Destination not found | + +--- + +## Connect States + +Constants representing the state of a call bridge (connect) operation. Used in +[`ConnectEvent.connect_state`][connectevent-connectstate]. + +| Constant | Value | Description | +|----------|-------|-------------| +| `CONNECT_STATE_CONNECTING` | `"connecting"` | Bridge is being established | +| `CONNECT_STATE_CONNECTED` | `"connected"` | Bridge is active | +| `CONNECT_STATE_DISCONNECTED` | `"disconnected"` | Bridge has been disconnected | +| `CONNECT_STATE_FAILED` | `"failed"` | Bridge attempt failed | + +--- + +## Event Types + +String constants for all RELAY event types. Use these when registering event +handlers with [`Call.on()`][call-on] or when +matching against [`RelayEvent.event_type`][relayevent-eventtype]. + +### Calling Events + +| Constant | Value | +|----------|-------| +| `EVENT_CALL_STATE` | `"calling.call.state"` | +| `EVENT_CALL_RECEIVE` | `"calling.call.receive"` | +| `EVENT_CALL_CONNECT` | `"calling.call.connect"` | +| `EVENT_CALL_PLAY` | `"calling.call.play"` | +| `EVENT_CALL_COLLECT` | `"calling.call.collect"` | +| `EVENT_CALL_RECORD` | `"calling.call.record"` | +| `EVENT_CALL_DETECT` | `"calling.call.detect"` | +| `EVENT_CALL_FAX` | `"calling.call.fax"` | +| `EVENT_CALL_TAP` | `"calling.call.tap"` | +| `EVENT_CALL_SEND_DIGITS` | `"calling.call.send_digits"` | +| `EVENT_CALL_DIAL` | `"calling.call.dial"` | +| `EVENT_CALL_REFER` | `"calling.call.refer"` | +| `EVENT_CALL_DENOISE` | `"calling.call.denoise"` | +| `EVENT_CALL_PAY` | `"calling.call.pay"` | +| `EVENT_CALL_QUEUE` | `"calling.call.queue"` | +| `EVENT_CALL_STREAM` | `"calling.call.stream"` | +| `EVENT_CALL_ECHO` | `"calling.call.echo"` | +| `EVENT_CALL_TRANSCRIBE` | `"calling.call.transcribe"` | +| `EVENT_CONFERENCE` | `"calling.conference"` | +| `EVENT_CALLING_ERROR` | `"calling.error"` | + +### Messaging Events + +| Constant | Value | +|----------|-------| +| `EVENT_MESSAGING_RECEIVE` | `"messaging.receive"` | +| `EVENT_MESSAGING_STATE` | `"messaging.state"` | + +### Authorization Event + +| Constant | Value | +|----------|-------| +| `EVENT_AUTHORIZATION_STATE` | `"signalwire.authorization.state"` | + +--- + +## Message States + +Constants representing the lifecycle states of an SMS/MMS message. Outbound +messages progress through: `queued` -> `initiated` -> `sent` -> `delivered` +(or `undelivered` / `failed`). Inbound messages arrive with state `received`. + +| Constant | Value | Description | +|----------|-------|-------------| +| `MESSAGE_STATE_QUEUED` | `"queued"` | Message has been queued for sending | +| `MESSAGE_STATE_INITIATED` | `"initiated"` | Send process has started | +| `MESSAGE_STATE_SENT` | `"sent"` | Message has been sent to the carrier | +| `MESSAGE_STATE_DELIVERED` | `"delivered"` | Message was delivered to the recipient | +| `MESSAGE_STATE_UNDELIVERED` | `"undelivered"` | Message could not be delivered | +| `MESSAGE_STATE_FAILED` | `"failed"` | Message send failed | +| `MESSAGE_STATE_RECEIVED` | `"received"` | Inbound message received | + + + Tuple of terminal states that resolve a [`Message.wait()`][message-wait] call: + `("delivered", "undelivered", "failed")`. + + +## Play States + +Constants for audio playback operation states. Used in +[`PlayEvent.state`][playevent-state]. + +| Constant | Value | Description | +|----------|-------|-------------| +| `PLAY_STATE_PLAYING` | `"playing"` | Audio is playing | +| `PLAY_STATE_PAUSED` | `"paused"` | Playback is paused | +| `PLAY_STATE_FINISHED` | `"finished"` | Playback completed | +| `PLAY_STATE_ERROR` | `"error"` | Playback error occurred | + +--- + +## Record States + +Constants for recording operation states. Used in +[`RecordEvent.state`][recordevent-state]. + +| Constant | Value | Description | +|----------|-------|-------------| +| `RECORD_STATE_RECORDING` | `"recording"` | Recording is active | +| `RECORD_STATE_PAUSED` | `"paused"` | Recording is paused | +| `RECORD_STATE_FINISHED` | `"finished"` | Recording completed | +| `RECORD_STATE_NO_INPUT` | `"no_input"` | No audio input detected | + +--- + +## Detect Types + +Constants for detection operation types. Used in the `type` field of the +`detect` parameter passed to [`call.detect()`][call-detect]. + +| Constant | Value | Description | +|----------|-------|-------------| +| `DETECT_TYPE_MACHINE` | `"machine"` | Answering machine detection | +| `DETECT_TYPE_FAX` | `"fax"` | Fax tone detection | +| `DETECT_TYPE_DIGIT` | `"digit"` | DTMF digit detection | + +--- + +## Room States + +Constants for audio/video room join/leave states. + +| Constant | Value | Description | +|----------|-------|-------------| +| `ROOM_STATE_JOINING` | `"joining"` | Joining the room | +| `ROOM_STATE_JOIN` | `"join"` | Successfully joined | +| `ROOM_STATE_LEAVING` | `"leaving"` | Leaving the room | +| `ROOM_STATE_LEAVE` | `"leave"` | Successfully left | + +--- + +## Reconnect Settings + +Configuration constants for the WebSocket reconnection strategy. + +| Constant | Value | Description | +|----------|-------|-------------| +| `RECONNECT_MIN_DELAY` | `1.0` | Minimum delay between reconnect attempts (seconds) | +| `RECONNECT_MAX_DELAY` | `30.0` | Maximum delay between reconnect attempts (seconds) | +| `RECONNECT_BACKOFF_FACTOR` | `2.0` | Exponential backoff multiplier | + +## **Example** + +```php +call_state == $CALL_STATE_ANSWERED) { + echo "Call answered!"; + } + } elseif ($event->call_state == $CALL_STATE_ENDED) { + echo "Call ended: {$event->end_reason}"; + } + +// Check terminal message states +function handleMessageState($message) +{ + if ($message->state $in $MESSAGE_TERMINAL_STATES) { + echo "Message delivery complete"; + } +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/events.mdx b/fern/products/sdks/pages/reference/php/relay/events.mdx new file mode 100644 index 000000000..05e983bd3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/events.mdx @@ -0,0 +1,1483 @@ +--- +title: "Events" +slug: /reference/php/relay/events +description: "Typed event classes for all RELAY events." +max-toc-depth: 3 +--- + +[call-on]: /docs/sdks/reference/php/relay/call/on +[message-on]: /docs/sdks/reference/php/relay/message +[constants]: /docs/sdks/reference/php/relay/constants +[playaction]: /docs/sdks/reference/php/relay/actions +[collect]: /docs/sdks/reference/php/relay/call/collect +[playandcollect]: /docs/sdks/reference/php/relay/call/play-and-collect +[sendfax]: /docs/sdks/reference/php/relay/call/send-fax +[receivefax]: /docs/sdks/reference/php/relay/call/receive-fax +[hold]: /docs/sdks/reference/php/relay/call/hold +[unhold]: /docs/sdks/reference/php/relay/call/unhold +[queueenter]: /docs/sdks/reference/php/relay/call/queue-enter +[queueleave]: /docs/sdks/reference/php/relay/call/queue-leave + +RELAY events are delivered as typed dataclass instances that wrap the raw JSON-RPC +event payloads from the SignalWire WebSocket connection. When you register a handler +with [`Call.on()`][call-on] or +[`Message.on()`][message-on], the handler +automatically receives a typed event object with named properties for each field. + +All typed event classes inherit from [`RelayEvent`](#relayevent), which provides +access to the raw `params` dictionary alongside the typed properties. You can also +use the [`parse_event()`](#parse_event) helper to manually parse raw event payloads. + +```php +onCall() +function onCall($call) +{ + function handleState(CallStateEvent $event) + { + echo "Call state: {$event->call_state}"; + } + + $call->on("calling.call.state", $handle_state); + $call->answer(); + +$client->run(); + + +``` + +## RelayEvent + +Base event class. All other event classes inherit from this. Every handler receives +at minimum a `RelayEvent` instance, which provides access to the raw event data. + + + The event type string (e.g., `"calling.call.state"`, `"messaging.receive"`). + See [`Constants`][constants] for the full list. + + + + The raw parameters dictionary from the event payload. Contains all event-specific + fields, including those not surfaced as typed attributes on subclasses. + + + + The call identifier associated with this event, if applicable. + + + + Server timestamp of the event. + + +## **Methods** + +### from_payload + +**from_payload**(`payload`) -> `RelayEvent` + +Class method. Parse a raw event dict into a `RelayEvent` instance. + +#### Parameters + + + Raw event payload dictionary. + + + + + The event type string (e.g., `"calling.call.state"`). + + + + Event-specific parameters. + + + +#### Returns + +`RelayEvent` -- A new event instance with typed properties. + +#### Example + +```php +from_payload({ + "event_type": "calling.call.state", + "params": ["call_state" => "answered"], +}); +echo $event->event_type; + + +``` + +--- + +### parse_event + +**parse_event**(`payload`) -> `RelayEvent` + +Module-level helper function. Parses a raw event dict and returns the appropriate +typed event subclass based on the `event_type` field. Falls back to `RelayEvent` +for unrecognized event types. + +#### Parameters + + + Raw event payload dictionary. + + + + + The event type string (e.g., `"calling.call.state"`, `"calling.call.play"`). + Determines which typed subclass is returned. + + + + Event-specific parameters. Contents vary by event type. + + + +#### Returns + +[`RelayEvent`](#relayevent) -- The appropriate typed subclass based on the +`event_type` field, or a base `RelayEvent` for unrecognized types. + +#### Example + +```php + "abc-123", "state": "playing"], +}); +// Returns a PlayEvent instance +echo $event->state; + + +``` + +--- + +## Calling Events + +### calling.call.state + +Emitted when the call state changes through its lifecycle: `created` -> +`ringing` -> `answered` -> `ending` -> `ended`. + +#### CallStateEvent + +Handlers for this event receive a `CallStateEvent` with the following properties: + + + The new call state. + + - `"created"` -- call object has been initialized + - `"ringing"` -- call is ringing at the destination + - `"answered"` -- call has been answered and is active + - `"ending"` -- hangup is in progress + - `"ended"` -- call has been fully terminated + + + + Reason the call ended. Only present when `call_state` is `"ended"`. + + - `"hangup"` -- normal disconnect by a party on the call + - `"cancel"` -- call was cancelled before being answered + - `"busy"` -- destination signaled busy + - `"noAnswer"` -- call rang but was not answered within the timeout + - `"decline"` -- destination actively declined the call + - `"error"` -- an error occurred during call processing + - `"abandoned"` -- caller hung up before the call was answered + - `"max_duration"` -- call reached the maximum allowed duration + - `"not_found"` -- destination could not be found or routed + + + + Call direction. + + - `"inbound"` -- incoming call + - `"outbound"` -- outgoing call + + + + Device information for the call endpoint. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleState(CallStateEvent $event) + { + echo "State: {$event->call_state}, reason: {$event->end_reason}"; + } + + $call->on("calling.call.state", $handle_state); + $call->answer(); + +$client->run(); + + +``` + +--- + +### calling.call.receive + +Emitted when an inbound call is received on a subscribed context. This event is +dispatched at the client level via the `@client.onCall` decorator rather than +through `call.on()`. + +#### CallReceiveEvent + +Handlers for this event receive a `CallReceiveEvent` with the following properties: + + + Initial call state (typically `"ringing"`). + + + + Always `"inbound"` for receive events. + + + + Device information for the caller. + + + + + RELAY node handling this call. + + + + SignalWire project ID. + + + + The context the call was received on. + + + + Call segment identifier. + + + + Correlation tag for the call. + + +### calling.call.play + +Emitted when playback state changes on a play operation. + +#### PlayEvent + +Handlers for this event receive a `PlayEvent` with the following properties: + + + The control ID of the play operation. Matches the `control_id` on the + [`PlayAction`][playaction]. + + + + Playback state. + + - `"playing"` -- audio is actively playing + - `"paused"` -- playback has been paused + - `"finished"` -- playback completed successfully + - `"error"` -- an error occurred during playback + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handlePlay(PlayEvent $event) + { + echo "Playback: {$event->state}"; + } + + $call->on("calling.call.play", $handle_play); + $call->answer(); + $call->play([["type" => "tts", "text": "Hello!"]]); + +$client->run(); + + +``` + +--- + +### calling.call.record + +Emitted when recording state changes on a record operation. + +#### RecordEvent + +Handlers for this event receive a `RecordEvent` with the following properties: + + + The control ID of the record operation. + + + + Recording state. + + - `"recording"` -- audio recording is in progress + - `"paused"` -- recording has been paused + - `"finished"` -- recording completed successfully + - `"no_input"` -- recording ended due to no audio input detected + + + + URL of the recording file (available when `state` is `"finished"`). + + + + Recording duration in seconds. + + + + Recording file size in bytes. + + + + Full record metadata object containing `url`, `duration`, `size`, and other fields. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleRecord(RecordEvent $event) + { + echo "Recording {$event->state}: {$event->url}"; + } + + $call->on("calling.call.record", $handle_record); + $call->answer(); + $call->record(["direction" => "both"]); + +$client->run(); + + +``` + +--- + +### calling.call.collect + +Emitted when input collection state changes on a +[`collect()`][collect] or +[`playAndCollect()`][playandcollect] +operation. + +#### CollectEvent + +Handlers for this event receive a `CollectEvent` with the following properties: + + + The control ID of the collect operation. + + + + Collection state. + + - `"finished"` -- input was collected successfully + - `"error"` -- an error occurred during collection + - `"no_input"` -- no input was detected within the timeout + - `"no_match"` -- collected input did not match any configured patterns + + + + The collected input result. Contains `type` and the collected value. + + - `"digit"` -- DTMF digit input was collected + - `"speech"` -- speech input was collected + + + + Whether this is the final result. May be `null` for non-continuous collect operations. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleCollect(CollectEvent $event) + { + echo "Collected: {$event->result}"; + } + + $call->on("calling.call.collect", $handle_collect); + $call->answer(); + $call->playAndCollect( + media: [["type" => "tts", "text": "Press 1 or 2."]], + collect: ["digits" => {"max": 1]}, + ); + +$client->run(); + + +``` + +--- + +### calling.call.connect + +Emitted when a connect operation changes state. + +#### ConnectEvent + +Handlers for this event receive a `ConnectEvent` with the following properties: + + + Connection state. + + - `"connecting"` -- bridge is being established to the destination + - `"connected"` -- bridge has been successfully established + - `"disconnected"` -- bridge has been disconnected + - `"failed"` -- connection attempt failed + + + + Information about the connected peer call. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleConnect(ConnectEvent $event) + { + echo "Connection: {$event->connect_state}"; + } + + $call->on("calling.call.connect", $handle_connect); + $call->answer(); + $call->connect( + devices: [[["type" => "phone", "params": {"to_number": "+15559876543", "from_number": "+15551234567"]}]] + ); + +$client->run(); + + +``` + +--- + +### calling.call.detect + +Emitted when detection results arrive from a detect operation. + +#### DetectEvent + +Handlers for this event receive a `DetectEvent` with the following properties: + + + The control ID of the detect operation. + + + + Detection result. Structure depends on the detection type. + + - `"machine"` -- voicemail or answering machine detection + - `"fax"` -- fax tone detection + - `"digit"` -- DTMF digit detection + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleDetect(DetectEvent $event) + { + echo "Detected: {$event->detect}"; + } + + $call->on("calling.call.detect", $handle_detect); + $call->answer(); + $call->detect(["type" => "machine", "params": {"initial_timeout": 5.0]}); + +$client->run(); + + +``` + +--- + +### calling.call.fax + +Emitted when a [`send_fax()`][sendfax] or +[`receive_fax()`][receivefax] operation +changes state. + +#### FaxEvent + +Handlers for this event receive a `FaxEvent` with the following properties: + + + The control ID of the fax operation. + + + + Fax result data including pages, status, and document URL. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleFax(FaxEvent $event) + { + echo "Fax: {$event->fax}"; + } + + $call->on("calling.call.fax", $handle_fax); + $call->answer(); + $call->send_fax(document: "https://example.com/invoice.pdf"); + +$client->run(); + + +``` + +--- + +### calling.call.tap + +Emitted when a tap operation changes state. + +#### TapEvent + +Handlers for this event receive a `TapEvent` with the following properties: + + + The control ID of the tap operation. + + + + Tap state. + + - `"finished"` -- tap operation completed + + + + Tap configuration details. + + + + The device receiving the tapped media. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleTap(TapEvent $event) + { + echo "Tap {$event->state}: {$event->tap}"; + } + + $call->on("calling.call.tap", $handle_tap); + $call->answer(); + +$client->run(); + + +``` + +--- + +### calling.call.stream + +Emitted when a stream operation changes state. + +#### StreamEvent + +Handlers for this event receive a `StreamEvent` with the following properties: + + + The control ID of the stream operation. + + + + Stream state. + + - `"finished"` -- stream operation completed + + + + The WebSocket URL the stream is connected to. + + + + The stream name. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleStream(StreamEvent $event) + { + echo "Stream {$event->state}: {$event->url}"; + } + + $call->on("calling.call.stream", $handle_stream); + $call->answer(); + +$client->run(); + + +``` + +--- + +### calling.call.send_digits + +Emitted when a send_digits operation changes state. + +#### SendDigitsEvent + +Handlers for this event receive a `SendDigitsEvent` with the following properties: + + + The control ID of the send_digits operation. + + + + Send digits state. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleDigits(SendDigitsEvent $event) + { + echo "Send digits: {$event->state}"; + } + + $call->on("calling.call.send_digits", $handle_digits); + $call->answer(); + +$client->run(); + + +``` + +--- + +### calling.call.dial + +Emitted during outbound dial state changes. This event is dispatched at the +client level rather than through `call.on()`. + +#### DialEvent + +Handlers for this event receive a `DialEvent` with the following properties: + + + Correlation tag for the dial operation. + + + + Dial state. + + - `"answered"` -- outbound call was answered + - `"failed"` -- outbound call failed to connect + + + + Call information for the dialed leg. + + +### calling.call.refer + +Emitted when a SIP REFER operation changes state. + +#### ReferEvent + +Handlers for this event receive a `ReferEvent` with the following properties: + + + Refer state. + + + + The SIP URI the call was referred to. + + + + SIP response code from the REFER request. + + + + SIP response code from the NOTIFY message. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleRefer(ReferEvent $event) + { + echo "Refer to {$event->sip_refer_to}: {$event->state}"; + } + + $call->on("calling.call.refer", $handle_refer); + $call->answer(); + +$client->run(); + + +``` + +--- + +### calling.call.hold + +Emitted when hold state changes via +[`hold()`][hold] or +[`unhold()`][unhold]. + +#### HoldEvent + +Handlers for this event receive a `HoldEvent` with the following properties: + + + Hold state. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleHold(HoldEvent $event) + { + echo "Hold: {$event->state}"; + } + + $call->on("calling.call.hold", $handle_hold); + $call->answer(); + +$client->run(); + + +``` + +--- + +### calling.call.denoise + +Emitted when noise reduction state changes. + +#### DenoiseEvent + +Handlers for this event receive a `DenoiseEvent` with the following properties: + + + Whether noise reduction is currently active. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleDenoise(DenoiseEvent $event) + { + echo "Denoise active: {$event->denoised}"; + } + + $call->on("calling.call.denoise", $handle_denoise); + $call->answer(); + +$client->run(); + + +``` + +--- + +### calling.call.pay + +Emitted when a pay operation changes state. + +#### PayEvent + +Handlers for this event receive a `PayEvent` with the following properties: + + + The control ID of the pay operation. + + + + Payment state. + + - `"finished"` -- payment collection completed + - `"error"` -- payment operation failed + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handlePay(PayEvent $event) + { + echo "Payment: {$event->state}"; + } + + $call->on("calling.call.pay", $handle_pay); + $call->answer(); + +$client->run(); + + +``` + +--- + +### calling.call.echo + +Emitted when an echo operation changes state. + +#### EchoEvent + +Handlers for this event receive an `EchoEvent` with the following properties: + + + Echo state. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleEcho(EchoEvent $event) + { + echo "Echo: {$event->state}"; + } + + $call->on("calling.call.echo", $handle_echo); + $call->answer(); + +$client->run(); + + +``` + +--- + +### calling.call.queue + +Emitted when queue state changes via +[`queue_enter()`][queueenter] or +[`queue_leave()`][queueleave]. + +#### QueueEvent + +Handlers for this event receive a `QueueEvent` with the following properties: + + + The control ID of the queue operation. + + + + Queue status. + + + + The queue identifier. + + + + The queue name. + + + + Current position in the queue. + + + + Total number of calls in the queue. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleQueue(QueueEvent $event) + { + echo "Queue {$event->queue_name}: position {$event->position}/{$event->size}"; + } + + $call->on("calling.call.queue", $handle_queue); + $call->answer(); + +$client->run(); + + +``` + +--- + +### calling.conference + +Emitted when conference state changes. + +#### ConferenceEvent + +Handlers for this event receive a `ConferenceEvent` with the following properties: + + + The conference identifier. + + + + The conference name. + + + + Conference status. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleConference(ConferenceEvent $event) + { + echo "Conference {$event->name}: {$event->status}"; + } + + $call->on("calling.conference", $handle_conference); + $call->answer(); + +$client->run(); + + +``` + +--- + +### calling.call.transcribe + +Emitted when a transcribe operation changes state. + +#### TranscribeEvent + +Handlers for this event receive a `TranscribeEvent` with the following properties: + + + The control ID of the transcribe operation. + + + + Transcription state. + + - `"finished"` -- transcription completed successfully + + + + URL of the transcription result. + + + + Associated recording ID. + + + + Duration of the transcribed audio in seconds. + + + + Size of the transcription data in bytes. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleTranscribe(TranscribeEvent $event) + { + echo "Transcription {$event->state}: {$event->url}"; + } + + $call->on("calling.call.transcribe", $handle_transcribe); + $call->answer(); + +$client->run(); + + +``` + +--- + +### calling.error + +Emitted when an error occurs on the call. + +#### CallingErrorEvent + +Handlers for this event receive a `CallingErrorEvent` with the following properties: + + + Error code. + + + + Human-readable error description. + + +#### Example + +```php +onCall() +function handleCall($call) +{ + function handleError(CallingErrorEvent $event) + { + echo "Error {$event->code}: {$event->message}"; + } + + $call->on("calling.error", $handle_error); + $call->answer(); + +$client->run(); + + +``` + +--- + +## Messaging Events + +### messaging.receive + +Emitted when an inbound SMS/MMS message is received on a subscribed context. +This event is dispatched at the client level via the `@client.onMessage` +decorator. + +#### MessageReceiveEvent + +Handlers for this event receive a `MessageReceiveEvent` with the following properties: + + + Unique identifier for the message. + + + + The messaging context the message was received on. + + + + Always `"inbound"` for receive events. + + + + Sender phone number in E.164 format. + + + + Recipient phone number in E.164 format. + + + + Text content of the message. + + + + Media URLs for MMS messages. + + + + Number of SMS segments. + + + + State of the message (typically `"received"`). + + + + Tags associated with the message. + + +### messaging.state + +Emitted when an outbound message's state changes (e.g., `queued` -> `sent` -> `delivered`). + +#### MessageStateEvent + +Handlers for this event receive a `MessageStateEvent` with the following properties: + + + Unique identifier for the message. + + + + The messaging context. + + + + Always `"outbound"` for state events. + + + + Sender phone number in E.164 format. + + + + Recipient phone number in E.164 format. + + + + Text content of the message. + + + + Media URLs for MMS messages. + + + + Number of SMS segments. + + + + Current message state. + + - `"queued"` -- message accepted by the platform, waiting to be sent + - `"initiated"` -- message sending has been initiated + - `"sent"` -- message has been sent to the carrier + - `"delivered"` -- message has been delivered to the recipient + - `"undelivered"` -- message could not be delivered + - `"failed"` -- message sending failed + + + + Failure reason if the message failed or was undelivered. + + + + Tags associated with the message. + + +#### Example + +```php +onMessage() +function handleMessage($message) +{ + function handleState(MessageStateEvent $event) + { + echo "Message {$event->message_id}: {$event->message_state}"; + } + + $message->on($handle_state); + +$client->run(); + + +``` + +--- + +## Event Type Mapping + +Reference table mapping `event_type` strings to their typed event classes. + +| Event Type | Class | +|-----------|-------| +| `calling.call.state` | `CallStateEvent` | +| `calling.call.receive` | `CallReceiveEvent` | +| `calling.call.play` | `PlayEvent` | +| `calling.call.record` | `RecordEvent` | +| `calling.call.collect` | `CollectEvent` | +| `calling.call.connect` | `ConnectEvent` | +| `calling.call.detect` | `DetectEvent` | +| `calling.call.fax` | `FaxEvent` | +| `calling.call.tap` | `TapEvent` | +| `calling.call.stream` | `StreamEvent` | +| `calling.call.send_digits` | `SendDigitsEvent` | +| `calling.call.dial` | `DialEvent` | +| `calling.call.refer` | `ReferEvent` | +| `calling.call.denoise` | `DenoiseEvent` | +| `calling.call.pay` | `PayEvent` | +| `calling.call.queue` | `QueueEvent` | +| `calling.call.echo` | `EchoEvent` | +| `calling.call.transcribe` | `TranscribeEvent` | +| `calling.call.hold` | `HoldEvent` | +| `calling.conference` | `ConferenceEvent` | +| `calling.error` | `CallingErrorEvent` | +| `messaging.receive` | `MessageReceiveEvent` | +| `messaging.state` | `MessageStateEvent` | diff --git a/fern/products/sdks/pages/reference/php/relay/message/index.mdx b/fern/products/sdks/pages/reference/php/relay/message/index.mdx new file mode 100644 index 000000000..94ea33158 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/message/index.mdx @@ -0,0 +1,220 @@ +--- +title: "Message" +slug: /reference/php/relay/message +description: "SMS/MMS message tracking and state management." +max-toc-depth: 3 +--- + +[relayclient-send-message]: /docs/sdks/reference/php/relay/client/send-message +[message-constants]: /docs/sdks/reference/php/relay/constants +[relayevent]: /docs/sdks/reference/php/relay/events +[message-on]: /docs/sdks/reference/php/relay/message/on +[events]: /docs/sdks/reference/php/relay/events#messaging-events +[on]: /docs/sdks/reference/php/relay/message/on +[wait]: /docs/sdks/reference/php/relay/message/wait + +The `Message` class represents a single SMS/MMS message in the RELAY messaging +namespace. It tracks the lifecycle of a sent or received message through state +events. Outbound messages progress through `queued`, `initiated`, `sent`, and +then reach a terminal state (`delivered`, `undelivered`, or `failed`). Inbound +messages arrive fully formed with state `received`. + +Obtain a `Message` instance from [`Client.sendMessage()`][relayclient-send-message] +or from the `@client.onMessage` handler for inbound messages. + +```php +sendMessage( + to_number: "+15551234567", + from_number: "+15559876543", + body: "Hello from SignalWire!", + ); +} + + // Wait for delivery confirmation + $result = $await $message->wait(timeout: 30); + echo "Final state: {$message->state}"; + +$asyncio->run(sendSms()); + + +``` + +## **Properties** + + + Unique identifier for this message, assigned by SignalWire. + + + + The messaging context this message belongs to. + + + + Message direction. Valid values: + - `"inbound"` -- incoming message + - `"outbound"` -- outgoing message + + + + Sender phone number in E.164 format. + + + + Recipient phone number in E.164 format. + + + + Text content of the message. + + + + List of media URLs for MMS messages. Empty list for SMS-only messages. + + + + Number of SMS segments required for this message. + + + + Current message state. See [`Message Constants`][message-constants] for valid values. + + - `"queued"` -- message has been accepted and is waiting to be processed + - `"initiated"` -- message processing has started + - `"sent"` -- message has been dispatched to the carrier + - `"delivered"` -- message was successfully delivered to the recipient + - `"undelivered"` -- carrier was unable to deliver the message + - `"failed"` -- message could not be sent + - `"received"` -- inbound message received from the network + + + + Failure reason when the message reaches an error state. Empty string if no failure has occurred. + + + + Optional tags associated with this message. + + + + `True` if the message has reached a terminal state (`delivered`, `undelivered`, or `failed`). + Read-only property. + + + + The terminal [`RelayEvent`][relayevent] that resolved this message, + or `null` if the message has not yet completed. + + +## **Events** + +Events are emitted during the lifecycle of a message. Register handlers using +[`message.on()`][message-on] to react to state changes on outbound messages. + +See the [Events][events] reference +for the full list of messaging events, their parameters, and typed event classes. + +--- + +## **Methods** + + + + Register an event listener for state changes on this message. + + + Block until the message reaches a terminal state. + + + +## **Examples** + +### Listening for state changes + +```php +sendMessage( + to_number: "+15551234567", + from_number: "+15559876543", + body: "Order confirmed", + ); +} + + function onStateChange($event) + { + echo "Message {$message->message_id} -> {$message->state}"; +} + + $message->on($on_state_change); + $message->wait(); + +$asyncio->run($track_state()); + + +``` + +### Waiting for delivery with timeout + +```php +sendMessage( + to_number: "+15551234567", + from_number: "+15559876543", + body: "Your verification code is 123456", + ); +} + + try { + $event = $await $message->wait(timeout: 30); + if ($message->state == "delivered") { + echo "Message delivered successfully"; + } + } else { + echo "Message failed: {$message->reason}"; + } + $except $asyncio->TimeoutError:; + echo "Timed out waiting for delivery confirmation"; + +$asyncio->run($send_with_timeout()); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/message/on.mdx b/fern/products/sdks/pages/reference/php/relay/message/on.mdx new file mode 100644 index 000000000..4ad8b6a90 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/message/on.mdx @@ -0,0 +1,60 @@ +--- +title: "on" +slug: /reference/php/relay/message/on +description: "Register an event listener for state changes on this message." +max-toc-depth: 3 +--- + +[relayevent]: /docs/sdks/reference/php/relay/events + +Register an event listener for state changes on this message. The handler is +called each time a `messaging.state` event is received for this message, allowing +you to react to intermediate states before the terminal state is reached. + +## **Parameters** + + + A function or coroutine that receives a [`RelayEvent`][relayevent] + on each state change. Both synchronous and async handlers are supported. + + +## **Returns** + +`null` + +## **Example** + +```php {22} +sendMessage( + to_number: "+15551234567", + from_number: "+15559876543", + body: "Order confirmed", + ); +} + + function onStateChange($event) + { + echo "Message {$message->message_id} -> {$message->state}"; +} + + $message->on($on_state_change); + $message->wait(); + +$asyncio->run($track_state()); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/message/wait.mdx b/fern/products/sdks/pages/reference/php/relay/message/wait.mdx new file mode 100644 index 000000000..a8a232735 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/message/wait.mdx @@ -0,0 +1,67 @@ +--- +title: "wait" +slug: /reference/php/relay/message/wait +description: "Block until the message reaches a terminal state." +max-toc-depth: 3 +--- + +[relayevent]: /docs/sdks/reference/php/relay/events + +Block until the message reaches a terminal state (`delivered`, `undelivered`, or +`failed`). Returns the terminal [`RelayEvent`][relayevent]. + + +Raises `asyncio.TimeoutError` if `timeout` is specified and the message does not +reach a terminal state within the given duration. + + +## **Parameters** + + + Maximum number of seconds to wait. `null` waits indefinitely. + + +## **Returns** + +[`RelayEvent`][relayevent] -- The event that caused the message to +reach its terminal state. Inspect `message.state` for the final state value. + +## **Example** + +```php {20} +sendMessage( + to_number: "+15551234567", + from_number: "+15559876543", + body: "Your verification code is 123456", + ); +} + + try { + $event = $await $message->wait(timeout: 30); + if ($message->state == "delivered") { + echo "Message delivered successfully"; + } + } else { + echo "Message failed: {$message->reason}"; + } + $except $asyncio->TimeoutError:; + echo "Timed out waiting for delivery confirmation"; + +$asyncio->run($send_with_timeout()); + + +``` diff --git a/fern/products/sdks/pages/reference/php/relay/overview.mdx b/fern/products/sdks/pages/reference/php/relay/overview.mdx new file mode 100644 index 000000000..1fbd7fa73 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/overview.mdx @@ -0,0 +1,152 @@ +--- +title: "RELAY" +sidebar-title: Overview +subtitle: "PHP API reference for RelayClient, Call, Message, and real-time events" +slug: /reference/php/relay +description: "Real-time WebSocket client for call and message control." +max-toc-depth: 3 +position: 0 +--- + +[agents]: /docs/sdks/reference/php/agents +[client]: /docs/sdks/reference/php/relay/client +[call]: /docs/sdks/reference/php/relay/call +[message]: /docs/sdks/reference/php/relay/message +[actions]: /docs/sdks/reference/php/relay/actions +[events]: /docs/sdks/reference/php/relay/events +[constants]: /docs/sdks/reference/php/relay/constants +[relay-error]: /docs/sdks/reference/php/relay/relay-error + +The RELAY namespace provides imperative, event-driven control over voice calls and +SMS/MMS messages through a persistent WebSocket connection to SignalWire. While the +[Agents][agents] namespace handles AI-driven conversations +declaratively via SWML, RELAY gives you fine-grained, async control over every step +of a call -- answering, playing prompts, collecting digits, recording, bridging, +conferencing, and more. + +RELAY uses the JSON-RPC 2.0 protocol over WebSocket (`wss://`). The client +authenticates once, subscribes to contexts for inbound events, and processes +call and message events in an async event loop. Automatic reconnection with +exponential backoff ensures resilience against transient network failures. + +## Context Routing + +Contexts are routing labels that control which inbound calls and messages are +delivered to your application. When you assign a phone number to a context in +the SignalWire dashboard, all calls to that number are routed to RELAY clients +subscribed to that context. + +```php +onCall(function ($call) { + $call->answer(); +}); + +// Or subscribe/unsubscribe dynamically +// $client->receive(['billing']); // Add a context +// $client->unreceive(['sales']); // Remove a context + +$client->run(); +``` + +A client only receives events for its subscribed contexts. This enables multiple +applications or workers to handle different call flows on the same project by +subscribing to different contexts. + +## Example + +An IVR that answers calls, plays a menu, collects a digit, and routes accordingly: + +```php +onCall(function ($call) { + $call->answer(); + + // Play a menu and collect one digit + $action = $call->playAndCollect( + media: [['type' => 'tts', 'text' => 'Press 1 for sales, 2 for support.']], + collect: ['digits' => ['max' => 1, 'digit_timeout' => 5.0]] + ); + $event = $action->wait(); + + $digit = $event->params['result']['digits'] ?? ''; + + if ($digit == '1') { + $call->play([['type' => 'tts', 'text' => 'Transferring to sales.']]); + $call->transfer(dest: '+15551234567'); + } elseif ($digit == '2') { + $call->play([['type' => 'tts', 'text' => 'Transferring to support.']]); + $call->transfer(dest: '+15559876543'); + } else { + $call->play([['type' => 'tts', 'text' => 'Goodbye.']]); + $call->hangup(); + } +}); + +$client->run(); +``` + +## Classes + + + + WebSocket client for connecting, authenticating, dialing calls, and sending messages. + + + Call object with methods for answer, hangup, play, record, collect, connect, and more. + + + Message object for tracking SMS/MMS state and waiting for delivery confirmation. + + + Async action handles returned from call control methods like play, record, and detect. + + + Typed event dataclasses for call state changes, playback, recording, and messaging. + + + Call states, connect states, message states, and event type string constants. + + + Exception raised when the RELAY server returns an error response. + + diff --git a/fern/products/sdks/pages/reference/php/relay/relay-error.mdx b/fern/products/sdks/pages/reference/php/relay/relay-error.mdx new file mode 100644 index 000000000..e388d8b7e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/relay/relay-error.mdx @@ -0,0 +1,59 @@ +--- +title: "RelayError" +slug: /reference/php/relay/relay-error +description: Exception raised when the RELAY server returns an error. +max-toc-depth: 3 +--- + +Exception raised when the RELAY server returns an error response. Inherits from +Python's built-in `Exception`. The string representation follows the format +`"RELAY error {code}: {message}"`. + +```php + + Numeric error code returned by the RELAY server. + + + + Human-readable error description returned by the RELAY server. + + +## **Examples** + +### Catch a RELAY error + +```php +onCall() +function handleCall($call) +{ + try { + $call->connect(devices: [["type" => "phone", "params": {"to_number": "+15559876543"]}]); + } + } catch (RelayError $e) { + echo "Error {$e->code}: {$e->message}"; + $call->hangup(); + } + +$client->run(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/addresses/create.mdx b/fern/products/sdks/pages/reference/php/rest/addresses/create.mdx new file mode 100644 index 000000000..d538002fc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/addresses/create.mdx @@ -0,0 +1,67 @@ +--- +title: "create" +slug: /reference/php/rest/addresses/create +description: Create a new regulatory address. +max-toc-depth: 3 +--- + +Create a new regulatory address. + +## **Parameters** + + + The customer or business name for the address. + + + + Street address. + + + + City name. + + + + State or province. + + + + Postal or ZIP code. + + + + ISO country code (e.g., `"US"`). + + + + Additional address fields as needed by the API. + + +## **Returns** + +`dict` -- The newly created address object. + +## **Example** + +```php {9} +addresses->create( + customer_name: "Acme Corp", + street: "123 Main St", + city: "Austin", + state: "TX", + postal_code: "78701", + country: "US", +); +echo "Created address:", $addr["id"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/addresses/delete.mdx b/fern/products/sdks/pages/reference/php/rest/addresses/delete.mdx new file mode 100644 index 000000000..4cda7c938 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/addresses/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/addresses/delete +description: Delete an address from the project. +max-toc-depth: 3 +--- + +Delete an address from the project. + +## **Parameters** + + + The address resource ID. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +addresses->delete("address-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/addresses/get.mdx b/fern/products/sdks/pages/reference/php/rest/addresses/get.mdx new file mode 100644 index 000000000..070e02053 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/addresses/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/addresses/get +description: Retrieve a specific address. +max-toc-depth: 3 +--- + +Retrieve a specific address. + +## **Parameters** + + + The address resource ID. + + +## **Returns** + +`dict` -- The address object. + +## **Example** + +```php {9-10} +addresses->get("address-id"); +echo $addr["customer_name"] ?? null, $addr["street"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/addresses/index.mdx b/fern/products/sdks/pages/reference/php/rest/addresses/index.mdx new file mode 100644 index 000000000..7244a5061 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/addresses/index.mdx @@ -0,0 +1,53 @@ +--- +title: "Addresses" +slug: /reference/php/rest/addresses +description: "Manage regulatory addresses." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/addresses/list +[create]: /docs/sdks/reference/php/rest/addresses/create +[get]: /docs/sdks/reference/php/rest/addresses/get +[delete]: /docs/sdks/reference/php/rest/addresses/delete + +Manage regulatory addresses associated with your SignalWire project. Addresses +are required for phone number compliance in certain regions. This resource +supports list, create, get, and delete -- but not update. + +Access via `client.addresses` on a [`RestClient`][restclient] instance. + +```php +addresses->list(); +foreach ($addresses["data"] ?? [] as $addr) { + echo $addr["id"], $addr["friendly_name"] ?? null; +} + + +``` + +## **Methods** + + + + List addresses in the project. + + + Create a new regulatory address. + + + Retrieve a specific address. + + + Delete an address from the project. + + diff --git a/fern/products/sdks/pages/reference/php/rest/addresses/list.mdx b/fern/products/sdks/pages/reference/php/rest/addresses/list.mdx new file mode 100644 index 000000000..a2766570c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/addresses/list.mdx @@ -0,0 +1,38 @@ +--- +title: "list" +slug: /reference/php/rest/addresses/list +description: List addresses in the project. +max-toc-depth: 3 +--- + +List addresses in the project. + +## **Parameters** + + + Optional query parameters to filter and paginate results. + + +## **Returns** + +`dict` -- JSON response containing a `data` list of address objects. + +## **Example** + +```php {9} +addresses->list(); +foreach ($result["data"] ?? [] as $addr) { + echo $addr["friendly_name"] ?? null, $addr["street"] ?? null; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/ai-hold.mdx b/fern/products/sdks/pages/reference/php/rest/calling/ai-hold.mdx new file mode 100644 index 000000000..4c2beaf59 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/ai-hold.mdx @@ -0,0 +1,37 @@ +--- +title: "aiHold" +slug: /reference/php/rest/calling/ai-hold +description: Put an active AI session on hold via REST. +max-toc-depth: 3 +--- + +Put an active AI session on hold. The AI agent stops processing speech +while the call remains connected. This is useful for transferring the +caller to a human agent or performing background operations. + +## **Parameters** + + + The ID of the call with an active AI session. + + +## **Returns** + +`dict` — The API response confirming the AI session was put on hold. + +## **Example** + +```php {9-9} +calling->ai_hold(call_id: "call-id-xxx"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/ai-message.mdx b/fern/products/sdks/pages/reference/php/rest/calling/ai-message.mdx new file mode 100644 index 000000000..65a414106 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/ai-message.mdx @@ -0,0 +1,51 @@ +--- +title: "aiMessage" +slug: /reference/php/rest/calling/ai-message +description: Send a message to an active AI session on a call via REST. +max-toc-depth: 3 +--- + +Send a message to an active AI session on a call. This injects instructions +or context into the AI agent's conversation without the caller hearing the +message directly. + +## **Parameters** + + + The ID of the call with an active AI session. + + + + The message text to send to the AI agent. The agent processes this as + additional context or instruction. + + + + The role of the message sender. Typically `"system"` or `"user"`. + + +## **Returns** + +`dict` — The API response confirming the message was delivered. + +## **Example** + +```php {10} +calling->ai_message( + call_id: "call-id-xxx", + message_text: "The caller's account has been verified. You can proceed with the transfer.", + role: "system", +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/ai-stop.mdx b/fern/products/sdks/pages/reference/php/rest/calling/ai-stop.mdx new file mode 100644 index 000000000..b583000f6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/ai-stop.mdx @@ -0,0 +1,42 @@ +--- +title: "aiStop" +slug: /reference/php/rest/calling/ai-stop +description: Stop an active AI session on a call via REST. +max-toc-depth: 3 +--- + +Stop an active AI session on a call. The AI agent is disconnected but +the call itself remains active, allowing further call control operations. + +## **Parameters** + + + The ID of the call with an active AI session. + + +## **Returns** + +`dict` — The API response confirming the AI session was stopped. + +## **Example** + +```php {10} +calling->ai_stop(call_id: "call-id-xxx"); +$client->calling->play( + call_id: "call-id-xxx", + play: [["type" => "tts", "text": "Thank you for calling. Goodbye!"]] +); +$client->calling->end(call_id: "call-id-xxx", reason: "hangup"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/ai-unhold.mdx b/fern/products/sdks/pages/reference/php/rest/calling/ai-unhold.mdx new file mode 100644 index 000000000..9453f5523 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/ai-unhold.mdx @@ -0,0 +1,43 @@ +--- +title: "aiUnhold" +slug: /reference/php/rest/calling/ai-unhold +description: Resume a held AI session on a call via REST. +max-toc-depth: 3 +--- + +[ai-hold]: /docs/sdks/reference/php/rest/calling/ai-hold + +Resume an AI session that was previously put on hold with +[`ai_hold()`][ai-hold]. + +## **Parameters** + + + The ID of the call with a held AI session. + + +## **Returns** + +`dict` — The API response confirming the AI session was resumed. + +## **Example** + +```php {14} +calling->ai_hold(call_id: "call-id-xxx"); + +// ... do some background processing ... + +$client->calling->ai_unhold(call_id: "call-id-xxx"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/collect-start-input-timers.mdx b/fern/products/sdks/pages/reference/php/rest/calling/collect-start-input-timers.mdx new file mode 100644 index 000000000..9e58b41f8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/collect-start-input-timers.mdx @@ -0,0 +1,60 @@ +--- +title: "collectStartInputTimers" +slug: /reference/php/rest/calling/collect-start-input-timers +description: Manually start input timers for a collection on a call via REST. +max-toc-depth: 3 +--- + +[collect]: /docs/sdks/reference/php/rest/calling/collect + +Manually start the input timers for a collection that was started without +automatic timer activation. This is useful when you want to play a prompt +before starting the timer countdown. + +## **Parameters** + + + The ID of the call. + + + + The control ID returned from [`collect()`][collect]. + + +## **Returns** + +`dict` — The API response confirming the input timers were started. + +## **Example** + +```php {23} +calling->collect( + call_id: "call-id-xxx", + collect: ["digits" => {"max": 4, "terminators": "#"]}, +); +$control_id = $result["control_id"] ?? null; + +// Play a prompt first +$client->calling->play( + call_id: "call-id-xxx", + play: [["type" => "tts", "text": "Please enter your 4-digit PIN."]] +); + +// Now start the input timers +$client->calling->collect_start_input_timers( + call_id: "call-id-xxx", + control_id: $control_id, +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/collect-stop.mdx b/fern/products/sdks/pages/reference/php/rest/calling/collect-stop.mdx new file mode 100644 index 000000000..a809cdd4a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/collect-stop.mdx @@ -0,0 +1,41 @@ +--- +title: "collectStop" +slug: /reference/php/rest/calling/collect-stop +description: Stop an active input collection on a call via REST. +max-toc-depth: 3 +--- + +[collect]: /docs/sdks/reference/php/rest/calling/collect + +Stop an active input collection. + +## **Parameters** + + + The ID of the call. + + + + The control ID returned from [`collect()`][collect]. + + +## **Returns** + +`dict` — The API response confirming collection was stopped. + +## **Example** + +```php {9-9} +calling->collect_stop(call_id: "call-id-xxx", control_id: "ctrl-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/collect.mdx b/fern/products/sdks/pages/reference/php/rest/calling/collect.mdx new file mode 100644 index 000000000..d5da8e1b1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/collect.mdx @@ -0,0 +1,109 @@ +--- +title: "collect" +slug: /reference/php/rest/calling/collect +description: Collect user input (DTMF or speech) on an active call via REST. +max-toc-depth: 3 +--- + +Start collecting user input on an active call. Supports DTMF digit collection +and speech recognition. Returns a `control_id` for managing the collection. + +## **Parameters** + + + The ID of the call to collect input on. + + + + Collection configuration. Supports the following keys: + + - `digits` — DTMF digit collection settings (e.g., `{"max": 4, "terminators": "#"}`) + - `speech` — Speech recognition settings (e.g., `{"end_silence_timeout": 1.0}`) + + + + Seconds to wait for the first input before timing out. + + + + Whether to send partial speech recognition results as events. + + +## **Returns** + +`dict` — The API response containing the `control_id`. + +## **Examples** + +### Collect DTMF Digits + +```php {10} +calling->collect( + call_id: "call-id-xxx", + collect: { + "digits": ["max" => 4, "terminators": "#", "digit_timeout": 5.0] + }, + initial_timeout: 10.0, +); + + +``` + +### Collect Speech + +```php {9} +calling->collect( + call_id: "call-id-xxx", + collect: { + "speech": { + "end_silence_timeout": 1.0, + "language": "en-US", + } + }, +); + + +``` + +### Collect Both + +```php {9} +calling->collect( + call_id: "call-id-xxx", + collect: { + "digits": ["max" => 1, "terminators": "#"], + "speech": ["end_silence_timeout" => 2.0], + }, + initial_timeout: 15.0, +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/denoise-stop.mdx b/fern/products/sdks/pages/reference/php/rest/calling/denoise-stop.mdx new file mode 100644 index 000000000..4532fb345 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/denoise-stop.mdx @@ -0,0 +1,35 @@ +--- +title: "denoiseStop" +slug: /reference/php/rest/calling/denoise-stop +description: Disable noise reduction on an active call via REST. +max-toc-depth: 3 +--- + +Disable noise reduction on an active call. + +## **Parameters** + + + The ID of the call. + + +## **Returns** + +`dict` — The API response confirming noise reduction was disabled. + +## **Example** + +```php {9-9} +calling->denoise_stop(call_id: "call-id-xxx"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/denoise.mdx b/fern/products/sdks/pages/reference/php/rest/calling/denoise.mdx new file mode 100644 index 000000000..a06d7c4fc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/denoise.mdx @@ -0,0 +1,36 @@ +--- +title: "denoise" +slug: /reference/php/rest/calling/denoise +description: Enable noise reduction on an active call via REST. +max-toc-depth: 3 +--- + +Enable noise reduction on an active call. This applies real-time noise +suppression to the audio stream, improving clarity for both parties. + +## **Parameters** + + + The ID of the call to enable noise reduction on. + + +## **Returns** + +`dict` — The API response confirming noise reduction was enabled. + +## **Example** + +```php {9-9} +calling->denoise(call_id: "call-id-xxx"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/detect-stop.mdx b/fern/products/sdks/pages/reference/php/rest/calling/detect-stop.mdx new file mode 100644 index 000000000..d608d696f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/detect-stop.mdx @@ -0,0 +1,41 @@ +--- +title: "detectStop" +slug: /reference/php/rest/calling/detect-stop +description: Stop an active detector on a call via REST. +max-toc-depth: 3 +--- + +[detect]: /docs/sdks/reference/php/rest/calling/detect + +Stop an active detector. + +## **Parameters** + + + The ID of the call. + + + + The control ID returned from [`detect()`][detect]. + + +## **Returns** + +`dict` — The API response confirming the detector was stopped. + +## **Example** + +```php {9-9} +calling->detect_stop(call_id: "call-id-xxx", control_id: "ctrl-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/detect.mdx b/fern/products/sdks/pages/reference/php/rest/calling/detect.mdx new file mode 100644 index 000000000..f9885655e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/detect.mdx @@ -0,0 +1,101 @@ +--- +title: "detect" +slug: /reference/php/rest/calling/detect +description: Start detection (answering machine, fax, DTMF) on a call via REST. +max-toc-depth: 3 +--- + +Start a detector on an active call. Detectors can identify answering machines, +fax tones, or DTMF digits. Returns a `control_id` for managing the detector. + +## **Parameters** + + + The ID of the call to run detection on. + + + + Detection configuration. Contains a `type` field and type-specific parameters: + + - `"machine"` — Answering machine detection (AMD). Optional: `initial_timeout`, `end_silence_timeout`, `machine_voice_threshold`. + - `"fax"` — Fax tone detection. Optional: `tone`. + - `"digit"` — DTMF digit detection. Optional: `digits`. + + + + Maximum seconds to run detection before automatically stopping. + + +## **Returns** + +`dict` — The API response containing the `control_id`. + +## **Examples** + +### Answering Machine Detection + +```php {10} +calling->detect( + call_id: "call-id-xxx", + detect: { + "type": "machine", + "params": { + "initial_timeout": 4.5, + "end_silence_timeout": 1.0, + } + }, + timeout: 30.0, +); + + +``` + +### Fax Detection + +```php {9} +calling->detect( + call_id: "call-id-xxx", + detect: ["type" => "fax", "params": {"tone": "CED"]} +); + + +``` + +### Digit Detection + +```php {9} +calling->detect( + call_id: "call-id-xxx", + detect: ["type" => "digit", "params": {"digits": "0123456789#*"]} +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/dial.mdx b/fern/products/sdks/pages/reference/php/rest/calling/dial.mdx new file mode 100644 index 000000000..ae4c9a4c5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/dial.mdx @@ -0,0 +1,51 @@ +--- +title: "dial" +slug: /reference/php/rest/calling/dial +description: Initiate a new outbound call via REST. +max-toc-depth: 3 +--- + +Initiate a new outbound call. + +## **Parameters** + + + A list of device groups to dial. Each group is a list of device objects. Groups are + tried sequentially; devices within a group are dialed simultaneously. + + Each device object contains: + - `type` — `"phone"` or `"sip"` + - `params` — device-specific parameters (e.g., `to_number`, `from_number`) + + + + The region to originate the call from. + + + + Custom tag to associate with the call for filtering or identification. + + +## **Returns** + +`dict` — The API response containing the call ID and initial call state. + +## **Example** + +```php {9} +calling->dial( + devices: [[["type" => "phone", "params": {"to_number": "+15559876543", "from_number": "+15551234567"]}]] +); +echo $result; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/disconnect.mdx b/fern/products/sdks/pages/reference/php/rest/calling/disconnect.mdx new file mode 100644 index 000000000..38beff806 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/disconnect.mdx @@ -0,0 +1,36 @@ +--- +title: "disconnect" +slug: /reference/php/rest/calling/disconnect +description: Disconnect (unbridge) a connected call without ending either leg via REST. +max-toc-depth: 3 +--- + +Disconnect (unbridge) a connected call. If two call legs are bridged together, +this separates them without ending either leg. + +## **Parameters** + + + The ID of the call to disconnect. + + +## **Returns** + +`dict` — The API response confirming the disconnect. + +## **Example** + +```php {9-9} +calling->disconnect(call_id: "call-id-xxx"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/end.mdx b/fern/products/sdks/pages/reference/php/rest/calling/end.mdx new file mode 100644 index 000000000..6315d877d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/end.mdx @@ -0,0 +1,43 @@ +--- +title: "end" +slug: /reference/php/rest/calling/end +description: End an active call via REST. +max-toc-depth: 3 +--- + +End an active call. + +## **Parameters** + + + The ID of the call to end. + + + + The reason for ending the call. + + - `"hangup"` -- normal call termination + - `"busy"` -- end the call with a busy signal + - `"cancel"` -- cancel the call before it is answered + + +## **Returns** + +`dict` — The API response confirming the call was ended. + +## **Example** + +```php {9-9} +calling->end(call_id: "call-id-xxx", reason: "hangup"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/get-base-path.mdx b/fern/products/sdks/pages/reference/php/rest/calling/get-base-path.mdx new file mode 100644 index 000000000..92c1333f5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/get-base-path.mdx @@ -0,0 +1,35 @@ +--- +title: "getBasePath" +slug: /reference/php/rest/calling/get-base-path +description: Get the base path of the Calling namespace. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/calling + +Get the base path of the Calling namespace. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- The base path value. + +## **Example** + +```php +calling(); + +$result = $calling->getBasePath(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/get-client.mdx b/fern/products/sdks/pages/reference/php/rest/calling/get-client.mdx new file mode 100644 index 000000000..a4dd9e64f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/get-client.mdx @@ -0,0 +1,35 @@ +--- +title: "getClient" +slug: /reference/php/rest/calling/get-client +description: Get the client of the Calling namespace. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/calling + +Get the client of the Calling namespace. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`HttpClient` -- The underlying HTTP client. + +## **Example** + +```php +calling(); + +$result = $calling->getClient(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/get-project-id.mdx b/fern/products/sdks/pages/reference/php/rest/calling/get-project-id.mdx new file mode 100644 index 000000000..ba8eec3cb --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/get-project-id.mdx @@ -0,0 +1,35 @@ +--- +title: "getProjectId" +slug: /reference/php/rest/calling/get-project-id +description: Get the project id of the Calling namespace. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/calling + +Get the project id of the Calling namespace. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- The project id value. + +## **Example** + +```php +calling(); + +$result = $calling->getProjectId(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/index.mdx b/fern/products/sdks/pages/reference/php/rest/calling/index.mdx new file mode 100644 index 000000000..b2c31e346 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/index.mdx @@ -0,0 +1,253 @@ +--- +title: "Calling" +slug: /reference/php/rest/calling +description: REST-based call control namespace with 37 commands for managing active calls. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[dial]: /docs/sdks/reference/php/rest/calling/dial +[update]: /docs/sdks/reference/php/rest/calling/update +[end]: /docs/sdks/reference/php/rest/calling/end +[transfer]: /docs/sdks/reference/php/rest/calling/transfer +[disconnect]: /docs/sdks/reference/php/rest/calling/disconnect +[play]: /docs/sdks/reference/php/rest/calling/play +[playpause]: /docs/sdks/reference/php/rest/calling/play-pause +[playresume]: /docs/sdks/reference/php/rest/calling/play-resume +[playstop]: /docs/sdks/reference/php/rest/calling/play-stop +[playvolume]: /docs/sdks/reference/php/rest/calling/play-volume +[record]: /docs/sdks/reference/php/rest/calling/record +[recordpause]: /docs/sdks/reference/php/rest/calling/record-pause +[recordresume]: /docs/sdks/reference/php/rest/calling/record-resume +[recordstop]: /docs/sdks/reference/php/rest/calling/record-stop +[collect]: /docs/sdks/reference/php/rest/calling/collect +[collectstop]: /docs/sdks/reference/php/rest/calling/collect-stop +[collectstartinputtimers]: /docs/sdks/reference/php/rest/calling/collect-start-input-timers +[detect]: /docs/sdks/reference/php/rest/calling/detect +[detectstop]: /docs/sdks/reference/php/rest/calling/detect-stop +[tap]: /docs/sdks/reference/php/rest/calling/tap +[tapstop]: /docs/sdks/reference/php/rest/calling/tap-stop +[stream]: /docs/sdks/reference/php/rest/calling/stream +[streamstop]: /docs/sdks/reference/php/rest/calling/stream-stop +[denoise]: /docs/sdks/reference/php/rest/calling/denoise +[denoisestop]: /docs/sdks/reference/php/rest/calling/denoise-stop +[transcribe]: /docs/sdks/reference/php/rest/calling/transcribe +[transcribestop]: /docs/sdks/reference/php/rest/calling/transcribe-stop +[livetranscribe]: /docs/sdks/reference/php/rest/calling/live-transcribe +[livetranslate]: /docs/sdks/reference/php/rest/calling/live-translate +[aimessage]: /docs/sdks/reference/php/rest/calling/ai-message +[aihold]: /docs/sdks/reference/php/rest/calling/ai-hold +[aiunhold]: /docs/sdks/reference/php/rest/calling/ai-unhold +[aistop]: /docs/sdks/reference/php/rest/calling/ai-stop +[sendfaxstop]: /docs/sdks/reference/php/rest/calling/send-fax-stop +[receivefaxstop]: /docs/sdks/reference/php/rest/calling/receive-fax-stop +[refer]: /docs/sdks/reference/php/rest/calling/refer +[userevent]: /docs/sdks/reference/php/rest/calling/user-event + +The `CallingNamespace` provides REST-based call control through the +[`RestClient`][restclient]. All 37 commands are dispatched +as POST requests to a single endpoint (`/api/calling/calls`) with a `command` field +identifying the operation. + +Access via `client.calling` on a [`RestClient`][restclient] instance. + + +Unlike the RELAY client which uses persistent WebSocket connections, the Calling namespace +sends each command as an independent HTTP request. This is suitable for server-side +orchestration where you do not need real-time event streams. + + +## **Methods** + +### Call Lifecycle + + + + Initiate a new outbound call via REST. + + + Update parameters on an active call via REST. + + + End an active call via REST. + + + +### Call Control + + + + Transfer an active call to a new destination via REST. + + + Disconnect (unbridge) a connected call without ending either leg via REST. + + + +### Media and Playback + + + + Play audio or text-to-speech on an active call via REST. + + + Pause an active playback on a call via REST. + + + Resume a paused playback on a call via REST. + + + Stop an active playback on a call via REST. + + + Adjust the volume of an active playback on a call via REST. + + + +### Recording + + + + Start recording an active call via REST. + + + Pause an active recording on a call via REST. + + + Resume a paused recording on a call via REST. + + + Stop an active recording on a call via REST. + + + +### Input Collection + + + + Collect user input (DTMF or speech) on an active call via REST. + + + Stop an active input collection on a call via REST. + + + Manually start input timers for a collection on a call via REST. + + + +### Detection + + + + Start detection (answering machine, fax, DTMF) on a call via REST. + + + Stop an active detector on a call via REST. + + + +### Audio Tap + + + + Tap call audio to an external endpoint via REST. + + + Stop an active audio tap on a call via REST. + + + +### Audio Streaming + + + + Stream call audio to a WebSocket endpoint via REST. + + + Stop an active audio stream on a call via REST. + + + +### Noise Reduction + + + + Enable noise reduction on an active call via REST. + + + Disable noise reduction on an active call via REST. + + + +### Transcription and Translation + + + + Start transcribing speech on an active call via REST. + + + Stop an active transcription on a call via REST. + + + Start live transcription with partial results on a call via REST. + + + Start live translation on an active call via REST. + + + +### AI Session Control + + + + Send a message to an active AI session on a call via REST. + + + Put an active AI session on hold via REST. + + + Resume a held AI session on a call via REST. + + + Stop an active AI session on a call via REST. + + + +### Fax + + + + Stop an in-progress fax send operation on a call via REST. + + + Stop an in-progress fax receive operation on a call via REST. + + + +### SIP + + + + Send a SIP REFER to transfer a call at the SIP level via REST. + + + +### Custom Events + + + + Send custom user-defined events on an active call via REST. + + + Get the base API path. + + + Get the REST client instance. + + + Get the project ID. + + + Update an active call. + + diff --git a/fern/products/sdks/pages/reference/php/rest/calling/live-transcribe.mdx b/fern/products/sdks/pages/reference/php/rest/calling/live-transcribe.mdx new file mode 100644 index 000000000..83bbe3b00 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/live-transcribe.mdx @@ -0,0 +1,44 @@ +--- +title: "liveTranscribe" +slug: /reference/php/rest/calling/live-transcribe +description: Start live transcription with partial results on a call via REST. +max-toc-depth: 3 +--- + +Start live transcription on an active call. Unlike standard transcription, +live transcription streams partial results in real time as the caller speaks, +enabling display of in-progress speech. + +## **Parameters** + + + The ID of the call. + + + + Language code for transcription (e.g., `"en-US"`). + + +## **Returns** + +`dict` — The API response confirming live transcription was started. + +## **Example** + +```php {9} +calling->live_transcribe( + call_id: "call-id-xxx", + language: "en-US", +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/live-translate.mdx b/fern/products/sdks/pages/reference/php/rest/calling/live-translate.mdx new file mode 100644 index 000000000..12716455e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/live-translate.mdx @@ -0,0 +1,48 @@ +--- +title: "liveTranslate" +slug: /reference/php/rest/calling/live-translate +description: Start live translation on an active call via REST. +max-toc-depth: 3 +--- + +Start live translation on an active call. Spoken audio is transcribed and +translated in real time to a target language. + +## **Parameters** + + + The ID of the call. + + + + The language being spoken on the call (e.g., `"en-US"`). + + + + The language to translate into (e.g., `"es-ES"`). + + +## **Returns** + +`dict` — The API response confirming live translation was started. + +## **Example** + +```php {9} +calling->live_translate( + call_id: "call-id-xxx", + source_language: "en-US", + target_language: "es-ES", +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/play-pause.mdx b/fern/products/sdks/pages/reference/php/rest/calling/play-pause.mdx new file mode 100644 index 000000000..c24ac1691 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/play-pause.mdx @@ -0,0 +1,41 @@ +--- +title: "playPause" +slug: /reference/php/rest/calling/play-pause +description: Pause an active playback on a call via REST. +max-toc-depth: 3 +--- + +[play]: /docs/sdks/reference/php/rest/calling/play + +Pause an active playback. + +## **Parameters** + + + The ID of the call. + + + + The control ID returned from [`play()`][play]. + + +## **Returns** + +`dict` — The API response confirming playback was paused. + +## **Example** + +```php {9-9} +calling->play_pause(call_id: "call-id-xxx", control_id: "ctrl-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/play-resume.mdx b/fern/products/sdks/pages/reference/php/rest/calling/play-resume.mdx new file mode 100644 index 000000000..afe66e0c9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/play-resume.mdx @@ -0,0 +1,41 @@ +--- +title: "playResume" +slug: /reference/php/rest/calling/play-resume +description: Resume a paused playback on a call via REST. +max-toc-depth: 3 +--- + +[play]: /docs/sdks/reference/php/rest/calling/play + +Resume a paused playback. + +## **Parameters** + + + The ID of the call. + + + + The control ID returned from [`play()`][play]. + + +## **Returns** + +`dict` — The API response confirming playback was resumed. + +## **Example** + +```php {9-9} +calling->play_resume(call_id: "call-id-xxx", control_id: "ctrl-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/play-stop.mdx b/fern/products/sdks/pages/reference/php/rest/calling/play-stop.mdx new file mode 100644 index 000000000..989e69aca --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/play-stop.mdx @@ -0,0 +1,41 @@ +--- +title: "playStop" +slug: /reference/php/rest/calling/play-stop +description: Stop an active playback on a call via REST. +max-toc-depth: 3 +--- + +[play]: /docs/sdks/reference/php/rest/calling/play + +Stop an active playback immediately. + +## **Parameters** + + + The ID of the call. + + + + The control ID returned from [`play()`][play]. + + +## **Returns** + +`dict` — The API response confirming playback was stopped. + +## **Example** + +```php {9-9} +calling->play_stop(call_id: "call-id-xxx", control_id: "ctrl-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/play-volume.mdx b/fern/products/sdks/pages/reference/php/rest/calling/play-volume.mdx new file mode 100644 index 000000000..aa00f4b4b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/play-volume.mdx @@ -0,0 +1,45 @@ +--- +title: "playVolume" +slug: /reference/php/rest/calling/play-volume +description: Adjust the volume of an active playback on a call via REST. +max-toc-depth: 3 +--- + +[play]: /docs/sdks/reference/php/rest/calling/play + +Adjust the volume of an active playback. + +## **Parameters** + + + The ID of the call. + + + + The control ID returned from [`play()`][play]. + + + + Volume level adjustment. Range: `-40.0` to `40.0`. + + +## **Returns** + +`dict` — The API response confirming the volume was adjusted. + +## **Example** + +```php {9-9} +calling->play_volume(call_id: "call-id-xxx", control_id: "ctrl-id", volume: 5.0); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/play.mdx b/fern/products/sdks/pages/reference/php/rest/calling/play.mdx new file mode 100644 index 000000000..63429ab3b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/play.mdx @@ -0,0 +1,110 @@ +--- +title: "play" +slug: /reference/php/rest/calling/play +description: Play audio or text-to-speech on an active call via REST. +max-toc-depth: 3 +--- + +[play-pause]: /docs/sdks/reference/php/rest/calling/play-pause +[play-resume]: /docs/sdks/reference/php/rest/calling/play-resume +[play-stop]: /docs/sdks/reference/php/rest/calling/play-stop +[play-volume]: /docs/sdks/reference/php/rest/calling/play-volume + +Play audio or text-to-speech on an active call. Returns a `control_id` that can be +used with [`play_pause()`][play-pause], +[`play_resume()`][play-resume], +[`play_stop()`][play-stop], and +[`play_volume()`][play-volume] to manage +the playback. + +## **Parameters** + + + The ID of the call to play audio on. + + + + A list of media items to play. Each item is a dict with a `type` field and + type-specific parameters. Supported types: + + - `"audio"` — Play an audio file. Requires `url`. + - `"tts"` — Play text-to-speech. Requires `text`. Optional: `language`, `gender`, `voice`. + - `"silence"` — Play silence. Requires `duration` (in seconds). + - `"ring"` — Play a ring tone. Optional: `duration`. + + + + Initial volume level for playback. Range: `-40.0` to `40.0`. + + +## **Returns** + +`dict` — The API response containing the `control_id` for managing the playback. + +## **Examples** + +### Play TTS + +```php {10} +calling->play( + call_id: "call-id-xxx", + play: [["type" => "tts", "text": "Hello from the REST API!"]] +); +$control_id = $result["control_id"] ?? null; + + +``` + +### Play Audio File + +```php {9} +calling->play( + call_id: "call-id-xxx", + play: [["type" => "audio", "url": "https://example.com/greeting.mp3"]] +); + + +``` + +### Play Multiple Items + +```php {9} +calling->play( + call_id: "call-id-xxx", + play: [ + ["type" => "tts", "text": "Please hold while we connect you."], + ["type" => "silence", "duration": 1], + ["type" => "audio", "url": "https://example.com/hold-music.mp3"], + ] +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/receive-fax-stop.mdx b/fern/products/sdks/pages/reference/php/rest/calling/receive-fax-stop.mdx new file mode 100644 index 000000000..ffdca05b3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/receive-fax-stop.mdx @@ -0,0 +1,46 @@ +--- +title: "receiveFaxStop" +slug: /reference/php/rest/calling/receive-fax-stop +description: Stop an in-progress fax receive operation on a call via REST. +max-toc-depth: 3 +--- + +[receive-fax]: /docs/sdks/reference/php/relay/call/receive-fax + +Stop an in-progress fax receive operation on an active call. + + +This method stops a fax receive that is already in progress. To initiate fax receiving, +use the RELAY client's [`receive_fax()`][receive-fax] method. + + +## **Parameters** + + + The ID of the call with an active fax receive operation. + + + + The control ID of the fax receive operation to stop. + + +## **Returns** + +`dict` — The API response confirming the fax receive was stopped. + +## **Example** + +```php {9-9} +calling->receive_fax_stop(call_id: "call-id-xxx", control_id: "ctrl-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/record-pause.mdx b/fern/products/sdks/pages/reference/php/rest/calling/record-pause.mdx new file mode 100644 index 000000000..69aff0a26 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/record-pause.mdx @@ -0,0 +1,43 @@ +--- +title: "recordPause" +slug: /reference/php/rest/calling/record-pause +description: Pause an active recording on a call via REST. +max-toc-depth: 3 +--- + +[record-resume]: /docs/sdks/reference/php/rest/calling/record-resume +[record]: /docs/sdks/reference/php/rest/calling/record + +Pause an active recording. The recording can be resumed later with +[`record_resume()`][record-resume]. + +## **Parameters** + + + The ID of the call. + + + + The control ID returned from [`record()`][record]. + + +## **Returns** + +`dict` — The API response confirming the recording was paused. + +## **Example** + +```php {9-9} +calling->record_pause(call_id: "call-id-xxx", control_id: "ctrl-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/record-resume.mdx b/fern/products/sdks/pages/reference/php/rest/calling/record-resume.mdx new file mode 100644 index 000000000..33c132990 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/record-resume.mdx @@ -0,0 +1,41 @@ +--- +title: "recordResume" +slug: /reference/php/rest/calling/record-resume +description: Resume a paused recording on a call via REST. +max-toc-depth: 3 +--- + +[record]: /docs/sdks/reference/php/rest/calling/record + +Resume a paused recording. + +## **Parameters** + + + The ID of the call. + + + + The control ID returned from [`record()`][record]. + + +## **Returns** + +`dict` — The API response confirming the recording was resumed. + +## **Example** + +```php {9-9} +calling->record_resume(call_id: "call-id-xxx", control_id: "ctrl-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/record-stop.mdx b/fern/products/sdks/pages/reference/php/rest/calling/record-stop.mdx new file mode 100644 index 000000000..04edbad2c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/record-stop.mdx @@ -0,0 +1,42 @@ +--- +title: "recordStop" +slug: /reference/php/rest/calling/record-stop +description: Stop an active recording on a call via REST. +max-toc-depth: 3 +--- + +[record]: /docs/sdks/reference/php/rest/calling/record + +Stop an active recording. The recording file becomes available after stopping. + +## **Parameters** + + + The ID of the call. + + + + The control ID returned from [`record()`][record]. + + +## **Returns** + +`dict` — The API response containing the recording URL and metadata. + +## **Example** + +```php {9} +calling->record_stop(call_id: "call-id-xxx", control_id: "ctrl-id"); +echo $result; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/record.mdx b/fern/products/sdks/pages/reference/php/rest/calling/record.mdx new file mode 100644 index 000000000..5d62db9e1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/record.mdx @@ -0,0 +1,59 @@ +--- +title: "record" +slug: /reference/php/rest/calling/record +description: Start recording an active call via REST. +max-toc-depth: 3 +--- + +[pause]: /docs/sdks/reference/php/rest/calling/record-pause +[resume]: /docs/sdks/reference/php/rest/calling/record-resume +[stop]: /docs/sdks/reference/php/rest/calling/record-stop + +Start recording an active call. Returns a `control_id` used to +[pause][pause], +[resume][resume], +or [stop][stop] the recording. + +## **Parameters** + + + The ID of the call to record. + + + + Recording configuration object. Contains: + + - `audio` — Audio recording settings (e.g., `{"format": "mp3", "stereo": true}`) + + + + Which leg of the call to record. + + - `"self"` -- record only the audio from the call's own leg + - `"both"` -- record audio from both legs of the call + + +## **Returns** + +`dict` — The API response containing the `control_id` for managing the recording. + +## **Example** + +```php {9} +calling->record( + call_id: "call-id-xxx", + record: ["audio" => {"format": "mp3", "stereo": true]} +); +$control_id = $result["control_id"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/refer.mdx b/fern/products/sdks/pages/reference/php/rest/calling/refer.mdx new file mode 100644 index 000000000..8e26200d7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/refer.mdx @@ -0,0 +1,52 @@ +--- +title: "refer" +slug: /reference/php/rest/calling/refer +description: Send a SIP REFER to transfer a call at the SIP level via REST. +max-toc-depth: 3 +--- + +[transfer]: /docs/sdks/reference/php/rest/calling/transfer + +Send a SIP REFER on an active call. This initiates a SIP-level transfer, +asking the remote endpoint to connect to a new destination. Unlike +[`transfer()`][transfer], which is +handled by SignalWire, a SIP REFER delegates the transfer to the remote +SIP endpoint. + + +SIP REFER is only applicable to SIP calls. It will not work on PSTN calls. + + +## **Parameters** + + + The ID of the SIP call. + + + + The SIP URI to refer the call to (e.g., `"sip:user@example.com"`). + + +## **Returns** + +`dict` — The API response confirming the SIP REFER was sent. + +## **Example** + +```php {9} +calling->refer( + call_id: "call-id-xxx", + refer_to: "sip:sales@example.com", +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/send-fax-stop.mdx b/fern/products/sdks/pages/reference/php/rest/calling/send-fax-stop.mdx new file mode 100644 index 000000000..17ed51a89 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/send-fax-stop.mdx @@ -0,0 +1,46 @@ +--- +title: "sendFaxStop" +slug: /reference/php/rest/calling/send-fax-stop +description: Stop an in-progress fax send operation on a call via REST. +max-toc-depth: 3 +--- + +[send-fax]: /docs/sdks/reference/php/relay/call/send-fax + +Stop an in-progress fax send operation on an active call. + + +This method stops a fax send that is already in progress. To initiate fax sending, +use the RELAY client's [`send_fax()`][send-fax] method. + + +## **Parameters** + + + The ID of the call with an active fax send operation. + + + + The control ID of the fax send operation to stop. + + +## **Returns** + +`dict` — The API response confirming the fax send was stopped. + +## **Example** + +```php {9-9} +calling->send_fax_stop(call_id: "call-id-xxx", control_id: "ctrl-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/stream-stop.mdx b/fern/products/sdks/pages/reference/php/rest/calling/stream-stop.mdx new file mode 100644 index 000000000..91492dd9a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/stream-stop.mdx @@ -0,0 +1,41 @@ +--- +title: "streamStop" +slug: /reference/php/rest/calling/stream-stop +description: Stop an active audio stream on a call via REST. +max-toc-depth: 3 +--- + +[stream]: /docs/sdks/reference/php/rest/calling/stream + +Stop an active audio stream. + +## **Parameters** + + + The ID of the call. + + + + The control ID returned from [`stream()`][stream]. + + +## **Returns** + +`dict` — The API response confirming the stream was stopped. + +## **Example** + +```php {9-9} +calling->stream_stop(call_id: "call-id-xxx", control_id: "ctrl-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/stream.mdx b/fern/products/sdks/pages/reference/php/rest/calling/stream.mdx new file mode 100644 index 000000000..7c9de54fa --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/stream.mdx @@ -0,0 +1,60 @@ +--- +title: "stream" +slug: /reference/php/rest/calling/stream +description: Stream call audio to a WebSocket endpoint via REST. +max-toc-depth: 3 +--- + +Start streaming audio from an active call to a WebSocket endpoint. This is +commonly used for real-time speech processing, analytics, or archival. +Returns a `control_id` for stopping the stream. + +## **Parameters** + + + The ID of the call to stream audio from. + + + + The WebSocket URL to stream audio to (e.g., `"wss://example.com/stream"`). + + + + Which audio channel to stream. + + - `"self"` -- stream only the audio from the call's own leg + - `"both"` -- stream audio from both legs of the call + + + + Audio codec for the stream. + + - `"PCMU"` -- G.711 mu-law codec (8 kHz, North America/Japan standard) + - `"PCMA"` -- G.711 A-law codec (8 kHz, international standard) + - `"OPUS"` -- Opus codec (variable bitrate, high quality) + + +## **Returns** + +`dict` — The API response containing the `control_id`. + +## **Example** + +```php {9} +calling->stream( + call_id: "call-id-xxx", + url: "wss://example.com/audio-stream", +); +$control_id = $result["control_id"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/tap-stop.mdx b/fern/products/sdks/pages/reference/php/rest/calling/tap-stop.mdx new file mode 100644 index 000000000..160e69b3b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/tap-stop.mdx @@ -0,0 +1,41 @@ +--- +title: "tapStop" +slug: /reference/php/rest/calling/tap-stop +description: Stop an active audio tap on a call via REST. +max-toc-depth: 3 +--- + +[tap]: /docs/sdks/reference/php/rest/calling/tap + +Stop an active audio tap. + +## **Parameters** + + + The ID of the call. + + + + The control ID returned from [`tap()`][tap]. + + +## **Returns** + +`dict` — The API response confirming the tap was stopped. + +## **Example** + +```php {9-9} +calling->tap_stop(call_id: "call-id-xxx", control_id: "ctrl-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/tap.mdx b/fern/products/sdks/pages/reference/php/rest/calling/tap.mdx new file mode 100644 index 000000000..4f00d8b67 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/tap.mdx @@ -0,0 +1,56 @@ +--- +title: "tap" +slug: /reference/php/rest/calling/tap +description: Tap call audio to an external endpoint via REST. +max-toc-depth: 3 +--- + +Start tapping audio from an active call and sending it to an external endpoint +(e.g., a WebSocket or RTP destination). Returns a `control_id` for stopping +the tap. + +## **Parameters** + + + The ID of the call to tap audio from. + + + + Tap configuration. Contains: + + - `type` — `"audio"` for audio tapping + - `params` — Direction settings (e.g., `{"direction": "both"}`) + + + + The destination device to send tapped audio to. Contains: + + - `type` — `"ws"` (WebSocket) or `"rtp"` (RTP stream) + - `params` — Connection parameters (e.g., `{"uri": "wss://example.com/tap"}` for WebSocket, or `{"addr": "192.168.1.1", "port": 5000}` for RTP) + + +## **Returns** + +`dict` — The API response containing the `control_id` and connection details. + +## **Example** + +```php {9} +calling->tap( + call_id: "call-id-xxx", + tap: ["type" => "audio", "params": {"direction": "both"]}, + device: ["type" => "ws", "params": {"uri": "wss://example.com/tap"]}, +); +$control_id = $result["control_id"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/transcribe-stop.mdx b/fern/products/sdks/pages/reference/php/rest/calling/transcribe-stop.mdx new file mode 100644 index 000000000..1c3153c2e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/transcribe-stop.mdx @@ -0,0 +1,41 @@ +--- +title: "transcribeStop" +slug: /reference/php/rest/calling/transcribe-stop +description: Stop an active transcription on a call via REST. +max-toc-depth: 3 +--- + +[transcribe]: /docs/sdks/reference/php/rest/calling/transcribe + +Stop an active transcription. + +## **Parameters** + + + The ID of the call. + + + + The control ID returned from [`transcribe()`][transcribe]. + + +## **Returns** + +`dict` — The API response confirming transcription was stopped. + +## **Example** + +```php {9-9} +calling->transcribe_stop(call_id: "call-id-xxx", control_id: "ctrl-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/transcribe.mdx b/fern/products/sdks/pages/reference/php/rest/calling/transcribe.mdx new file mode 100644 index 000000000..2b6c144f6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/transcribe.mdx @@ -0,0 +1,44 @@ +--- +title: "transcribe" +slug: /reference/php/rest/calling/transcribe +description: Start transcribing speech on an active call via REST. +max-toc-depth: 3 +--- + +Start transcribing speech on an active call. Transcription results are delivered +via events. Returns a `control_id` for stopping the transcription. + +## **Parameters** + + + The ID of the call to transcribe. + + + + Language code for transcription (e.g., `"en-US"`, `"es-ES"`). + + +## **Returns** + +`dict` — The API response containing the `control_id`. + +## **Example** + +```php {9} +calling->transcribe( + call_id: "call-id-xxx", + language: "en-US", +); +$control_id = $result["control_id"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/transfer.mdx b/fern/products/sdks/pages/reference/php/rest/calling/transfer.mdx new file mode 100644 index 000000000..c6fb7aa3c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/transfer.mdx @@ -0,0 +1,44 @@ +--- +title: "transfer" +slug: /reference/php/rest/calling/transfer +description: Transfer an active call to a new destination via REST. +max-toc-depth: 3 +--- + +Transfer an active call to a new destination. The current call leg is replaced +by a new connection to the specified target. + +## **Parameters** + + + The ID of the call to transfer. + + + + The transfer destination. Contains `type` (e.g., `"phone"`, `"sip"`) and + type-specific parameters such as `to_number`. + + +## **Returns** + +`dict` — The API response confirming the transfer was initiated. + +## **Example** + +```php {9} +calling->transfer( + call_id: "call-id-xxx", + dest: ["type" => "phone", "params": {"to_number": "+15559876543"]} +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/update-call.mdx b/fern/products/sdks/pages/reference/php/rest/calling/update-call.mdx new file mode 100644 index 000000000..95318487f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/update-call.mdx @@ -0,0 +1,38 @@ +--- +title: "updateCall" +slug: /reference/php/rest/calling/update-call +description: Update a call. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/calling + +Update a call. + +## **Parameters** + + + Additional parameters. + Defaults to `[]`. + + +## **Returns** + +`array` -- The result array. + +## **Example** + +```php +calling(); + +$result = $calling->updateCall(["key" => "value"]); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/update.mdx b/fern/products/sdks/pages/reference/php/rest/calling/update.mdx new file mode 100644 index 000000000..073dfc3eb --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/update.mdx @@ -0,0 +1,41 @@ +--- +title: "update" +slug: /reference/php/rest/calling/update +description: Update parameters on an active call via REST. +max-toc-depth: 3 +--- + +Update parameters on an active call, such as metadata or call settings. + + +Unlike most calling methods, `update()` does **not** take a positional `call_id` +parameter. Pass all fields (including call identification) as keyword arguments. + + +## **Parameters** + + + Keyword arguments forwarded to the SignalWire API. Common fields include + `call_id`, `metadata`, and other call settings. + + +## **Returns** + +`dict` — The API response confirming the update. + +## **Example** + +```php {9-9} +calling->update(call_id: "call-id-xxx", metadata: ["department" => "sales"]); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/calling/user-event.mdx b/fern/products/sdks/pages/reference/php/rest/calling/user-event.mdx new file mode 100644 index 000000000..f771264c7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/calling/user-event.mdx @@ -0,0 +1,50 @@ +--- +title: "userEvent" +slug: /reference/php/rest/calling/user-event +description: Send custom user-defined events on an active call via REST. +max-toc-depth: 3 +--- + +Send a custom user-defined event on an active call. User events allow you +to pass arbitrary data between call control applications and event handlers. +Listeners registered for user events on the RELAY side will receive the +payload you send here. + +## **Parameters** + + + The ID of the call to send the event on. + + + + The name of the custom event (e.g., `"my_app.status_update"`). + + + + Arbitrary key-value data to include in the event payload. + + +## **Returns** + +`dict` — The API response confirming the event was sent. + +## **Example** + +```php {9} +calling->user_event( + call_id: "call-id-xxx", + name: "order.confirmed", + params: ["order_id" => "ORD-12345", "amount": 49.99], +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/chat.mdx b/fern/products/sdks/pages/reference/php/rest/chat.mdx new file mode 100644 index 000000000..593f11418 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/chat.mdx @@ -0,0 +1,72 @@ +--- +title: "Chat" +slug: /reference/php/rest/chat +description: "Chat messaging tokens." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client + +Generate tokens for the SignalWire Chat service. Chat tokens authenticate +client-side connections for real-time chat messaging. + +Access via `client.chat` on a [`RestClient`][restclient] instance. + +```php + + List of channel names the token grants access to. + + + + Identifier for the connecting member. + + + + Token time-to-live in seconds. + + + + Additional token parameters (e.g., `state`, `permissions`). + + +## **Returns** + +`dict` -- The token object containing the JWT token string. + +## **Example** + +```php +chat->create_token( + channels: ["support-room"], + member_id: "user-456", + ttl: 3600, +); +echo "Chat token:", $token["token"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/addresses.mdx b/fern/products/sdks/pages/reference/php/rest/client/addresses.mdx new file mode 100644 index 000000000..e4494659c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/addresses.mdx @@ -0,0 +1,33 @@ +--- +title: "addresses" +slug: /reference/php/rest/client/addresses +description: Add a resses. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Add a resses. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +addresses(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/calling.mdx b/fern/products/sdks/pages/reference/php/rest/client/calling.mdx new file mode 100644 index 000000000..9842dd50f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/calling.mdx @@ -0,0 +1,33 @@ +--- +title: "calling" +slug: /reference/php/rest/client/calling +description: Access the Calling namespace for voice call operations. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Calling namespace for voice call operations. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`Calling` -- The Calling namespace instance. + +## **Example** + +```php +calling(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/chat.mdx b/fern/products/sdks/pages/reference/php/rest/client/chat.mdx new file mode 100644 index 000000000..2a07a14b8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/chat.mdx @@ -0,0 +1,33 @@ +--- +title: "chat" +slug: /reference/php/rest/client/chat +description: Access the Chat resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Chat resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +chat(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/compat.mdx b/fern/products/sdks/pages/reference/php/rest/client/compat.mdx new file mode 100644 index 000000000..f4b682873 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/compat.mdx @@ -0,0 +1,33 @@ +--- +title: "compat" +slug: /reference/php/rest/client/compat +description: Access the Compatibility API resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Compatibility API resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +compat(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/datasphere.mdx b/fern/products/sdks/pages/reference/php/rest/client/datasphere.mdx new file mode 100644 index 000000000..fa2a5623c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/datasphere.mdx @@ -0,0 +1,33 @@ +--- +title: "datasphere" +slug: /reference/php/rest/client/datasphere +description: Access the Datasphere resource for knowledge management. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Datasphere resource for knowledge management. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +datasphere(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/fabric.mdx b/fern/products/sdks/pages/reference/php/rest/client/fabric.mdx new file mode 100644 index 000000000..e0ce406e7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/fabric.mdx @@ -0,0 +1,33 @@ +--- +title: "fabric" +slug: /reference/php/rest/client/fabric +description: Access the Fabric namespace for resource management. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Fabric namespace for resource management. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`Fabric` -- The Fabric namespace instance. + +## **Example** + +```php +fabric(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/get-base-url.mdx b/fern/products/sdks/pages/reference/php/rest/client/get-base-url.mdx new file mode 100644 index 000000000..0f418a3b4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/get-base-url.mdx @@ -0,0 +1,33 @@ +--- +title: "getBaseUrl" +slug: /reference/php/rest/client/get-base-url +description: Get the base url of the REST client. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Get the base url of the REST client. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- The base url value. + +## **Example** + +```php +getBaseUrl(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/get-http.mdx b/fern/products/sdks/pages/reference/php/rest/client/get-http.mdx new file mode 100644 index 000000000..b901debba --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/get-http.mdx @@ -0,0 +1,33 @@ +--- +title: "getHttp" +slug: /reference/php/rest/client/get-http +description: Get the http of the REST client. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Get the http of the REST client. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`HttpClient` -- The underlying HTTP client. + +## **Example** + +```php +getHttp(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/get-project-id.mdx b/fern/products/sdks/pages/reference/php/rest/client/get-project-id.mdx new file mode 100644 index 000000000..8f4874444 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/get-project-id.mdx @@ -0,0 +1,33 @@ +--- +title: "getProjectId" +slug: /reference/php/rest/client/get-project-id +description: Get the project id of the REST client. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Get the project id of the REST client. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- The project id value. + +## **Example** + +```php +getProjectId(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/get-space.mdx b/fern/products/sdks/pages/reference/php/rest/client/get-space.mdx new file mode 100644 index 000000000..b382d7d1d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/get-space.mdx @@ -0,0 +1,33 @@ +--- +title: "getSpace" +slug: /reference/php/rest/client/get-space +description: Get the space of the REST client. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Get the space of the REST client. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- The space value. + +## **Example** + +```php +getSpace(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/get-token.mdx b/fern/products/sdks/pages/reference/php/rest/client/get-token.mdx new file mode 100644 index 000000000..7e06e17c0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/get-token.mdx @@ -0,0 +1,33 @@ +--- +title: "getToken" +slug: /reference/php/rest/client/get-token +description: Get the token of the REST client. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Get the token of the REST client. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`string` -- The token value. + +## **Example** + +```php +getToken(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/imported-numbers.mdx b/fern/products/sdks/pages/reference/php/rest/client/imported-numbers.mdx new file mode 100644 index 000000000..f748756b4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/imported-numbers.mdx @@ -0,0 +1,33 @@ +--- +title: "importedNumbers" +slug: /reference/php/rest/client/imported-numbers +description: Access the Imported Numbers resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Imported Numbers resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +importedNumbers(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/index.mdx b/fern/products/sdks/pages/reference/php/rest/client/index.mdx new file mode 100644 index 000000000..27ae823de --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/index.mdx @@ -0,0 +1,279 @@ +--- +title: "RestClient" +slug: /reference/php/rest/client +description: "HTTP client for the SignalWire REST API." +max-toc-depth: 3 +--- + +[fabric]: /docs/sdks/reference/php/rest/fabric +[calling]: /docs/sdks/reference/php/rest/calling +[phone-numbers]: /docs/sdks/reference/php/rest/phone-numbers +[addresses]: /docs/sdks/reference/php/rest/addresses +[queues]: /docs/sdks/reference/php/rest/queues +[recordings]: /docs/sdks/reference/php/rest/recordings +[number-groups]: /docs/sdks/reference/php/rest/number-groups +[verified-callers]: /docs/sdks/reference/php/rest/verified-callers +[sip-profile]: /docs/sdks/reference/php/rest/sip-profile +[lookup]: /docs/sdks/reference/php/rest/lookup +[short-codes]: /docs/sdks/reference/php/rest/short-codes +[imported-numbers]: /docs/sdks/reference/php/rest/imported-numbers +[mfa]: /docs/sdks/reference/php/rest/mfa +[registry]: /docs/sdks/reference/php/rest/registry +[datasphere]: /docs/sdks/reference/php/rest/datasphere +[video]: /docs/sdks/reference/php/rest/video +[logs]: /docs/sdks/reference/php/rest/logs +[project]: /docs/sdks/reference/php/rest/project +[pubsub]: /docs/sdks/reference/php/rest/pubsub +[chat]: /docs/sdks/reference/php/rest/chat +[compatibility]: /docs/sdks/reference/php/rest/compat + +The `RestClient` is the entry point for all SignalWire REST API operations. +It authenticates with your project credentials and exposes every API namespace +as a property, giving you typed access to phone numbers, fabric resources, +call control, video rooms, datasphere documents, logs, and more. + +## **Constructor Parameters** + + + SignalWire project ID. Falls back to the `SIGNALWIRE_PROJECT_ID` environment variable + when not provided. + + + + API token for authentication. Falls back to the `SIGNALWIRE_API_TOKEN` environment + variable when not provided. + + + + SignalWire space hostname (e.g., `your-space.signalwire.com`). Falls back to the + `SIGNALWIRE_SPACE` environment variable when not provided. + + + +All three parameters are required. If any is missing from both the constructor +arguments and environment variables, a `ValueError` is raised. + + +## **Namespace Properties** + + + AI agents, SWML scripts, subscribers, call flows, SIP gateways, and tokens. + See [`Fabric`][fabric]. + + + + REST-based call control with 37+ commands dispatched via POST. + See [`Calling`][calling]. + + + + Search, purchase, and manage phone numbers. + See [`Phone Numbers`][phone-numbers]. + + + + Manage regulatory addresses. + See [`Addresses`][addresses]. + + + + Manage call queues and queue members. + See [`Queues`][queues]. + + + + List, retrieve, and delete call recordings. + See [`Recordings`][recordings]. + + + + Manage number groups and their memberships. + See [`Number Groups`][number-groups]. + + + + Manage and verify caller IDs. + See [`Verified Callers`][verified-callers]. + + + + Get and update the project SIP profile. + See [`SIP Profile`][sip-profile]. + + + + Phone number carrier and CNAM lookup. + See [`Lookup`][lookup]. + + + + Manage short codes. + See [`Short Codes`][short-codes]. + + + + Import externally-hosted phone numbers. + See [`Imported Numbers`][imported-numbers]. + + + + Multi-factor authentication via SMS and voice. + See [`MFA`][mfa]. + + + + 10DLC brand and campaign registration. + See [`Registry`][registry]. + + + + Document management and semantic search. + See [`Datasphere`][datasphere]. + + + + Video rooms, conferences, sessions, recordings, and streams. + See [`Video`][video]. + + + + Message, voice, fax, and conference log queries. + See [`Logs`][logs]. + + + + Project-level API token management. + See [`Project`][project]. + + + + PubSub token generation. + See [`PubSub`][pubsub]. + + + + Chat token generation. + See [`Chat`][chat]. + + + + Twilio-compatible LAML API for migration. + See [`Compatibility`][compatibility]. + + +## **Examples** + +### Explicit credentials + +```php {3} +phoneNumbers->list(); + + +``` + +### Environment variables + +```php +phoneNumbers->search(area_code: "512"); + + +``` + +## **Methods** + + + + Access the Addresses namespace. + + + Access the Calling namespace. + + + Access the Chat namespace. + + + Access the Compatibility namespace. + + + Access the Datasphere namespace. + + + Access the Fabric namespace. + + + Get the base URL for API requests. + + + Get the HTTP client instance. + + + Get the project ID. + + + Get the space hostname. + + + Get the API token. + + + Access the Imported Numbers namespace. + + + Access the Logs namespace. + + + Access the Lookup namespace. + + + Access the MFA namespace. + + + Access the Number Groups namespace. + + + Access the Phone Numbers namespace. + + + Access the Project namespace. + + + Access the PubSub namespace. + + + Access the Queues namespace. + + + Access the Recordings namespace. + + + Access the Registry namespace. + + + Access the Short Codes namespace. + + + Access the SIP Profile namespace. + + + Access the Verified Callers namespace. + + + Access the Video namespace. + + diff --git a/fern/products/sdks/pages/reference/php/rest/client/logs.mdx b/fern/products/sdks/pages/reference/php/rest/client/logs.mdx new file mode 100644 index 000000000..5d4eb6bbc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/logs.mdx @@ -0,0 +1,33 @@ +--- +title: "logs" +slug: /reference/php/rest/client/logs +description: Access the Logs resource for call and message history. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Logs resource for call and message history. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +logs(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/lookup.mdx b/fern/products/sdks/pages/reference/php/rest/client/lookup.mdx new file mode 100644 index 000000000..4b5a081fa --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/lookup.mdx @@ -0,0 +1,33 @@ +--- +title: "lookup" +slug: /reference/php/rest/client/lookup +description: Access the Lookup resource for phone number information. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Lookup resource for phone number information. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +lookup(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/mfa.mdx b/fern/products/sdks/pages/reference/php/rest/client/mfa.mdx new file mode 100644 index 000000000..d1fbba80d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/mfa.mdx @@ -0,0 +1,33 @@ +--- +title: "mfa" +slug: /reference/php/rest/client/mfa +description: Access the MFA (multi-factor authentication) resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the MFA (multi-factor authentication) resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +mfa(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/number-groups.mdx b/fern/products/sdks/pages/reference/php/rest/client/number-groups.mdx new file mode 100644 index 000000000..646fd36f1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/number-groups.mdx @@ -0,0 +1,33 @@ +--- +title: "numberGroups" +slug: /reference/php/rest/client/number-groups +description: Access the Number Groups resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Number Groups resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +numberGroups(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/phone-numbers.mdx b/fern/products/sdks/pages/reference/php/rest/client/phone-numbers.mdx new file mode 100644 index 000000000..ea84767e8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/phone-numbers.mdx @@ -0,0 +1,33 @@ +--- +title: "phoneNumbers" +slug: /reference/php/rest/client/phone-numbers +description: Access the Phone Numbers resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Phone Numbers resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +phoneNumbers(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/project.mdx b/fern/products/sdks/pages/reference/php/rest/client/project.mdx new file mode 100644 index 000000000..19ca22ce4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/project.mdx @@ -0,0 +1,33 @@ +--- +title: "project" +slug: /reference/php/rest/client/project +description: Access the Project resource for project management. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Project resource for project management. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +project(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/pubsub.mdx b/fern/products/sdks/pages/reference/php/rest/client/pubsub.mdx new file mode 100644 index 000000000..5fdc2886b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/pubsub.mdx @@ -0,0 +1,33 @@ +--- +title: "pubsub" +slug: /reference/php/rest/client/pubsub +description: Access the PubSub resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the PubSub resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +pubsub(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/queues.mdx b/fern/products/sdks/pages/reference/php/rest/client/queues.mdx new file mode 100644 index 000000000..5b7198210 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/queues.mdx @@ -0,0 +1,33 @@ +--- +title: "queues" +slug: /reference/php/rest/client/queues +description: Access the Queues resource for call queue management. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Queues resource for call queue management. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +queues(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/recordings.mdx b/fern/products/sdks/pages/reference/php/rest/client/recordings.mdx new file mode 100644 index 000000000..0c9f9d98f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/recordings.mdx @@ -0,0 +1,33 @@ +--- +title: "recordings" +slug: /reference/php/rest/client/recordings +description: Access the Recordings resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Recordings resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +recordings(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/registry.mdx b/fern/products/sdks/pages/reference/php/rest/client/registry.mdx new file mode 100644 index 000000000..59a2fe464 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/registry.mdx @@ -0,0 +1,33 @@ +--- +title: "registry" +slug: /reference/php/rest/client/registry +description: Access the Registry resource for brand and campaign management. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Registry resource for brand and campaign management. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +registry(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/short-codes.mdx b/fern/products/sdks/pages/reference/php/rest/client/short-codes.mdx new file mode 100644 index 000000000..576f721a2 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/short-codes.mdx @@ -0,0 +1,33 @@ +--- +title: "shortCodes" +slug: /reference/php/rest/client/short-codes +description: Access the Short Codes resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Short Codes resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +shortCodes(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/sip-profile.mdx b/fern/products/sdks/pages/reference/php/rest/client/sip-profile.mdx new file mode 100644 index 000000000..b5226e306 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/sip-profile.mdx @@ -0,0 +1,33 @@ +--- +title: "sipProfile" +slug: /reference/php/rest/client/sip-profile +description: Access the SIP Profile resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the SIP Profile resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +sipProfile(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/verified-callers.mdx b/fern/products/sdks/pages/reference/php/rest/client/verified-callers.mdx new file mode 100644 index 000000000..53d914bee --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/verified-callers.mdx @@ -0,0 +1,33 @@ +--- +title: "verifiedCallers" +slug: /reference/php/rest/client/verified-callers +description: Access the Verified Callers resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Verified Callers resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +verifiedCallers(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/client/video.mdx b/fern/products/sdks/pages/reference/php/rest/client/video.mdx new file mode 100644 index 000000000..60619db7c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/client/video.mdx @@ -0,0 +1,33 @@ +--- +title: "video" +slug: /reference/php/rest/client/video +description: Access the Video resource for video conferencing. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/client + +Access the Video resource for video conferencing. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +video(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/accounts/create.mdx b/fern/products/sdks/pages/reference/php/rest/compat/accounts/create.mdx new file mode 100644 index 000000000..bb40ce3ca --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/accounts/create.mdx @@ -0,0 +1,35 @@ +--- +title: "create" +slug: /reference/php/rest/compat/accounts/create +description: Create a new subproject (sub-account). +max-toc-depth: 3 +--- + +Create a new subproject (sub-account). + +## **Parameters** + + + A human-readable name for the subproject. + + +## **Returns** + +`dict` -- The created account resource. + +## **Example** + +```php {9-9} +compat->accounts->create(FriendlyName: "Marketing Team"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/accounts/get.mdx b/fern/products/sdks/pages/reference/php/rest/compat/accounts/get.mdx new file mode 100644 index 000000000..4adb9d56b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/accounts/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/compat/accounts/get +description: Retrieve a single account by SID. +max-toc-depth: 3 +--- + +Retrieve a single account by its SID. + +## **Parameters** + + + The account SID. + + +## **Returns** + +`dict` -- The account resource. + +## **Example** + +```php {9-9} +compat->accounts->get("account-sid"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/accounts/index.mdx b/fern/products/sdks/pages/reference/php/rest/compat/accounts/index.mdx new file mode 100644 index 000000000..9969e8059 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/accounts/index.mdx @@ -0,0 +1,49 @@ +--- +title: "Accounts" +slug: /reference/php/rest/compat/accounts +description: Manage accounts and subprojects via the Compat API. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/compat/accounts/list +[create]: /docs/sdks/reference/php/rest/compat/accounts/create +[get]: /docs/sdks/reference/php/rest/compat/accounts/get +[update]: /docs/sdks/reference/php/rest/compat/accounts/update + +Manage accounts and subprojects. The base path is +`/api/laml/2010-04-01/Accounts` (not scoped to a specific account SID). + +Access via `client.compat.accounts` on a [`RestClient`][restclient] instance. + +```php +compat->accounts->list(); + + +``` + +## **Methods** + + + + List accounts in the project. + + + Create a new subproject (sub-account). + + + Retrieve a single account by SID. + + + Update an account. + + diff --git a/fern/products/sdks/pages/reference/php/rest/compat/accounts/list.mdx b/fern/products/sdks/pages/reference/php/rest/compat/accounts/list.mdx new file mode 100644 index 000000000..42bc56fbc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/accounts/list.mdx @@ -0,0 +1,29 @@ +--- +title: "list" +slug: /reference/php/rest/compat/accounts/list +description: List accounts in the project. +max-toc-depth: 3 +--- + +List accounts. + +## **Returns** + +`dict` -- Response containing accounts. + +## **Example** + +```php {9-9} +compat->accounts->list(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/accounts/update.mdx b/fern/products/sdks/pages/reference/php/rest/compat/accounts/update.mdx new file mode 100644 index 000000000..7084544a7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/accounts/update.mdx @@ -0,0 +1,47 @@ +--- +title: "update" +slug: /reference/php/rest/compat/accounts/update +description: Update an account. +max-toc-depth: 3 +--- + +Update an account. Uses POST (Twilio convention). + +## **Parameters** + + + The account SID to update. + + + + Updated friendly name. + + + + Account status. + + - `"active"` -- account is fully operational + - `"suspended"` -- account is temporarily disabled + - `"closed"` -- account is permanently deactivated + + +## **Returns** + +`dict` -- The updated account resource. + +## **Example** + +```php {9-9} +compat->accounts->update("account-sid", FriendlyName: "Sales Team"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/applications/create.mdx b/fern/products/sdks/pages/reference/php/rest/compat/applications/create.mdx new file mode 100644 index 000000000..a2574844a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/applications/create.mdx @@ -0,0 +1,59 @@ +--- +title: "create" +slug: /reference/php/rest/compat/applications/create +description: Create a new application. +max-toc-depth: 3 +--- + +Create a new application. + +## **Parameters** + + + A human-readable name for the application. + + + + URL to fetch LAML instructions when a call is received. + + + + HTTP method for the voice URL. Defaults to `"POST"`. + + + + URL to fetch LAML instructions when an SMS is received. + + + + HTTP method for the SMS URL. Defaults to `"POST"`. + + + + URL to receive status webhook events. + + +## **Returns** + +`dict` -- The created application resource. + +## **Example** + +```php {9} +compat->applications->create( + FriendlyName: "My App", + VoiceUrl: "https://example.com/voice", + SmsUrl: "https://example.com/sms" +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/applications/delete.mdx b/fern/products/sdks/pages/reference/php/rest/compat/applications/delete.mdx new file mode 100644 index 000000000..d60e97409 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/applications/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/compat/applications/delete +description: Delete an application. +max-toc-depth: 3 +--- + +Delete an application. + +## **Parameters** + + + The application SID to delete. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +compat->applications->delete("AP..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/applications/get.mdx b/fern/products/sdks/pages/reference/php/rest/compat/applications/get.mdx new file mode 100644 index 000000000..0e9c4e399 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/applications/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/compat/applications/get +description: Retrieve a single application by SID. +max-toc-depth: 3 +--- + +Retrieve a single application by SID. + +## **Parameters** + + + The application SID. + + +## **Returns** + +`dict` -- The application resource. + +## **Example** + +```php {9-9} +compat->applications->get("AP..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/applications/index.mdx b/fern/products/sdks/pages/reference/php/rest/compat/applications/index.mdx new file mode 100644 index 000000000..cf09bb035 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/applications/index.mdx @@ -0,0 +1,53 @@ +--- +title: "Applications" +slug: /reference/php/rest/compat/applications +description: Manage applications with CRUD operations. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/compat/applications/list +[create]: /docs/sdks/reference/php/rest/compat/applications/create +[get]: /docs/sdks/reference/php/rest/compat/applications/get +[update]: /docs/sdks/reference/php/rest/compat/applications/update +[delete]: /docs/sdks/reference/php/rest/compat/applications/delete + +Manage applications with CRUD operations. Applications define voice and messaging +URL endpoints for handling incoming calls and messages. + +Access via `client.compat.applications` on a [`RestClient`][restclient] instance. + +```php +compat->applications->list(); + + +``` + +## **Methods** + + + + List applications in the account. + + + Create a new application. + + + Retrieve a single application by SID. + + + Update an application. + + + Delete an application. + + diff --git a/fern/products/sdks/pages/reference/php/rest/compat/applications/list.mdx b/fern/products/sdks/pages/reference/php/rest/compat/applications/list.mdx new file mode 100644 index 000000000..d74c6fc2f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/applications/list.mdx @@ -0,0 +1,39 @@ +--- +title: "list" +slug: /reference/php/rest/compat/applications/list +description: List applications in the account. +max-toc-depth: 3 +--- + +List applications in the account. + +## **Parameters** + + + Filter by friendly name. + + + + Number of results per page. + + +## **Returns** + +`dict` -- Paginated response containing application resources. + +## **Example** + +```php {9-9} +compat->applications->list(PageSize: 20); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/applications/update.mdx b/fern/products/sdks/pages/reference/php/rest/compat/applications/update.mdx new file mode 100644 index 000000000..e0189a1c1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/applications/update.mdx @@ -0,0 +1,54 @@ +--- +title: "update" +slug: /reference/php/rest/compat/applications/update +description: Update an application. +max-toc-depth: 3 +--- + +Update an application's configuration. Uses POST (Twilio convention). + +## **Parameters** + + + The application SID. + + + + A human-readable name for the application. + + + + URL to fetch LAML instructions when a call is received. + + + + URL to fetch LAML instructions when an SMS is received. + + + + URL to receive status webhook events. + + +## **Returns** + +`dict` -- The updated application resource. + +## **Example** + +```php {9} +compat->applications->update( + "AP...", + VoiceUrl: "https://example.com/new-voice" +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/calls/create.mdx b/fern/products/sdks/pages/reference/php/rest/compat/calls/create.mdx new file mode 100644 index 000000000..7c1fec02c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/calls/create.mdx @@ -0,0 +1,61 @@ +--- +title: "create" +slug: /reference/php/rest/compat/calls/create +description: Initiate a new outbound call. +max-toc-depth: 3 +--- + +Initiate a new outbound call. + +## **Parameters** + + + The destination phone number in E.164 format. + + + + The caller ID phone number (must be a number you own). + + + + The URL that returns LAML instructions when the call connects. + + + + URL to receive call status webhook events. + + + + Events to send to the status callback. + + - `"initiated"` -- the call request has been created + - `"ringing"` -- the destination is ringing + - `"answered"` -- the call has been answered + - `"completed"` -- the call has ended + + +## **Returns** + +`dict` -- The created call resource including the call SID. + +## **Example** + +```php {9} +compat->calls->create( + To: "+15559876543", + From: "+15551234567", + Url: "https://example.com/voice" +); +echo $call["sid"]; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/calls/delete.mdx b/fern/products/sdks/pages/reference/php/rest/compat/calls/delete.mdx new file mode 100644 index 000000000..6eb2acefd --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/calls/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/compat/calls/delete +description: Delete a call record. +max-toc-depth: 3 +--- + +Delete a call record. + +## **Parameters** + + + The call SID to delete. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +compat->calls->delete("CA..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/calls/get.mdx b/fern/products/sdks/pages/reference/php/rest/compat/calls/get.mdx new file mode 100644 index 000000000..8e82224a7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/calls/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/compat/calls/get +description: Retrieve a single call by SID. +max-toc-depth: 3 +--- + +Retrieve a single call by SID. + +## **Parameters** + + + The call SID. + + +## **Returns** + +`dict` -- The call resource. + +## **Example** + +```php {9-9} +compat->calls->get("CA..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/calls/index.mdx b/fern/products/sdks/pages/reference/php/rest/compat/calls/index.mdx new file mode 100644 index 000000000..9b61272ed --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/calls/index.mdx @@ -0,0 +1,81 @@ +--- +title: "Calls" +slug: /reference/php/rest/compat/calls +description: Manage calls with CRUD operations, in-call recording, and media streaming. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/compat/calls/list +[create]: /docs/sdks/reference/php/rest/compat/calls/create +[get]: /docs/sdks/reference/php/rest/compat/calls/get +[update]: /docs/sdks/reference/php/rest/compat/calls/update +[delete]: /docs/sdks/reference/php/rest/compat/calls/delete +[startrecording]: /docs/sdks/reference/php/rest/compat/calls/start-recording +[updaterecording]: /docs/sdks/reference/php/rest/compat/calls/update-recording +[startstream]: /docs/sdks/reference/php/rest/compat/calls/start-stream +[stopstream]: /docs/sdks/reference/php/rest/compat/calls/stop-stream + +Manage calls with CRUD operations, plus sub-resources for in-call recording +and streaming. Uses POST for updates (Twilio convention). + +Access via `client.compat.calls` on a [`RestClient`][restclient] instance. + +```php +compat->calls->list(); + + +``` + +## **Methods** + +### Call CRUD + + + + List calls in the account. + + + Initiate a new outbound call. + + + Retrieve a single call by SID. + + + Update an active call. + + + Delete a call record. + + + +### Recording + + + + Start recording an active call. + + + Update a call recording (pause, resume, or stop). + + + +### Streaming + + + + Start a media stream on an active call. + + + Stop a media stream on a call. + + diff --git a/fern/products/sdks/pages/reference/php/rest/compat/calls/list.mdx b/fern/products/sdks/pages/reference/php/rest/compat/calls/list.mdx new file mode 100644 index 000000000..49caf5c36 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/calls/list.mdx @@ -0,0 +1,56 @@ +--- +title: "list" +slug: /reference/php/rest/compat/calls/list +description: List calls in the account. +max-toc-depth: 3 +--- + +List calls in the account. + +## **Parameters** + + + Filter by call status. + + - `"queued"` -- call is waiting to be processed + - `"ringing"` -- call is ringing at the destination + - `"in-progress"` -- call is currently connected and active + - `"completed"` -- call ended normally + - `"busy"` -- destination returned a busy signal + - `"failed"` -- call could not be completed due to an error + - `"no-answer"` -- destination did not answer + - `"canceled"` -- call was canceled before being answered + + + + Filter by the destination number. + + + + Filter by the originating number. + + + + Number of results per page. + + +## **Returns** + +`dict` -- Paginated response containing call resources. + +## **Example** + +```php {9-9} +compat->calls->list(Status: "completed", PageSize: 20); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/calls/start-recording.mdx b/fern/products/sdks/pages/reference/php/rest/compat/calls/start-recording.mdx new file mode 100644 index 000000000..e9604713b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/calls/start-recording.mdx @@ -0,0 +1,46 @@ +--- +title: "startRecording" +slug: /reference/php/rest/compat/calls/start-recording +description: Start recording an active call. +max-toc-depth: 3 +--- + +Start recording an active call. + +## **Parameters** + + + The SID of the call to record. + + + + URL to receive recording status events. + + + + Recording channel mode. + + - `"mono"` -- both legs of the call are mixed into a single audio channel + - `"dual"` -- each leg of the call is recorded in a separate audio channel + + +## **Returns** + +`dict` -- The created recording resource. + +## **Example** + +```php {9-9} +compat->calls->start_recording("CA..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/calls/start-stream.mdx b/fern/products/sdks/pages/reference/php/rest/compat/calls/start-stream.mdx new file mode 100644 index 000000000..fdbb7b4cb --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/calls/start-stream.mdx @@ -0,0 +1,39 @@ +--- +title: "startStream" +slug: /reference/php/rest/compat/calls/start-stream +description: Start a media stream on an active call. +max-toc-depth: 3 +--- + +Start a media stream on an active call, sending real-time audio to a WebSocket URL. + +## **Parameters** + + + The SID of the call. + + + + The WebSocket URL to stream audio to. + + +## **Returns** + +`dict` -- The created stream resource. + +## **Example** + +```php {9-9} +compat->calls->start_stream("CA...", Url: "wss://stream.example.com"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/calls/stop-stream.mdx b/fern/products/sdks/pages/reference/php/rest/compat/calls/stop-stream.mdx new file mode 100644 index 000000000..856a1fdb5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/calls/stop-stream.mdx @@ -0,0 +1,39 @@ +--- +title: "stopStream" +slug: /reference/php/rest/compat/calls/stop-stream +description: Stop a media stream on a call. +max-toc-depth: 3 +--- + +Stop a media stream on a call. + +## **Parameters** + + + The SID of the call. + + + + The SID of the stream to stop. + + +## **Returns** + +`dict` -- The updated stream resource. + +## **Example** + +```php {9-9} +compat->calls->stop_stream("CA...", "ST..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/calls/update-recording.mdx b/fern/products/sdks/pages/reference/php/rest/compat/calls/update-recording.mdx new file mode 100644 index 000000000..25ab711a6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/calls/update-recording.mdx @@ -0,0 +1,47 @@ +--- +title: "updateRecording" +slug: /reference/php/rest/compat/calls/update-recording +description: Update a call recording (pause, resume, or stop). +max-toc-depth: 3 +--- + +Update a call recording (e.g., pause, resume, or stop). + +## **Parameters** + + + The SID of the call. + + + + The SID of the recording. + + + + New recording status. + + - `"paused"` -- pause the recording + - `"in-progress"` -- resume a paused recording + - `"stopped"` -- stop the recording permanently + + +## **Returns** + +`dict` -- The updated recording resource. + +## **Example** + +```php {9-9} +compat->calls->update_recording("CA...", "RE...", Status: "paused"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/calls/update.mdx b/fern/products/sdks/pages/reference/php/rest/compat/calls/update.mdx new file mode 100644 index 000000000..c1276f731 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/calls/update.mdx @@ -0,0 +1,43 @@ +--- +title: "update" +slug: /reference/php/rest/compat/calls/update +description: Update an active call. +max-toc-depth: 3 +--- + +Update an active call (e.g., redirect to new LAML, end the call). + +## **Parameters** + + + The call SID. + + + + New URL to fetch LAML instructions from. + + + + Set to `"completed"` to end the call. + + +## **Returns** + +`dict` -- The updated call resource. + +## **Example** + +```php {9-9} +compat->calls->update("CA...", Status: "completed"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/conferences/delete-recording.mdx b/fern/products/sdks/pages/reference/php/rest/compat/conferences/delete-recording.mdx new file mode 100644 index 000000000..baaaae5da --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/conferences/delete-recording.mdx @@ -0,0 +1,39 @@ +--- +title: "deleteRecording" +slug: /reference/php/rest/compat/conferences/delete-recording +description: Delete a conference recording. +max-toc-depth: 3 +--- + +Delete a conference recording. + +## **Parameters** + + + The SID of the conference. + + + + The SID of the recording to delete. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +compat->conferences->delete_recording("CF...", "RE..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/conferences/get-participant.mdx b/fern/products/sdks/pages/reference/php/rest/compat/conferences/get-participant.mdx new file mode 100644 index 000000000..c05536ad1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/conferences/get-participant.mdx @@ -0,0 +1,39 @@ +--- +title: "getParticipant" +slug: /reference/php/rest/compat/conferences/get-participant +description: Retrieve a specific participant in a conference. +max-toc-depth: 3 +--- + +Retrieve a specific participant in a conference. + +## **Parameters** + + + The SID of the conference. + + + + The call SID of the participant. + + +## **Returns** + +`dict` -- The participant resource. + +## **Example** + +```php {9-9} +compat->conferences->get_participant("CF...", "CA..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/conferences/get-recording.mdx b/fern/products/sdks/pages/reference/php/rest/compat/conferences/get-recording.mdx new file mode 100644 index 000000000..9a7c9fe55 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/conferences/get-recording.mdx @@ -0,0 +1,39 @@ +--- +title: "getRecording" +slug: /reference/php/rest/compat/conferences/get-recording +description: Retrieve a specific conference recording. +max-toc-depth: 3 +--- + +Retrieve a specific conference recording. + +## **Parameters** + + + The SID of the conference. + + + + The SID of the recording. + + +## **Returns** + +`dict` -- The recording resource. + +## **Example** + +```php {9-9} +compat->conferences->get_recording("CF...", "RE..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/conferences/get.mdx b/fern/products/sdks/pages/reference/php/rest/compat/conferences/get.mdx new file mode 100644 index 000000000..c2c783b0b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/conferences/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/compat/conferences/get +description: Retrieve a single conference by SID. +max-toc-depth: 3 +--- + +Retrieve a single conference by SID. + +## **Parameters** + + + The conference SID. + + +## **Returns** + +`dict` -- The conference resource. + +## **Example** + +```php {9-9} +compat->conferences->get("CF..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/conferences/index.mdx b/fern/products/sdks/pages/reference/php/rest/compat/conferences/index.mdx new file mode 100644 index 000000000..4ad045ab6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/conferences/index.mdx @@ -0,0 +1,103 @@ +--- +title: "Conferences" +slug: /reference/php/rest/compat/conferences +description: Manage conferences with participants, recordings, and media streams. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/compat/conferences/list +[get]: /docs/sdks/reference/php/rest/compat/conferences/get +[update]: /docs/sdks/reference/php/rest/compat/conferences/update +[listparticipants]: /docs/sdks/reference/php/rest/compat/conferences/list-participants +[getparticipant]: /docs/sdks/reference/php/rest/compat/conferences/get-participant +[updateparticipant]: /docs/sdks/reference/php/rest/compat/conferences/update-participant +[removeparticipant]: /docs/sdks/reference/php/rest/compat/conferences/remove-participant +[listrecordings]: /docs/sdks/reference/php/rest/compat/conferences/list-recordings +[getrecording]: /docs/sdks/reference/php/rest/compat/conferences/get-recording +[updaterecording]: /docs/sdks/reference/php/rest/compat/conferences/update-recording +[deleterecording]: /docs/sdks/reference/php/rest/compat/conferences/delete-recording +[startstream]: /docs/sdks/reference/php/rest/compat/conferences/start-stream +[stopstream]: /docs/sdks/reference/php/rest/compat/conferences/stop-stream + +Manage conferences with participants, recordings, and streams. Conferences are +list/get/update only (they are created implicitly when a participant dials in +via LAML). + +Access via `client.compat.conferences` on a [`RestClient`][restclient] instance. + +```php +compat->conferences->list(); + + +``` + +## **Methods** + +### Conference CRUD + + + + List conferences. + + + Retrieve a single conference by SID. + + + Update a conference (e.g., end it or set an announce URL). + + + +### Participants + + + + List participants in a conference. + + + Retrieve a specific participant in a conference. + + + Update a participant in a conference (mute, hold, or remove). + + + Remove a participant from a conference. + + + +### Recordings + + + + List recordings for a conference. + + + Retrieve a specific conference recording. + + + Update a conference recording (pause, resume, or stop). + + + Delete a conference recording. + + + +### Streaming + + + + Start a media stream on a conference. + + + Stop a media stream on a conference. + + diff --git a/fern/products/sdks/pages/reference/php/rest/compat/conferences/list-participants.mdx b/fern/products/sdks/pages/reference/php/rest/compat/conferences/list-participants.mdx new file mode 100644 index 000000000..506f7b586 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/conferences/list-participants.mdx @@ -0,0 +1,43 @@ +--- +title: "listParticipants" +slug: /reference/php/rest/compat/conferences/list-participants +description: List participants in a conference. +max-toc-depth: 3 +--- + +List participants in a conference. + +## **Parameters** + + + The SID of the conference. + + + + Filter by muted status. + + + + Filter by hold status. + + +## **Returns** + +`dict` -- List of participant resources. + +## **Example** + +```php {9-9} +compat->conferences->list_participants("CF..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/conferences/list-recordings.mdx b/fern/products/sdks/pages/reference/php/rest/compat/conferences/list-recordings.mdx new file mode 100644 index 000000000..727f0e80c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/conferences/list-recordings.mdx @@ -0,0 +1,35 @@ +--- +title: "listRecordings" +slug: /reference/php/rest/compat/conferences/list-recordings +description: List recordings for a conference. +max-toc-depth: 3 +--- + +List recordings for a conference. + +## **Parameters** + + + The SID of the conference. + + +## **Returns** + +`dict` -- List of recording resources. + +## **Example** + +```php {9-9} +compat->conferences->list_recordings("CF..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/conferences/list.mdx b/fern/products/sdks/pages/reference/php/rest/compat/conferences/list.mdx new file mode 100644 index 000000000..23de7bffd --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/conferences/list.mdx @@ -0,0 +1,47 @@ +--- +title: "list" +slug: /reference/php/rest/compat/conferences/list +description: List conferences. +max-toc-depth: 3 +--- + +List conferences. + +## **Parameters** + + + Filter by conference status. + + - `"init"` -- conference has been created but no participants have joined yet + - `"in-progress"` -- conference is currently active with participants + - `"completed"` -- conference has ended + + + + Filter by the conference's friendly name. + + + + Number of results per page. + + +## **Returns** + +`dict` -- Paginated response containing conference resources. + +## **Example** + +```php {9-9} +compat->conferences->list(Status: "in-progress"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/conferences/remove-participant.mdx b/fern/products/sdks/pages/reference/php/rest/compat/conferences/remove-participant.mdx new file mode 100644 index 000000000..460b23b8b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/conferences/remove-participant.mdx @@ -0,0 +1,39 @@ +--- +title: "removeParticipant" +slug: /reference/php/rest/compat/conferences/remove-participant +description: Remove a participant from a conference. +max-toc-depth: 3 +--- + +Remove a participant from a conference, ending their call leg. + +## **Parameters** + + + The SID of the conference. + + + + The call SID of the participant to remove. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +compat->conferences->remove_participant("CF...", "CA..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/conferences/start-stream.mdx b/fern/products/sdks/pages/reference/php/rest/compat/conferences/start-stream.mdx new file mode 100644 index 000000000..b260832d7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/conferences/start-stream.mdx @@ -0,0 +1,42 @@ +--- +title: "startStream" +slug: /reference/php/rest/compat/conferences/start-stream +description: Start a media stream on a conference. +max-toc-depth: 3 +--- + +Start a media stream on a conference, sending real-time audio to a WebSocket URL. + +## **Parameters** + + + The SID of the conference. + + + + The WebSocket URL to stream audio to. + + +## **Returns** + +`dict` -- The created stream resource. + +## **Example** + +```php {9} +compat->conferences->start_stream( + "CF...", + Url: "wss://stream.example.com" +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/conferences/stop-stream.mdx b/fern/products/sdks/pages/reference/php/rest/compat/conferences/stop-stream.mdx new file mode 100644 index 000000000..fefd66c6b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/conferences/stop-stream.mdx @@ -0,0 +1,39 @@ +--- +title: "stopStream" +slug: /reference/php/rest/compat/conferences/stop-stream +description: Stop a media stream on a conference. +max-toc-depth: 3 +--- + +Stop a media stream on a conference. + +## **Parameters** + + + The SID of the conference. + + + + The SID of the stream to stop. + + +## **Returns** + +`dict` -- The updated stream resource. + +## **Example** + +```php {9-9} +compat->conferences->stop_stream("CF...", "ST..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/conferences/update-participant.mdx b/fern/products/sdks/pages/reference/php/rest/compat/conferences/update-participant.mdx new file mode 100644 index 000000000..10378240d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/conferences/update-participant.mdx @@ -0,0 +1,47 @@ +--- +title: "updateParticipant" +slug: /reference/php/rest/compat/conferences/update-participant +description: Update a participant in a conference (mute, hold, or remove). +max-toc-depth: 3 +--- + +Update a participant in a conference (e.g., mute, hold, or remove). + +## **Parameters** + + + The SID of the conference. + + + + The call SID of the participant. + + + + Set to `true` to mute or `false` to unmute. + + + + Set to `true` to hold or `false` to unhold. + + +## **Returns** + +`dict` -- The updated participant resource. + +## **Example** + +```php {9-9} +compat->conferences->update_participant("CF...", "CA...", Muted: true); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/conferences/update-recording.mdx b/fern/products/sdks/pages/reference/php/rest/compat/conferences/update-recording.mdx new file mode 100644 index 000000000..43eb89e71 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/conferences/update-recording.mdx @@ -0,0 +1,47 @@ +--- +title: "updateRecording" +slug: /reference/php/rest/compat/conferences/update-recording +description: Update a conference recording (pause, resume, or stop). +max-toc-depth: 3 +--- + +Update a conference recording (e.g., pause, resume, or stop). + +## **Parameters** + + + The SID of the conference. + + + + The SID of the recording. + + + + New recording status. + + - `"paused"` -- pause the recording + - `"in-progress"` -- resume a paused recording + - `"stopped"` -- stop the recording permanently + + +## **Returns** + +`dict` -- The updated recording resource. + +## **Example** + +```php {9-9} +compat->conferences->update_recording("CF...", "RE...", Status: "paused"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/conferences/update.mdx b/fern/products/sdks/pages/reference/php/rest/compat/conferences/update.mdx new file mode 100644 index 000000000..e42338ea3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/conferences/update.mdx @@ -0,0 +1,43 @@ +--- +title: "update" +slug: /reference/php/rest/compat/conferences/update +description: Update a conference (e.g., end it or set an announce URL). +max-toc-depth: 3 +--- + +Update a conference (e.g., end it, or set the announce URL). + +## **Parameters** + + + The conference SID. + + + + Set to `"completed"` to end the conference. + + + + URL returning LAML to play an announcement to all participants. + + +## **Returns** + +`dict` -- The updated conference resource. + +## **Example** + +```php {9-9} +compat->conferences->update("CF...", Status: "completed"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/faxes/create.mdx b/fern/products/sdks/pages/reference/php/rest/compat/faxes/create.mdx new file mode 100644 index 000000000..15dc0ce8a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/faxes/create.mdx @@ -0,0 +1,51 @@ +--- +title: "create" +slug: /reference/php/rest/compat/faxes/create +description: Send a new fax. +max-toc-depth: 3 +--- + +Send a new fax. + +## **Parameters** + + + The destination fax number in E.164 format. + + + + The sender number (must be a number you own). + + + + URL of the document to fax (PDF format). + + + + URL to receive fax status webhook events. + + +## **Returns** + +`dict` -- The created fax resource. + +## **Example** + +```php {9} +compat->faxes->create( + To: "+15559876543", + From: "+15551234567", + MediaUrl: "https://example.com/document.pdf" +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/faxes/delete-media.mdx b/fern/products/sdks/pages/reference/php/rest/compat/faxes/delete-media.mdx new file mode 100644 index 000000000..d89fe39a5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/faxes/delete-media.mdx @@ -0,0 +1,39 @@ +--- +title: "deleteMedia" +slug: /reference/php/rest/compat/faxes/delete-media +description: Delete a media item from a fax. +max-toc-depth: 3 +--- + +Delete a media item from a fax. + +## **Parameters** + + + The SID of the fax. + + + + The SID of the media item to delete. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +compat->faxes->delete_media("FX...", "ME..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/faxes/delete.mdx b/fern/products/sdks/pages/reference/php/rest/compat/faxes/delete.mdx new file mode 100644 index 000000000..9af751b74 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/faxes/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/compat/faxes/delete +description: Delete a fax record. +max-toc-depth: 3 +--- + +Delete a fax record. + +## **Parameters** + + + The fax SID to delete. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +compat->faxes->delete("FX..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/faxes/get-media.mdx b/fern/products/sdks/pages/reference/php/rest/compat/faxes/get-media.mdx new file mode 100644 index 000000000..e4c4c56d1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/faxes/get-media.mdx @@ -0,0 +1,39 @@ +--- +title: "getMedia" +slug: /reference/php/rest/compat/faxes/get-media +description: Retrieve a specific media item from a fax. +max-toc-depth: 3 +--- + +Retrieve a specific media item from a fax. + +## **Parameters** + + + The SID of the fax. + + + + The SID of the media item. + + +## **Returns** + +`dict` -- The media resource. + +## **Example** + +```php {9-9} +compat->faxes->get_media("FX...", "ME..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/faxes/get.mdx b/fern/products/sdks/pages/reference/php/rest/compat/faxes/get.mdx new file mode 100644 index 000000000..ca522bf83 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/faxes/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/compat/faxes/get +description: Retrieve a single fax by SID. +max-toc-depth: 3 +--- + +Retrieve a single fax by SID. + +## **Parameters** + + + The fax SID. + + +## **Returns** + +`dict` -- The fax resource. + +## **Example** + +```php {9-9} +compat->faxes->get("FX..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/faxes/index.mdx b/fern/products/sdks/pages/reference/php/rest/compat/faxes/index.mdx new file mode 100644 index 000000000..2381dd8b3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/faxes/index.mdx @@ -0,0 +1,73 @@ +--- +title: "Faxes" +slug: /reference/php/rest/compat/faxes +description: Manage faxes with CRUD operations and media sub-resources. +max-toc-depth: 3 +--- + +[messages]: /docs/sdks/reference/php/rest/compat/messages +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/compat/faxes/list +[create]: /docs/sdks/reference/php/rest/compat/faxes/create +[get]: /docs/sdks/reference/php/rest/compat/faxes/get +[update]: /docs/sdks/reference/php/rest/compat/faxes/update +[delete]: /docs/sdks/reference/php/rest/compat/faxes/delete +[listmedia]: /docs/sdks/reference/php/rest/compat/faxes/list-media +[getmedia]: /docs/sdks/reference/php/rest/compat/faxes/get-media +[deletemedia]: /docs/sdks/reference/php/rest/compat/faxes/delete-media + +Manage faxes with CRUD operations and media sub-resources. The media sub-resource +pattern is identical to [`messages`][messages]. + +Access via `client.compat.faxes` on a [`RestClient`][restclient] instance. + +```php +compat->faxes->list(); + + +``` + +## **Methods** + +### Fax CRUD + + + + List faxes in the account. + + + Send a new fax. + + + Retrieve a single fax by SID. + + + Update a fax resource. + + + Delete a fax record. + + + +### Media + + + + List media items attached to a fax. + + + Retrieve a specific media item from a fax. + + + Delete a media item from a fax. + + diff --git a/fern/products/sdks/pages/reference/php/rest/compat/faxes/list-media.mdx b/fern/products/sdks/pages/reference/php/rest/compat/faxes/list-media.mdx new file mode 100644 index 000000000..80a0a11bf --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/faxes/list-media.mdx @@ -0,0 +1,35 @@ +--- +title: "listMedia" +slug: /reference/php/rest/compat/faxes/list-media +description: List media items attached to a fax. +max-toc-depth: 3 +--- + +List media items attached to a fax. + +## **Parameters** + + + The SID of the fax. + + +## **Returns** + +`dict` -- List of media resources. + +## **Example** + +```php {9-9} +compat->faxes->list_media("FX..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/faxes/list.mdx b/fern/products/sdks/pages/reference/php/rest/compat/faxes/list.mdx new file mode 100644 index 000000000..d31236b6b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/faxes/list.mdx @@ -0,0 +1,29 @@ +--- +title: "list" +slug: /reference/php/rest/compat/faxes/list +description: List faxes in the account. +max-toc-depth: 3 +--- + +List faxes in the account. + +## **Returns** + +`dict` -- Paginated response containing fax resources. + +## **Example** + +```php {9-9} +compat->faxes->list(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/faxes/update.mdx b/fern/products/sdks/pages/reference/php/rest/compat/faxes/update.mdx new file mode 100644 index 000000000..c3972a2ae --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/faxes/update.mdx @@ -0,0 +1,35 @@ +--- +title: "update" +slug: /reference/php/rest/compat/faxes/update +description: Update a fax resource. +max-toc-depth: 3 +--- + +Update a fax resource. + +## **Parameters** + + + The fax SID. + + +## **Returns** + +`dict` -- The updated fax resource. + +## **Example** + +```php {9-9} +compat->faxes->update("FX..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/index.mdx b/fern/products/sdks/pages/reference/php/rest/compat/index.mdx new file mode 100644 index 000000000..b27503896 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/index.mdx @@ -0,0 +1,126 @@ +--- +title: "Compat" +slug: /reference/php/rest/compat +description: Twilio-compatible REST API for calls, messages, faxes, conferences, phone numbers, and more. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[accounts]: /docs/sdks/reference/php/rest/compat/accounts +[calls]: /docs/sdks/reference/php/rest/compat/calls +[messages]: /docs/sdks/reference/php/rest/compat/messages +[faxes]: /docs/sdks/reference/php/rest/compat/faxes +[conferences]: /docs/sdks/reference/php/rest/compat/conferences +[phone-numbers]: /docs/sdks/reference/php/rest/compat/phone-numbers +[applications]: /docs/sdks/reference/php/rest/compat/applications +[laml-bins]: /docs/sdks/reference/php/rest/compat/laml-bins +[queues]: /docs/sdks/reference/php/rest/compat/queues +[recordings]: /docs/sdks/reference/php/rest/compat/recordings +[transcriptions]: /docs/sdks/reference/php/rest/compat/transcriptions +[tokens]: /docs/sdks/reference/php/rest/compat/tokens + +The `CompatNamespace` provides a Twilio-compatible LAML REST API through the +[`RestClient`][restclient]. It implements the familiar +`/2010-04-01/Accounts/{AccountSid}/` URL structure with 12 sub-resources, making it +straightforward to migrate existing Twilio integrations to SignalWire. + +Access via `client.compat` on a [`RestClient`][restclient] instance. + +```php +compat->calls->list(); + + +``` + + +The Compat namespace uses the same REST patterns as Twilio's API. If you are migrating +from Twilio, most code changes are limited to updating the client initialization to use +SignalWire credentials. Resource identifiers use SIDs (e.g., `CA...` for calls, `SM...` +for messages). + + +## **Sub-resources** + + + + Account and subproject management. + + + Call management with recording and stream sub-resources. + + + SMS/MMS messaging with media sub-resources. + + + Fax management with media sub-resources. + + + Conference management with participants, recordings, and streams. + + + Phone number management, search, and import. + + + Application configuration management. + + + LAML (cXML) script management. + + + Queue management with member operations. + + + Recording management. + + + Transcription management. + + + API token management. + + diff --git a/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/create.mdx b/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/create.mdx new file mode 100644 index 000000000..5aae95129 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/create.mdx @@ -0,0 +1,45 @@ +--- +title: "create" +slug: /reference/php/rest/compat/laml-bins/create +description: Create a new LAML bin. +max-toc-depth: 3 +--- + +Create a new LAML bin containing a cXML/LaML script. + +## **Parameters** + + + A human-readable name for the LAML bin. + + + + The cXML/LaML script content. + + +## **Returns** + +`dict` -- The created LAML bin resource. + +## **Example** + +```php {9} +compat->laml_bins->create( + FriendlyName: "Greeting", + Contents: ( + '' + "Hello!" + ) +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/delete.mdx b/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/delete.mdx new file mode 100644 index 000000000..cbaaa3862 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/compat/laml-bins/delete +description: Delete a LAML bin. +max-toc-depth: 3 +--- + +Delete a LAML bin. + +## **Parameters** + + + The LAML bin SID to delete. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +compat->laml_bins->delete("LB..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/get.mdx b/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/get.mdx new file mode 100644 index 000000000..25285f9a9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/compat/laml-bins/get +description: Retrieve a single LAML bin by SID. +max-toc-depth: 3 +--- + +Retrieve a single LAML bin by SID. + +## **Parameters** + + + The LAML bin SID. + + +## **Returns** + +`dict` -- The LAML bin resource. + +## **Example** + +```php {9-9} +compat->laml_bins->get("LB..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/index.mdx b/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/index.mdx new file mode 100644 index 000000000..6e6bbebd4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/index.mdx @@ -0,0 +1,53 @@ +--- +title: "LAML Bins" +slug: /reference/php/rest/compat/laml-bins +description: Manage LAML bins (cXML/LaML scripts) with CRUD operations. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/compat/laml-bins/list +[create]: /docs/sdks/reference/php/rest/compat/laml-bins/create +[get]: /docs/sdks/reference/php/rest/compat/laml-bins/get +[update]: /docs/sdks/reference/php/rest/compat/laml-bins/update +[delete]: /docs/sdks/reference/php/rest/compat/laml-bins/delete + +Manage LAML bins with CRUD operations. LAML bins store reusable cXML/LaML scripts +that can be referenced by URL in call and message handling. + +Access via `client.compat.laml_bins` on a [`RestClient`][restclient] instance. + +```php +compat->laml_bins->list(); + + +``` + +## **Methods** + + + + List LAML bins in the account. + + + Create a new LAML bin. + + + Retrieve a single LAML bin by SID. + + + Update a LAML bin. + + + Delete a LAML bin. + + diff --git a/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/list.mdx b/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/list.mdx new file mode 100644 index 000000000..7f2ff1611 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/list.mdx @@ -0,0 +1,39 @@ +--- +title: "list" +slug: /reference/php/rest/compat/laml-bins/list +description: List LAML bins in the account. +max-toc-depth: 3 +--- + +List LAML bins in the account. + +## **Parameters** + + + Filter by friendly name. + + + + Number of results per page. + + +## **Returns** + +`dict` -- Paginated response containing LAML bin resources. + +## **Example** + +```php {9-9} +compat->laml_bins->list(PageSize: 20); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/update.mdx b/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/update.mdx new file mode 100644 index 000000000..71b06bdd7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/laml-bins/update.mdx @@ -0,0 +1,49 @@ +--- +title: "update" +slug: /reference/php/rest/compat/laml-bins/update +description: Update a LAML bin. +max-toc-depth: 3 +--- + +Update a LAML bin's content or name. Uses POST (Twilio convention). + +## **Parameters** + + + The LAML bin SID. + + + + A human-readable name for the LAML bin. + + + + The updated cXML/LaML script content. + + +## **Returns** + +`dict` -- The updated LAML bin resource. + +## **Example** + +```php {9} +compat->laml_bins->update( + "LB...", + Contents: ( + '' + "Goodbye!" + ) +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/messages/create.mdx b/fern/products/sdks/pages/reference/php/rest/compat/messages/create.mdx new file mode 100644 index 000000000..f8e2c979a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/messages/create.mdx @@ -0,0 +1,64 @@ +--- +title: "create" +slug: /reference/php/rest/compat/messages/create +description: Send a new SMS or MMS message. +max-toc-depth: 3 +--- + +Send a new SMS or MMS message. + +## **Parameters** + + + The destination phone number in E.164 format. + + + + The sender phone number (must be a number you own). + + + + The text body of the message. Required for SMS; optional for MMS if `MediaUrl` is provided. + + + + URLs of media to include (for MMS). Up to 10 media URLs. + + + + URL to receive message status webhook events. + + +## **Returns** + +`dict` -- The created message resource including the message SID. + +## **Example** + +```php {10,17} +compat->messages->create( + To: "+15559876543", + From: "+15551234567", + Body: "Hello from SignalWire!" +); + +// Send an MMS with an image +$mms = $client->compat->messages->create( + To: "+15559876543", + From: "+15551234567", + Body: "Check this out", + MediaUrl: ["https://example.com/image.jpg"] +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/messages/delete-media.mdx b/fern/products/sdks/pages/reference/php/rest/compat/messages/delete-media.mdx new file mode 100644 index 000000000..64f425968 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/messages/delete-media.mdx @@ -0,0 +1,39 @@ +--- +title: "deleteMedia" +slug: /reference/php/rest/compat/messages/delete-media +description: Delete a media item from a message. +max-toc-depth: 3 +--- + +Delete a media item from a message. + +## **Parameters** + + + The SID of the message. + + + + The SID of the media item to delete. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +compat->messages->delete_media("SM...", "ME..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/messages/delete.mdx b/fern/products/sdks/pages/reference/php/rest/compat/messages/delete.mdx new file mode 100644 index 000000000..b82e66029 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/messages/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/compat/messages/delete +description: Delete a message record. +max-toc-depth: 3 +--- + +Delete a message record. + +## **Parameters** + + + The message SID to delete. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +compat->messages->delete("SM..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/messages/get-media.mdx b/fern/products/sdks/pages/reference/php/rest/compat/messages/get-media.mdx new file mode 100644 index 000000000..28bae5f84 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/messages/get-media.mdx @@ -0,0 +1,39 @@ +--- +title: "getMedia" +slug: /reference/php/rest/compat/messages/get-media +description: Retrieve a specific media item from a message. +max-toc-depth: 3 +--- + +Retrieve a specific media item from a message. + +## **Parameters** + + + The SID of the message. + + + + The SID of the media item. + + +## **Returns** + +`dict` -- The media resource including the content URL. + +## **Example** + +```php {9-9} +compat->messages->get_media("SM...", "ME..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/messages/get.mdx b/fern/products/sdks/pages/reference/php/rest/compat/messages/get.mdx new file mode 100644 index 000000000..1c063d793 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/messages/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/compat/messages/get +description: Retrieve a single message by SID. +max-toc-depth: 3 +--- + +Retrieve a single message by SID. + +## **Parameters** + + + The message SID. + + +## **Returns** + +`dict` -- The message resource. + +## **Example** + +```php {9-9} +compat->messages->get("SM..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/messages/index.mdx b/fern/products/sdks/pages/reference/php/rest/compat/messages/index.mdx new file mode 100644 index 000000000..8e49aa820 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/messages/index.mdx @@ -0,0 +1,71 @@ +--- +title: "Messages" +slug: /reference/php/rest/compat/messages +description: Manage SMS and MMS messages with media sub-resources. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/compat/messages/list +[create]: /docs/sdks/reference/php/rest/compat/messages/create +[get]: /docs/sdks/reference/php/rest/compat/messages/get +[update]: /docs/sdks/reference/php/rest/compat/messages/update +[delete]: /docs/sdks/reference/php/rest/compat/messages/delete +[listmedia]: /docs/sdks/reference/php/rest/compat/messages/list-media +[getmedia]: /docs/sdks/reference/php/rest/compat/messages/get-media +[deletemedia]: /docs/sdks/reference/php/rest/compat/messages/delete-media + +Manage SMS and MMS messages with CRUD operations and media sub-resources. + +Access via `client.compat.messages` on a [`RestClient`][restclient] instance. + +```php +compat->messages->list(); + + +``` + +## **Methods** + +### Message CRUD + + + + List messages in the account. + + + Send a new SMS or MMS message. + + + Retrieve a single message by SID. + + + Update a message (e.g., redact the body). + + + Delete a message record. + + + +### Media + + + + List media items attached to a message. + + + Retrieve a specific media item from a message. + + + Delete a media item from a message. + + diff --git a/fern/products/sdks/pages/reference/php/rest/compat/messages/list-media.mdx b/fern/products/sdks/pages/reference/php/rest/compat/messages/list-media.mdx new file mode 100644 index 000000000..3efbc7bd8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/messages/list-media.mdx @@ -0,0 +1,35 @@ +--- +title: "listMedia" +slug: /reference/php/rest/compat/messages/list-media +description: List media items attached to a message. +max-toc-depth: 3 +--- + +List media items (images, files) attached to a message. + +## **Parameters** + + + The SID of the message. + + +## **Returns** + +`dict` -- List of media resources attached to the message. + +## **Example** + +```php {9-9} +compat->messages->list_media("SM..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/messages/list.mdx b/fern/products/sdks/pages/reference/php/rest/compat/messages/list.mdx new file mode 100644 index 000000000..8065ed1dc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/messages/list.mdx @@ -0,0 +1,43 @@ +--- +title: "list" +slug: /reference/php/rest/compat/messages/list +description: List messages in the account. +max-toc-depth: 3 +--- + +List messages in the account. + +## **Parameters** + + + Filter by destination number. + + + + Filter by sender number. + + + + Number of results per page. + + +## **Returns** + +`dict` -- Paginated response containing message resources. + +## **Example** + +```php {9-9} +compat->messages->list(PageSize: 20); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/messages/update.mdx b/fern/products/sdks/pages/reference/php/rest/compat/messages/update.mdx new file mode 100644 index 000000000..fce2bd7f0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/messages/update.mdx @@ -0,0 +1,39 @@ +--- +title: "update" +slug: /reference/php/rest/compat/messages/update +description: Update a message (e.g., redact the body). +max-toc-depth: 3 +--- + +Update a message (e.g., redact the body of a sent message). + +## **Parameters** + + + The message SID. + + + + Set to an empty string to redact the message body. + + +## **Returns** + +`dict` -- The updated message resource. + +## **Example** + +```php {9-9} +compat->messages->update("SM...", Body: ""); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/delete.mdx b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/delete.mdx new file mode 100644 index 000000000..335c3dcbe --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/compat/phone-numbers/delete +description: Release a phone number. +max-toc-depth: 3 +--- + +Release a phone number from the account. + +## **Parameters** + + + The phone number SID to release. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +compat->phoneNumbers->delete("PN..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/get.mdx b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/get.mdx new file mode 100644 index 000000000..3a8de8e2d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/compat/phone-numbers/get +description: Retrieve a single phone number by SID. +max-toc-depth: 3 +--- + +Retrieve a single phone number by SID. + +## **Parameters** + + + The phone number SID. + + +## **Returns** + +`dict` -- The phone number resource. + +## **Example** + +```php {9-9} +compat->phoneNumbers->get("PN..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/import-number.mdx b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/import-number.mdx new file mode 100644 index 000000000..da53f8f96 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/import-number.mdx @@ -0,0 +1,41 @@ +--- +title: "importNumber" +slug: /reference/php/rest/compat/phone-numbers/import-number +description: Import an external phone number. +max-toc-depth: 3 +--- + +Import an external phone number into the account. + +## **Parameters** + + + The phone number to import in E.164 format. + + + + A human-readable label for the number. + + +## **Returns** + +`dict` -- The imported phone number resource. + +## **Example** + +```php {9} +compat->phoneNumbers->import_number( + PhoneNumber: "+15559876543" +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/index.mdx b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/index.mdx new file mode 100644 index 000000000..935283fa5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/index.mdx @@ -0,0 +1,81 @@ +--- +title: "Phone Numbers" +slug: /reference/php/rest/compat/phone-numbers +description: Manage phone numbers, search available inventory, and import numbers. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/compat/phone-numbers/list +[purchase]: /docs/sdks/reference/php/rest/compat/phone-numbers/purchase +[get]: /docs/sdks/reference/php/rest/compat/phone-numbers/get +[update]: /docs/sdks/reference/php/rest/compat/phone-numbers/update +[delete]: /docs/sdks/reference/php/rest/compat/phone-numbers/delete +[importnumber]: /docs/sdks/reference/php/rest/compat/phone-numbers/import-number +[listavailablecountries]: /docs/sdks/reference/php/rest/compat/phone-numbers/list-available-countries +[searchlocal]: /docs/sdks/reference/php/rest/compat/phone-numbers/search-local +[searchtollfree]: /docs/sdks/reference/php/rest/compat/phone-numbers/search-toll-free + +Manage incoming phone numbers with CRUD operations, search available inventory +by country, and import external numbers. + +Access via `client.compat.phoneNumbers` on a [`RestClient`][restclient] instance. + +```php +compat->phoneNumbers->list(); + + +``` + +## **Methods** + +### Phone Number CRUD + + + + List incoming phone numbers in the account. + + + Purchase a new phone number. + + + Retrieve a single phone number by SID. + + + Update a phone number's configuration. + + + Release a phone number. + + + +### Import + + + + Import an external phone number. + + + +### Available Numbers + + + + List countries with available phone numbers. + + + Search for available local numbers in a country. + + + Search for available toll-free numbers in a country. + + diff --git a/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/list-available-countries.mdx b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/list-available-countries.mdx new file mode 100644 index 000000000..d29802461 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/list-available-countries.mdx @@ -0,0 +1,33 @@ +--- +title: "listAvailableCountries" +slug: /reference/php/rest/compat/phone-numbers/list-available-countries +description: List countries with available phone numbers. +max-toc-depth: 3 +--- + +List countries that have phone numbers available for purchase. + +## **Parameters** + +No required parameters. + +## **Returns** + +`dict` -- Response containing available country resources. + +## **Example** + +```php {9-9} +compat->phoneNumbers->list_available_countries(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/list.mdx b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/list.mdx new file mode 100644 index 000000000..298becc8b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/list.mdx @@ -0,0 +1,43 @@ +--- +title: "list" +slug: /reference/php/rest/compat/phone-numbers/list +description: List incoming phone numbers in the account. +max-toc-depth: 3 +--- + +List incoming phone numbers in the account. + +## **Parameters** + + + Filter by exact phone number. + + + + Filter by friendly name. + + + + Number of results per page. + + +## **Returns** + +`dict` -- Paginated response containing phone number resources. + +## **Example** + +```php {9-9} +compat->phoneNumbers->list(PageSize: 20); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/purchase.mdx b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/purchase.mdx new file mode 100644 index 000000000..b472a559c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/purchase.mdx @@ -0,0 +1,54 @@ +--- +title: "purchase" +slug: /reference/php/rest/compat/phone-numbers/purchase +description: Purchase a new phone number. +max-toc-depth: 3 +--- + +Purchase a new phone number for the account. + +## **Parameters** + + + The phone number to purchase in E.164 format. + + + + A human-readable label for the number. + + + + URL to fetch LAML instructions when a call is received. + + + + URL to fetch LAML instructions when an SMS is received. + + + + URL to receive status webhook events. + + +## **Returns** + +`dict` -- The purchased phone number resource. + +## **Example** + +```php {9} +compat->phoneNumbers->purchase( + PhoneNumber: "+15551234567", + FriendlyName: "Main Line" +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/search-local.mdx b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/search-local.mdx new file mode 100644 index 000000000..b1dcda65f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/search-local.mdx @@ -0,0 +1,51 @@ +--- +title: "searchLocal" +slug: /reference/php/rest/compat/phone-numbers/search-local +description: Search for available local numbers in a country. +max-toc-depth: 3 +--- + +Search for available local phone numbers in a specific country. + +## **Parameters** + + + The ISO 3166-1 alpha-2 country code (e.g., `"US"`). + + + + Filter by area code. + + + + Filter by number pattern (e.g., `"555"`). + + + + Filter by region or state abbreviation. + + + + Number of results per page. + + +## **Returns** + +`dict` -- Paginated response containing available local number resources. + +## **Example** + +```php {9-9} +compat->phoneNumbers->search_local("US", AreaCode: "512"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/search-toll-free.mdx b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/search-toll-free.mdx new file mode 100644 index 000000000..e7ef4cdca --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/search-toll-free.mdx @@ -0,0 +1,43 @@ +--- +title: "searchTollFree" +slug: /reference/php/rest/compat/phone-numbers/search-toll-free +description: Search for available toll-free numbers in a country. +max-toc-depth: 3 +--- + +Search for available toll-free phone numbers in a specific country. + +## **Parameters** + + + The ISO 3166-1 alpha-2 country code (e.g., `"US"`). + + + + Filter by number pattern (e.g., `"800"`). + + + + Number of results per page. + + +## **Returns** + +`dict` -- Paginated response containing available toll-free number resources. + +## **Example** + +```php {9-9} +compat->phoneNumbers->search_toll_free("US", Contains: "800"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/update.mdx b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/update.mdx new file mode 100644 index 000000000..70f2308a1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/phone-numbers/update.mdx @@ -0,0 +1,54 @@ +--- +title: "update" +slug: /reference/php/rest/compat/phone-numbers/update +description: Update a phone number's configuration. +max-toc-depth: 3 +--- + +Update a phone number's configuration (e.g., change voice/SMS URLs). + +## **Parameters** + + + The phone number SID. + + + + A human-readable label for the number. + + + + URL to fetch LAML instructions when a call is received. + + + + URL to fetch LAML instructions when an SMS is received. + + + + URL to receive status webhook events. + + +## **Returns** + +`dict` -- The updated phone number resource. + +## **Example** + +```php {9} +compat->phoneNumbers->update( + "PN...", + VoiceUrl: "https://example.com/voice" +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/queues/create.mdx b/fern/products/sdks/pages/reference/php/rest/compat/queues/create.mdx new file mode 100644 index 000000000..86757628a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/queues/create.mdx @@ -0,0 +1,42 @@ +--- +title: "create" +slug: /reference/php/rest/compat/queues/create +description: Create a new queue. +max-toc-depth: 3 +--- + +Create a new call queue. + +## **Parameters** + + + A human-readable name for the queue. + + + + Maximum number of calls allowed in the queue. + + +## **Returns** + +`dict` -- The created queue resource. + +## **Example** + +```php {9} +compat->queues->create( + FriendlyName: "Support Queue", + MaxSize: 100 +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/queues/delete.mdx b/fern/products/sdks/pages/reference/php/rest/compat/queues/delete.mdx new file mode 100644 index 000000000..634a91442 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/queues/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/compat/queues/delete +description: Delete a queue. +max-toc-depth: 3 +--- + +Delete a queue. + +## **Parameters** + + + The queue SID to delete. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +compat->queues->delete("QU..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/queues/dequeue-member.mdx b/fern/products/sdks/pages/reference/php/rest/compat/queues/dequeue-member.mdx new file mode 100644 index 000000000..e06e4b733 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/queues/dequeue-member.mdx @@ -0,0 +1,50 @@ +--- +title: "dequeueMember" +slug: /reference/php/rest/compat/queues/dequeue-member +description: Dequeue a member from a queue. +max-toc-depth: 3 +--- + +Dequeue a member from a queue, redirecting the call to a new LAML URL. + +## **Parameters** + + + The SID of the queue. + + + + The call SID of the queue member to dequeue. + + + + The URL that returns LAML instructions for the dequeued call. + + + + HTTP method for the URL. Defaults to `"POST"`. + + +## **Returns** + +`dict` -- The dequeued member resource. + +## **Example** + +```php {9} +compat->queues->dequeue_member( + "QU...", "CA...", + Url: "https://example.com/dequeue" +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/queues/get-member.mdx b/fern/products/sdks/pages/reference/php/rest/compat/queues/get-member.mdx new file mode 100644 index 000000000..5cdb8a28a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/queues/get-member.mdx @@ -0,0 +1,39 @@ +--- +title: "getMember" +slug: /reference/php/rest/compat/queues/get-member +description: Retrieve a specific queue member. +max-toc-depth: 3 +--- + +Retrieve a specific member from a queue by call SID. + +## **Parameters** + + + The SID of the queue. + + + + The call SID of the queue member. + + +## **Returns** + +`dict` -- The queue member resource. + +## **Example** + +```php {9-9} +compat->queues->get_member("QU...", "CA..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/queues/get.mdx b/fern/products/sdks/pages/reference/php/rest/compat/queues/get.mdx new file mode 100644 index 000000000..356bfe01a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/queues/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/compat/queues/get +description: Retrieve a single queue by SID. +max-toc-depth: 3 +--- + +Retrieve a single queue by SID. + +## **Parameters** + + + The queue SID. + + +## **Returns** + +`dict` -- The queue resource. + +## **Example** + +```php {9-9} +compat->queues->get("QU..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/queues/index.mdx b/fern/products/sdks/pages/reference/php/rest/compat/queues/index.mdx new file mode 100644 index 000000000..7df08eae3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/queues/index.mdx @@ -0,0 +1,72 @@ +--- +title: "Queues" +slug: /reference/php/rest/compat/queues +description: Manage call queues with CRUD operations and member management. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/compat/queues/list +[create]: /docs/sdks/reference/php/rest/compat/queues/create +[get]: /docs/sdks/reference/php/rest/compat/queues/get +[update]: /docs/sdks/reference/php/rest/compat/queues/update +[delete]: /docs/sdks/reference/php/rest/compat/queues/delete +[listmembers]: /docs/sdks/reference/php/rest/compat/queues/list-members +[getmember]: /docs/sdks/reference/php/rest/compat/queues/get-member +[dequeuemember]: /docs/sdks/reference/php/rest/compat/queues/dequeue-member + +Manage call queues with CRUD operations and member sub-resources for dequeuing +callers. + +Access via `client.compat.queues` on a [`RestClient`][restclient] instance. + +```php +compat->queues->list(); + + +``` + +## **Methods** + +### Queue CRUD + + + + List queues in the account. + + + Create a new queue. + + + Retrieve a single queue by SID. + + + Update a queue. + + + Delete a queue. + + + +### Members + + + + List members in a queue. + + + Retrieve a specific queue member. + + + Dequeue a member from a queue. + + diff --git a/fern/products/sdks/pages/reference/php/rest/compat/queues/list-members.mdx b/fern/products/sdks/pages/reference/php/rest/compat/queues/list-members.mdx new file mode 100644 index 000000000..ef13d32e3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/queues/list-members.mdx @@ -0,0 +1,39 @@ +--- +title: "listMembers" +slug: /reference/php/rest/compat/queues/list-members +description: List members in a queue. +max-toc-depth: 3 +--- + +List members currently waiting in a queue. + +## **Parameters** + + + The SID of the queue. + + + + Number of results per page. + + +## **Returns** + +`dict` -- Paginated response containing queue member resources. + +## **Example** + +```php {9-9} +compat->queues->list_members("QU..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/queues/list.mdx b/fern/products/sdks/pages/reference/php/rest/compat/queues/list.mdx new file mode 100644 index 000000000..5c6c6c277 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/queues/list.mdx @@ -0,0 +1,39 @@ +--- +title: "list" +slug: /reference/php/rest/compat/queues/list +description: List queues in the account. +max-toc-depth: 3 +--- + +List queues in the account. + +## **Parameters** + + + Filter by friendly name. + + + + Number of results per page. + + +## **Returns** + +`dict` -- Paginated response containing queue resources. + +## **Example** + +```php {9-9} +compat->queues->list(PageSize: 20); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/queues/update.mdx b/fern/products/sdks/pages/reference/php/rest/compat/queues/update.mdx new file mode 100644 index 000000000..1e44a7f41 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/queues/update.mdx @@ -0,0 +1,43 @@ +--- +title: "update" +slug: /reference/php/rest/compat/queues/update +description: Update a queue. +max-toc-depth: 3 +--- + +Update a queue's configuration. Uses POST (Twilio convention). + +## **Parameters** + + + The queue SID. + + + + A human-readable name for the queue. + + + + Maximum number of calls allowed in the queue. + + +## **Returns** + +`dict` -- The updated queue resource. + +## **Example** + +```php {9-9} +compat->queues->update("QU...", MaxSize: 200); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/recordings/delete.mdx b/fern/products/sdks/pages/reference/php/rest/compat/recordings/delete.mdx new file mode 100644 index 000000000..d2cd69144 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/recordings/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/compat/recordings/delete +description: Delete a recording. +max-toc-depth: 3 +--- + +Delete a recording. + +## **Parameters** + + + The recording SID to delete. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +compat->recordings->delete("RE..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/recordings/get.mdx b/fern/products/sdks/pages/reference/php/rest/compat/recordings/get.mdx new file mode 100644 index 000000000..b4c7e2d69 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/recordings/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/compat/recordings/get +description: Retrieve a single recording by SID. +max-toc-depth: 3 +--- + +Retrieve a single recording by SID. + +## **Parameters** + + + The recording SID. + + +## **Returns** + +`dict` -- The recording resource. + +## **Example** + +```php {9-9} +compat->recordings->get("RE..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/recordings/index.mdx b/fern/products/sdks/pages/reference/php/rest/compat/recordings/index.mdx new file mode 100644 index 000000000..1e7be0626 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/recordings/index.mdx @@ -0,0 +1,44 @@ +--- +title: "Recordings" +slug: /reference/php/rest/compat/recordings +description: Manage call recordings. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/compat/recordings/list +[get]: /docs/sdks/reference/php/rest/compat/recordings/get +[delete]: /docs/sdks/reference/php/rest/compat/recordings/delete + +Manage call recordings with list, get, and delete operations. + +Access via `client.compat.recordings` on a [`RestClient`][restclient] instance. + +```php +compat->recordings->list(); + + +``` + +## **Methods** + + + + List recordings in the account. + + + Retrieve a single recording by SID. + + + Delete a recording. + + diff --git a/fern/products/sdks/pages/reference/php/rest/compat/recordings/list.mdx b/fern/products/sdks/pages/reference/php/rest/compat/recordings/list.mdx new file mode 100644 index 000000000..f790bb821 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/recordings/list.mdx @@ -0,0 +1,43 @@ +--- +title: "list" +slug: /reference/php/rest/compat/recordings/list +description: List recordings in the account. +max-toc-depth: 3 +--- + +List recordings in the account. + +## **Parameters** + + + Filter by creation date. + + + + Filter by the call SID that generated the recording. + + + + Number of results per page. + + +## **Returns** + +`dict` -- Paginated response containing recording resources. + +## **Example** + +```php {9-9} +compat->recordings->list(PageSize: 20); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/tokens/create.mdx b/fern/products/sdks/pages/reference/php/rest/compat/tokens/create.mdx new file mode 100644 index 000000000..520392d3d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/tokens/create.mdx @@ -0,0 +1,35 @@ +--- +title: "create" +slug: /reference/php/rest/compat/tokens/create +description: Create a new API token. +max-toc-depth: 3 +--- + +Create a new API token. + +## **Parameters** + + + Time-to-live in seconds for the token. + + +## **Returns** + +`dict` -- The created token resource. + +## **Example** + +```php {9-9} +compat->tokens->create(Ttl: 3600); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/tokens/delete.mdx b/fern/products/sdks/pages/reference/php/rest/compat/tokens/delete.mdx new file mode 100644 index 000000000..611d7c467 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/tokens/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/compat/tokens/delete +description: Delete an API token. +max-toc-depth: 3 +--- + +Delete an API token. + +## **Parameters** + + + The token identifier to delete. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +compat->tokens->delete("token-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/tokens/index.mdx b/fern/products/sdks/pages/reference/php/rest/compat/tokens/index.mdx new file mode 100644 index 000000000..1b9a5c4d1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/tokens/index.mdx @@ -0,0 +1,44 @@ +--- +title: "Tokens" +slug: /reference/php/rest/compat/tokens +description: Manage API tokens. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[create]: /docs/sdks/reference/php/rest/compat/tokens/create +[update]: /docs/sdks/reference/php/rest/compat/tokens/update +[delete]: /docs/sdks/reference/php/rest/compat/tokens/delete + +Manage API tokens with create, update, and delete operations. + +Access via `client.compat.tokens` on a [`RestClient`][restclient] instance. + +```php +compat->tokens->create(); + + +``` + +## **Methods** + + + + Create a new API token. + + + Update an API token. + + + Delete an API token. + + diff --git a/fern/products/sdks/pages/reference/php/rest/compat/tokens/update.mdx b/fern/products/sdks/pages/reference/php/rest/compat/tokens/update.mdx new file mode 100644 index 000000000..d23f1d107 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/tokens/update.mdx @@ -0,0 +1,39 @@ +--- +title: "update" +slug: /reference/php/rest/compat/tokens/update +description: Update an API token. +max-toc-depth: 3 +--- + +Update an API token. Uses PATCH. + +## **Parameters** + + + The token identifier. + + + + New time-to-live in seconds for the token. + + +## **Returns** + +`dict` -- The updated token resource. + +## **Example** + +```php {9-9} +compat->tokens->update("token-id", Ttl: 7200); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/transcriptions/delete.mdx b/fern/products/sdks/pages/reference/php/rest/compat/transcriptions/delete.mdx new file mode 100644 index 000000000..ef78dc7a9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/transcriptions/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/compat/transcriptions/delete +description: Delete a transcription. +max-toc-depth: 3 +--- + +Delete a transcription. + +## **Parameters** + + + The transcription SID to delete. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +compat->transcriptions->delete("TR..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/transcriptions/get.mdx b/fern/products/sdks/pages/reference/php/rest/compat/transcriptions/get.mdx new file mode 100644 index 000000000..2fef969d9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/transcriptions/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/compat/transcriptions/get +description: Retrieve a single transcription by SID. +max-toc-depth: 3 +--- + +Retrieve a single transcription by SID. + +## **Parameters** + + + The transcription SID. + + +## **Returns** + +`dict` -- The transcription resource. + +## **Example** + +```php {9-9} +compat->transcriptions->get("TR..."); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/compat/transcriptions/index.mdx b/fern/products/sdks/pages/reference/php/rest/compat/transcriptions/index.mdx new file mode 100644 index 000000000..2bc60e94e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/transcriptions/index.mdx @@ -0,0 +1,44 @@ +--- +title: "Transcriptions" +slug: /reference/php/rest/compat/transcriptions +description: Manage call transcriptions. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/compat/transcriptions/list +[get]: /docs/sdks/reference/php/rest/compat/transcriptions/get +[delete]: /docs/sdks/reference/php/rest/compat/transcriptions/delete + +Manage call transcriptions with list, get, and delete operations. + +Access via `client.compat.transcriptions` on a [`RestClient`][restclient] instance. + +```php +compat->transcriptions->list(); + + +``` + +## **Methods** + + + + List transcriptions in the account. + + + Retrieve a single transcription by SID. + + + Delete a transcription. + + diff --git a/fern/products/sdks/pages/reference/php/rest/compat/transcriptions/list.mdx b/fern/products/sdks/pages/reference/php/rest/compat/transcriptions/list.mdx new file mode 100644 index 000000000..7f2aa27bc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/compat/transcriptions/list.mdx @@ -0,0 +1,35 @@ +--- +title: "list" +slug: /reference/php/rest/compat/transcriptions/list +description: List transcriptions in the account. +max-toc-depth: 3 +--- + +List transcriptions in the account. + +## **Parameters** + + + Number of results per page. + + +## **Returns** + +`dict` -- Paginated response containing transcription resources. + +## **Example** + +```php {9-9} +compat->transcriptions->list(PageSize: 20); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/datasphere/create.mdx b/fern/products/sdks/pages/reference/php/rest/datasphere/create.mdx new file mode 100644 index 000000000..d29b1f795 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/datasphere/create.mdx @@ -0,0 +1,49 @@ +--- +title: "create" +slug: /reference/php/rest/datasphere/create +description: Upload a new document. +max-toc-depth: 3 +--- + +[ref-datasphere]: /docs/sdks/reference/php/rest/datasphere + +Upload a new document to the [Datasphere][ref-datasphere]. + +## **Parameters** + + + Document name or title. + + + + Document content text. + + + + Additional document fields (e.g., `metadata`). + + +## **Returns** + +`dict` -- The newly created document object. + +## **Example** + +```php {9} +datasphere->documents->create( + name: "FAQ", + content: "Frequently asked questions and answers...", +); +echo "Document ID:", $doc["id"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/datasphere/delete.mdx b/fern/products/sdks/pages/reference/php/rest/datasphere/delete.mdx new file mode 100644 index 000000000..f1b1042ac --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/datasphere/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/datasphere/delete +description: Delete a document and all its chunks. +max-toc-depth: 3 +--- + +Delete a document and all its chunks. + +## **Parameters** + + + The document resource ID. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +datasphere->documents->delete("document-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/datasphere/get.mdx b/fern/products/sdks/pages/reference/php/rest/datasphere/get.mdx new file mode 100644 index 000000000..25e650dd3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/datasphere/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/datasphere/get +description: Retrieve a specific document. +max-toc-depth: 3 +--- + +Retrieve a specific document by ID. + +## **Parameters** + + + The document resource ID. + + +## **Returns** + +`dict` -- The document object. + +## **Example** + +```php {9-10} +datasphere->documents->get("document-id"); +echo $doc["name"] ?? null, $doc["id"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/datasphere/index.mdx b/fern/products/sdks/pages/reference/php/rest/datasphere/index.mdx new file mode 100644 index 000000000..c92144d0d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/datasphere/index.mdx @@ -0,0 +1,57 @@ +--- +title: "Datasphere" +slug: /reference/php/rest/datasphere +description: "Document storage and vector search." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/datasphere/list +[create]: /docs/sdks/reference/php/rest/datasphere/create +[get]: /docs/sdks/reference/php/rest/datasphere/get +[update]: /docs/sdks/reference/php/rest/datasphere/update +[delete]: /docs/sdks/reference/php/rest/datasphere/delete + +Manage documents and perform semantic search via the Datasphere API. Documents +are stored with vector embeddings, enabling natural-language search across your +knowledge base. The `documents` sub-resource provides full CRUD plus search and +chunk-level operations. + +Access via `client.datasphere.documents` on a [`RestClient`][restclient] instance. + +```php +datasphere->documents->search(query_string: "billing FAQ"); +foreach ($results["data"] ?? [] as $doc) { + echo $doc["id"], $doc["title"] ?? null; +} + +``` + +## **Methods** + + + + List documents in the project. + + + Upload a new document. + + + Retrieve a specific document. + + + Update a document. + + + Delete a document and all its chunks. + + diff --git a/fern/products/sdks/pages/reference/php/rest/datasphere/list.mdx b/fern/products/sdks/pages/reference/php/rest/datasphere/list.mdx new file mode 100644 index 000000000..3987a0bf8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/datasphere/list.mdx @@ -0,0 +1,38 @@ +--- +title: "list" +slug: /reference/php/rest/datasphere/list +description: List documents in the project. +max-toc-depth: 3 +--- + +List documents in the project. + +## **Parameters** + + + Optional query parameters to filter and paginate results. + + +## **Returns** + +`dict` -- JSON response containing a `data` list of document objects. + +## **Example** + +```php {9} +datasphere->documents->list(); +foreach ($result["data"] ?? [] as $doc) { + echo $doc["name"] ?? null, $doc["id"] ?? null; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/datasphere/update.mdx b/fern/products/sdks/pages/reference/php/rest/datasphere/update.mdx new file mode 100644 index 000000000..4d707b721 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/datasphere/update.mdx @@ -0,0 +1,43 @@ +--- +title: "update" +slug: /reference/php/rest/datasphere/update +description: Update a document. +max-toc-depth: 3 +--- + +Update an existing document. + +## **Parameters** + + + The document resource ID. + + + + Fields to update (e.g., `name`, `content`, `metadata`). + + +## **Returns** + +`dict` -- The updated document object. + +## **Example** + +```php {9} +datasphere->documents->update( + "document-id", + name: "Updated FAQ", +); +echo $updated["name"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/addresses.mdx new file mode 100644 index 000000000..9cccd2c9e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/addresses.mdx @@ -0,0 +1,70 @@ +--- +title: "Addresses" +slug: /reference/php/rest/fabric/addresses +description: Read-only access to fabric addresses. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client + +Read-only access to fabric addresses. Addresses represent the endpoints (phone numbers, +SIP URIs, domains) that route traffic to fabric resources. + +Access via `client.fabric.addresses` on a [`RestClient`][restclient] instance. + +### list + +List all fabric addresses. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing fabric addresses. + +### get + +Retrieve a single fabric address. + +## **Parameters** + + + The unique identifier of the address. + + +## **Returns** + +`dict` -- The fabric address resource. + +## **Example** + +```php +fabric->addresses->list(); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['type']}"; +} + +// Get a specific address +$address = $client->fabric->addresses->get("address-id"); +echo "Address: {$address['display_name']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents.mdx new file mode 100644 index 000000000..741b857f6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents.mdx @@ -0,0 +1,35 @@ +--- +title: "aiAgents" +slug: /reference/php/rest/fabric/ai-agents +description: Access the AI Agents resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/fabric + +Access the AI Agents resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +fabric(); + +$result = $fabric->aiAgents(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/create.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/create.mdx new file mode 100644 index 000000000..f2b83a450 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/create.mdx @@ -0,0 +1,40 @@ +--- +title: "create" +slug: /reference/php/rest/fabric/ai-agents/create +description: Create a new AI agent resource. +max-toc-depth: 3 +--- + +Create a new AI agent resource. + +## **Parameters** + + + Display name of the AI agent. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created AI agent resource. + +## **Example** + +```php {9} +fabric->ai_agents->create( + name: "support-bot", type: "ai_agent", +); +echo "Created: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/delete.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/delete.mdx new file mode 100644 index 000000000..5b9f76337 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/fabric/ai-agents/delete +description: Delete an AI agent resource. +max-toc-depth: 3 +--- + +Delete an AI agent resource. + +## **Parameters** + + + The unique identifier of the AI agent to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->ai_agents->delete("agent-id"); +echo "AI Agent deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/get.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/get.mdx new file mode 100644 index 000000000..d730a25a7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/fabric/ai-agents/get +description: Retrieve a single AI agent resource. +max-toc-depth: 3 +--- + +Retrieve a single AI agent resource. + +## **Parameters** + + + The unique identifier of the AI agent. + + +## **Returns** + +`dict` -- The AI agent resource. + +## **Example** + +```php {9} +fabric->ai_agents->get("agent-id"); +echo "AI Agent: {$agent['name']}, ID: {$agent['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/index.mdx new file mode 100644 index 000000000..814dec781 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/index.mdx @@ -0,0 +1,56 @@ +--- +title: "AI Agents" +slug: /reference/php/rest/fabric/ai-agents +description: Manage AI agent resources via the Fabric namespace. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/fabric/ai-agents/list +[create]: /docs/sdks/reference/php/rest/fabric/ai-agents/create +[get]: /docs/sdks/reference/php/rest/fabric/ai-agents/get +[update]: /docs/sdks/reference/php/rest/fabric/ai-agents/update +[delete]: /docs/sdks/reference/php/rest/fabric/ai-agents/delete +[listaddresses]: /docs/sdks/reference/php/rest/fabric/ai-agents/list-addresses + +Manage AI agent resources. Standard CRUD with PATCH updates and address listing. + +Access via `client.fabric.ai_agents` on a [`RestClient`][restclient] instance. + +```php +fabric->ai_agents->list(); + + +``` + +## **Methods** + + + + List AI agent resources. + + + Create a new AI agent resource. + + + Retrieve a single AI agent resource. + + + Partially update an AI agent resource. + + + Delete an AI agent resource. + + + List addresses for an AI agent resource. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/list-addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/list-addresses.mdx new file mode 100644 index 000000000..489b39b44 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/list-addresses.mdx @@ -0,0 +1,38 @@ +--- +title: "listAddresses" +slug: /reference/php/rest/fabric/ai-agents/list-addresses +description: List addresses associated with an AI agent resource. +max-toc-depth: 3 +--- + +List addresses associated with an AI agent resource. + +## **Parameters** + + + The unique identifier of the AI agent. + + +## **Returns** + +`dict` -- List of addresses assigned to this resource. + +## **Example** + +```php {9} +fabric->ai_agents->list_addresses("agent-id"); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/list.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/list.mdx new file mode 100644 index 000000000..f1a8a80ff --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/list.mdx @@ -0,0 +1,42 @@ +--- +title: "list" +slug: /reference/php/rest/fabric/ai-agents/list +description: List AI agent resources. +max-toc-depth: 3 +--- + +List AI agent resources in the project. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing AI agent resources. + +## **Example** + +```php {9} +fabric->ai_agents->list(); +foreach ($response["data"] ?? [] as $agent) { + echo "{$agent['name']}: {$agent['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/update.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/update.mdx new file mode 100644 index 000000000..84de5d639 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/ai-agents/update.mdx @@ -0,0 +1,38 @@ +--- +title: "update" +slug: /reference/php/rest/fabric/ai-agents/update +description: Partially update an AI agent resource. +max-toc-depth: 3 +--- + +Partially update an AI agent resource. Uses PATCH, so only provided fields are changed. + +## **Parameters** + + + The unique identifier of the AI agent. + + +Additional keyword arguments are the fields to update. + +## **Returns** + +`dict` -- The updated AI agent resource. + +## **Example** + +```php {9} +fabric->ai_agents->update("agent-id", name: "updated-name"); +echo "Updated: {$updated['name']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/call-flows.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows.mdx new file mode 100644 index 000000000..4efaa26f6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows.mdx @@ -0,0 +1,35 @@ +--- +title: "callFlows" +slug: /reference/php/rest/fabric/call-flows +description: Access the Call Flows resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/fabric + +Access the Call Flows resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +fabric(); + +$result = $fabric->callFlows(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/create.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/create.mdx new file mode 100644 index 000000000..8bed576f3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/create.mdx @@ -0,0 +1,40 @@ +--- +title: "create" +slug: /reference/php/rest/fabric/call-flows/create +description: Create a new call flow resource. +max-toc-depth: 3 +--- + +Create a new call flow resource. + +## **Parameters** + + + Display name of the call flow. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created call flow resource. + +## **Example** + +```php {9} +fabric->call_flows->create( + name: "inbound-flow", +); +echo "Created: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/delete.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/delete.mdx new file mode 100644 index 000000000..f21bd6931 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/fabric/call-flows/delete +description: Delete a call flow resource. +max-toc-depth: 3 +--- + +Delete a call flow resource. + +## **Parameters** + + + The unique identifier of the call flow to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->call_flows->delete("flow-id"); +echo "Call Flow deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/deploy-version.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/deploy-version.mdx new file mode 100644 index 000000000..9ce390f4d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/deploy-version.mdx @@ -0,0 +1,40 @@ +--- +title: "deployVersion" +slug: /reference/php/rest/fabric/call-flows/deploy-version +description: Deploy a specific version of a call flow. +max-toc-depth: 3 +--- + +Deploy a specific version of a call flow resource. + +## **Parameters** + + + The unique identifier of the call flow. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The deployed version details. + +## **Example** + +```php {9} +fabric->call_flows->deploy_version( + "call-flow-id", version_id: "version-id", +); +echo "Deployed version: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/get.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/get.mdx new file mode 100644 index 000000000..f02272343 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/fabric/call-flows/get +description: Retrieve a single call flow resource. +max-toc-depth: 3 +--- + +Retrieve a single call flow resource. + +## **Parameters** + + + The unique identifier of the call flow. + + +## **Returns** + +`dict` -- The call flow resource. + +## **Example** + +```php {9} +fabric->call_flows->get("flow-id"); +echo "Call Flow: {$flow['name']}, ID: {$flow['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/index.mdx new file mode 100644 index 000000000..1e35033eb --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/index.mdx @@ -0,0 +1,65 @@ +--- +title: "Call Flows" +slug: /reference/php/rest/fabric/call-flows +description: Manage call flow resources with versioning and deployment. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/fabric/call-flows/list +[create]: /docs/sdks/reference/php/rest/fabric/call-flows/create +[get]: /docs/sdks/reference/php/rest/fabric/call-flows/get +[update]: /docs/sdks/reference/php/rest/fabric/call-flows/update +[delete]: /docs/sdks/reference/php/rest/fabric/call-flows/delete +[listaddresses]: /docs/sdks/reference/php/rest/fabric/call-flows/list-addresses +[listversions]: /docs/sdks/reference/php/rest/fabric/call-flows/list-versions +[deployversion]: /docs/sdks/reference/php/rest/fabric/call-flows/deploy-version + +Manage call flow resources with version management and deployment. Extends standard CRUD +(PUT updates) with methods to list versions and deploy specific versions. + +Access via `client.fabric.call_flows` on a [`RestClient`][restclient] instance. + +```php +fabric->call_flows->list(); + + +``` + +## **Methods** + + + + List call flow resources. + + + Create a new call flow resource. + + + Retrieve a single call flow resource. + + + Replace a call flow resource. + + + Delete a call flow resource. + + + List addresses for a call flow resource. + + + List all versions of a call flow. + + + Deploy a specific version of a call flow. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/list-addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/list-addresses.mdx new file mode 100644 index 000000000..498af977b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/list-addresses.mdx @@ -0,0 +1,38 @@ +--- +title: "listAddresses" +slug: /reference/php/rest/fabric/call-flows/list-addresses +description: List addresses associated with a call flow resource. +max-toc-depth: 3 +--- + +List addresses associated with a call flow resource. + +## **Parameters** + + + The unique identifier of the call flow. + + +## **Returns** + +`dict` -- List of addresses assigned to this call flow. + +## **Example** + +```php {9} +fabric->call_flows->list_addresses("flow-id"); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/list-versions.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/list-versions.mdx new file mode 100644 index 000000000..4b6c341f6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/list-versions.mdx @@ -0,0 +1,46 @@ +--- +title: "listVersions" +slug: /reference/php/rest/fabric/call-flows/list-versions +description: List all versions of a call flow. +max-toc-depth: 3 +--- + +List all versions of a call flow resource. + +## **Parameters** + + + The unique identifier of the call flow. + + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing call flow versions. + +## **Example** + +```php {9} +fabric->call_flows->list_versions("call-flow-id"); +foreach ($response["data"] ?? [] as $version) { + echo "Version {$version['version']}: {$version['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/list.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/list.mdx new file mode 100644 index 000000000..9502c671f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/list.mdx @@ -0,0 +1,42 @@ +--- +title: "list" +slug: /reference/php/rest/fabric/call-flows/list +description: List call flow resources. +max-toc-depth: 3 +--- + +List call flow resources in the project. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing call flow resources. + +## **Example** + +```php {9} +fabric->call_flows->list(); +foreach ($response["data"] ?? [] as $flow) { + echo "{$flow['name']}: {$flow['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/update.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/update.mdx new file mode 100644 index 000000000..94235109a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/call-flows/update.mdx @@ -0,0 +1,38 @@ +--- +title: "update" +slug: /reference/php/rest/fabric/call-flows/update +description: Replace a call flow resource. +max-toc-depth: 3 +--- + +Replace a call flow resource. Uses PUT for full replacement. + +## **Parameters** + + + The unique identifier of the call flow. + + +Additional keyword arguments are the full replacement body. + +## **Returns** + +`dict` -- The updated call flow resource. + +## **Example** + +```php {9} +fabric->call_flows->update("flow-id", name: "updated-name"); +echo "Updated: {$updated['name']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/call-queues.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/call-queues.mdx new file mode 100644 index 000000000..721844e0a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/call-queues.mdx @@ -0,0 +1,35 @@ +--- +title: "callQueues" +slug: /reference/php/rest/fabric/call-queues +description: Access the Call Queues resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/fabric + +Access the Call Queues resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +fabric(); + +$result = $fabric->callQueues(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms.mdx new file mode 100644 index 000000000..31badca6f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms.mdx @@ -0,0 +1,35 @@ +--- +title: "conferenceRooms" +slug: /reference/php/rest/fabric/conference-rooms +description: Access the Conference Rooms resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/fabric + +Access the Conference Rooms resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +fabric(); + +$result = $fabric->conferenceRooms(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/create.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/create.mdx new file mode 100644 index 000000000..c39f06d50 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/create.mdx @@ -0,0 +1,40 @@ +--- +title: "create" +slug: /reference/php/rest/fabric/conference-rooms/create +description: Create a new conference room resource. +max-toc-depth: 3 +--- + +Create a new conference room resource. + +## **Parameters** + + + Display name of the conference room. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created conference room resource. + +## **Example** + +```php {9} +fabric->conference_rooms->create( + name: "my-room", +); +echo "Created: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/delete.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/delete.mdx new file mode 100644 index 000000000..529a4efe4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/fabric/conference-rooms/delete +description: Delete a conference room resource. +max-toc-depth: 3 +--- + +Delete a conference room resource. + +## **Parameters** + + + The unique identifier of the conference room to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->conference_rooms->delete("room-id"); +echo "Conference Room deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/get.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/get.mdx new file mode 100644 index 000000000..0dd50c2e0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/fabric/conference-rooms/get +description: Retrieve a single conference room resource. +max-toc-depth: 3 +--- + +Retrieve a single conference room resource. + +## **Parameters** + + + The unique identifier of the conference room. + + +## **Returns** + +`dict` -- The conference room resource. + +## **Example** + +```php {9} +fabric->conference_rooms->get("room-id"); +echo "Conference Room: {$room['name']}, ID: {$room['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/index.mdx new file mode 100644 index 000000000..67f7b2203 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/index.mdx @@ -0,0 +1,56 @@ +--- +title: "Conference Rooms" +slug: /reference/php/rest/fabric/conference-rooms +description: Manage conference room resources via the Fabric namespace. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/fabric/conference-rooms/list +[create]: /docs/sdks/reference/php/rest/fabric/conference-rooms/create +[get]: /docs/sdks/reference/php/rest/fabric/conference-rooms/get +[update]: /docs/sdks/reference/php/rest/fabric/conference-rooms/update +[delete]: /docs/sdks/reference/php/rest/fabric/conference-rooms/delete +[listaddresses]: /docs/sdks/reference/php/rest/fabric/conference-rooms/list-addresses + +Manage conference room resources. Standard CRUD with PUT updates and address listing. + +Access via `client.fabric.conference_rooms` on a [`RestClient`][restclient] instance. + +```php +fabric->conference_rooms->list(); + + +``` + +## **Methods** + + + + List conference room resources. + + + Create a new conference room resource. + + + Retrieve a single conference room resource. + + + Replace a conference room resource. + + + Delete a conference room resource. + + + List addresses for a conference room resource. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/list-addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/list-addresses.mdx new file mode 100644 index 000000000..680fa602a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/list-addresses.mdx @@ -0,0 +1,38 @@ +--- +title: "listAddresses" +slug: /reference/php/rest/fabric/conference-rooms/list-addresses +description: List addresses associated with a conference room resource. +max-toc-depth: 3 +--- + +List addresses associated with a conference room resource. + +## **Parameters** + + + The unique identifier of the conference room. + + +## **Returns** + +`dict` -- List of addresses assigned to this resource. + +## **Example** + +```php {9} +fabric->conference_rooms->list_addresses("room-id"); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/list.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/list.mdx new file mode 100644 index 000000000..5d392b218 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/list.mdx @@ -0,0 +1,42 @@ +--- +title: "list" +slug: /reference/php/rest/fabric/conference-rooms/list +description: List conference room resources. +max-toc-depth: 3 +--- + +List conference room resources in the project. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing conference room resources. + +## **Example** + +```php {9} +fabric->conference_rooms->list(); +foreach ($response["data"] ?? [] as $room) { + echo "{$room['name']}: {$room['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/update.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/update.mdx new file mode 100644 index 000000000..05585ed03 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/conference-rooms/update.mdx @@ -0,0 +1,38 @@ +--- +title: "update" +slug: /reference/php/rest/fabric/conference-rooms/update +description: Replace a conference room resource. +max-toc-depth: 3 +--- + +Replace a conference room resource. Uses PUT for full replacement. + +## **Parameters** + + + The unique identifier of the conference room. + + +Additional keyword arguments are the full replacement body. + +## **Returns** + +`dict` -- The updated conference room resource. + +## **Example** + +```php {9} +fabric->conference_rooms->update("room-id", name: "updated-name"); +echo "Updated: {$updated['name']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/conversations.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/conversations.mdx new file mode 100644 index 000000000..5468b5edb --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/conversations.mdx @@ -0,0 +1,35 @@ +--- +title: "conversations" +slug: /reference/php/rest/fabric/conversations +description: Access the Conversations resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/fabric + +Access the Conversations resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +fabric(); + +$result = $fabric->conversations(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/delete.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/delete.mdx new file mode 100644 index 000000000..b19ba0547 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/fabric/cxml-applications/delete +description: Delete a cXML application resource. +max-toc-depth: 3 +--- + +Delete a cXML application resource. + +## **Parameters** + + + The unique identifier of the cXML application to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->cxml_applications->delete("app-id"); +echo "cXML application deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/get.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/get.mdx new file mode 100644 index 000000000..3111ae9b5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/fabric/cxml-applications/get +description: Retrieve a single cXML application resource. +max-toc-depth: 3 +--- + +Retrieve a single cXML application resource. + +## **Parameters** + + + The unique identifier of the cXML application. + + +## **Returns** + +`dict` -- The cXML application resource. + +## **Example** + +```php {9} +fabric->cxml_applications->get("app-id"); +echo "cXML Application: {$app['name']}, ID: {$app['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/index.mdx new file mode 100644 index 000000000..b8b9ddc3a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/index.mdx @@ -0,0 +1,53 @@ +--- +title: "cXML Applications" +slug: /reference/php/rest/fabric/cxml-applications +description: Manage cXML application resources. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/fabric/cxml-applications/list +[get]: /docs/sdks/reference/php/rest/fabric/cxml-applications/get +[update]: /docs/sdks/reference/php/rest/fabric/cxml-applications/update +[delete]: /docs/sdks/reference/php/rest/fabric/cxml-applications/delete +[listaddresses]: /docs/sdks/reference/php/rest/fabric/cxml-applications/list-addresses + +Manage cXML application resources. Supports list, get, update (PUT), and delete operations. +The `create` method is not available for cXML applications and raises `NotImplementedError`. + +Access via `client.fabric.cxml_applications` on a [`RestClient`][restclient] instance. + +```php +fabric->cxml_applications->list(); + + +``` + +## **Methods** + + + + List cXML application resources. + + + Retrieve a single cXML application resource. + + + Replace a cXML application resource. + + + Delete a cXML application resource. + + + List addresses for a cXML application resource. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/list-addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/list-addresses.mdx new file mode 100644 index 000000000..3a2ab8a8e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/list-addresses.mdx @@ -0,0 +1,38 @@ +--- +title: "listAddresses" +slug: /reference/php/rest/fabric/cxml-applications/list-addresses +description: List addresses associated with a cXML application resource. +max-toc-depth: 3 +--- + +List addresses associated with a cXML application resource. + +## **Parameters** + + + The unique identifier of the cXML application. + + +## **Returns** + +`dict` -- List of addresses assigned to this resource. + +## **Example** + +```php {9} +fabric->cxml_applications->list_addresses("app-id"); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/list.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/list.mdx new file mode 100644 index 000000000..8983c5b73 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/list.mdx @@ -0,0 +1,42 @@ +--- +title: "list" +slug: /reference/php/rest/fabric/cxml-applications/list +description: List cXML application resources. +max-toc-depth: 3 +--- + +List cXML application resources in the project. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing cXML application resources. + +## **Example** + +```php {9} +fabric->cxml_applications->list(); +foreach ($response["data"] ?? [] as $app) { + echo "{$app['name']}: {$app['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/update.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/update.mdx new file mode 100644 index 000000000..0b5178bd5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-applications/update.mdx @@ -0,0 +1,40 @@ +--- +title: "update" +slug: /reference/php/rest/fabric/cxml-applications/update +description: Replace a cXML application resource. +max-toc-depth: 3 +--- + +Replace a cXML application resource. Uses PUT, so the full resource body must be provided. + +## **Parameters** + + + The unique identifier of the cXML application. + + +Additional keyword arguments are the fields for the replacement resource body. + +## **Returns** + +`dict` -- The updated cXML application resource. + +## **Example** + +```php {9} +fabric->cxml_applications->update( + "app-id", name: "updated-cxml-app", +); +echo "Updated: {$updated['name']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/create.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/create.mdx new file mode 100644 index 000000000..04bdcec03 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/create.mdx @@ -0,0 +1,40 @@ +--- +title: "create" +slug: /reference/php/rest/fabric/cxml-scripts/create +description: Create a new cXML script resource. +max-toc-depth: 3 +--- + +Create a new cXML script resource. + +## **Parameters** + + + Display name of the cXML script. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created cXML script resource. + +## **Example** + +```php {9} +fabric->cxml_scripts->create( + name: "my-item", +); +echo "Created: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/delete.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/delete.mdx new file mode 100644 index 000000000..e9ca805ab --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/fabric/cxml-scripts/delete +description: Delete a cXML script resource. +max-toc-depth: 3 +--- + +Delete a cXML script resource. + +## **Parameters** + + + The unique identifier of the cXML script to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->cxml_scripts->delete("resource-id"); +echo "Cxml Script deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/get.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/get.mdx new file mode 100644 index 000000000..a101c6f76 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/fabric/cxml-scripts/get +description: Retrieve a single cXML script resource. +max-toc-depth: 3 +--- + +Retrieve a single cXML script resource. + +## **Parameters** + + + The unique identifier of the cXML script. + + +## **Returns** + +`dict` -- The cXML script resource. + +## **Example** + +```php {9} +fabric->cxml_scripts->get("resource-id"); +echo "Cxml Script: {$item['name']}, ID: {$item['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/index.mdx new file mode 100644 index 000000000..f91c04653 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/index.mdx @@ -0,0 +1,56 @@ +--- +title: "cXML Scripts" +slug: /reference/php/rest/fabric/cxml-scripts +description: Manage cXML script resources via the Fabric namespace. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/fabric/cxml-scripts/list +[create]: /docs/sdks/reference/php/rest/fabric/cxml-scripts/create +[get]: /docs/sdks/reference/php/rest/fabric/cxml-scripts/get +[update]: /docs/sdks/reference/php/rest/fabric/cxml-scripts/update +[delete]: /docs/sdks/reference/php/rest/fabric/cxml-scripts/delete +[listaddresses]: /docs/sdks/reference/php/rest/fabric/cxml-scripts/list-addresses + +Manage cXML script resources. Standard CRUD with PUT updates and address listing. + +Access via `client.fabric.cxml_scripts` on a [`RestClient`][restclient] instance. + +```php +fabric->cxml_scripts->list(); + + +``` + +## **Methods** + + + + List cXML script resources. + + + Create a new cXML script resource. + + + Retrieve a single cXML script resource. + + + Replace a cXML script resource. + + + Delete a cXML script resource. + + + List addresses for a cXML script resource. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/list-addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/list-addresses.mdx new file mode 100644 index 000000000..51d10aede --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/list-addresses.mdx @@ -0,0 +1,38 @@ +--- +title: "listAddresses" +slug: /reference/php/rest/fabric/cxml-scripts/list-addresses +description: List addresses associated with a cXML script resource. +max-toc-depth: 3 +--- + +List addresses associated with a cXML script resource. + +## **Parameters** + + + The unique identifier of the cXML script. + + +## **Returns** + +`dict` -- List of addresses assigned to this resource. + +## **Example** + +```php {9} +fabric->cxml_scripts->list_addresses("resource-id"); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/list.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/list.mdx new file mode 100644 index 000000000..e1b17b2aa --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/list.mdx @@ -0,0 +1,42 @@ +--- +title: "list" +slug: /reference/php/rest/fabric/cxml-scripts/list +description: List cXML script resources. +max-toc-depth: 3 +--- + +List cXML script resources in the project. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing cXML script resources. + +## **Example** + +```php {9} +fabric->cxml_scripts->list(); +foreach ($response["data"] ?? [] as $item) { + echo "{$item['name']}: {$item['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/update.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/update.mdx new file mode 100644 index 000000000..64e4bfa3d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-scripts/update.mdx @@ -0,0 +1,38 @@ +--- +title: "update" +slug: /reference/php/rest/fabric/cxml-scripts/update +description: Replace a cXML script resource. +max-toc-depth: 3 +--- + +Replace a cXML script resource. Uses PUT for full replacement. + +## **Parameters** + + + The unique identifier of the cXML script. + + +Additional keyword arguments are the full replacement body. + +## **Returns** + +`dict` -- The updated cXML script resource. + +## **Example** + +```php {9} +fabric->cxml_scripts->update("resource-id", name: "updated-name"); +echo "Updated: {$updated['name']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/create.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/create.mdx new file mode 100644 index 000000000..660617a28 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/create.mdx @@ -0,0 +1,40 @@ +--- +title: "create" +slug: /reference/php/rest/fabric/cxml-webhooks/create +description: Create a new cXML webhook resource. +max-toc-depth: 3 +--- + +Create a new cXML webhook resource. + +## **Parameters** + + + Display name of the cXML webhook. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created cXML webhook resource. + +## **Example** + +```php {9} +fabric->cxml_webhooks->create( + name: "my-webhook", +); +echo "Created: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/delete.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/delete.mdx new file mode 100644 index 000000000..df40de913 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/fabric/cxml-webhooks/delete +description: Delete a cXML webhook resource. +max-toc-depth: 3 +--- + +Delete a cXML webhook resource. + +## **Parameters** + + + The unique identifier of the cXML webhook to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->cxml_webhooks->delete("webhook-id"); +echo "Cxml Webhook deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/get.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/get.mdx new file mode 100644 index 000000000..80a2ed196 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/fabric/cxml-webhooks/get +description: Retrieve a single cXML webhook resource. +max-toc-depth: 3 +--- + +Retrieve a single cXML webhook resource. + +## **Parameters** + + + The unique identifier of the cXML webhook. + + +## **Returns** + +`dict` -- The cXML webhook resource. + +## **Example** + +```php {9} +fabric->cxml_webhooks->get("webhook-id"); +echo "Cxml Webhook: {$webhook['name']}, ID: {$webhook['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/index.mdx new file mode 100644 index 000000000..90333adeb --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/index.mdx @@ -0,0 +1,56 @@ +--- +title: "cXML Webhooks" +slug: /reference/php/rest/fabric/cxml-webhooks +description: Manage cXML webhook resources via the Fabric namespace. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/fabric/cxml-webhooks/list +[create]: /docs/sdks/reference/php/rest/fabric/cxml-webhooks/create +[get]: /docs/sdks/reference/php/rest/fabric/cxml-webhooks/get +[update]: /docs/sdks/reference/php/rest/fabric/cxml-webhooks/update +[delete]: /docs/sdks/reference/php/rest/fabric/cxml-webhooks/delete +[listaddresses]: /docs/sdks/reference/php/rest/fabric/cxml-webhooks/list-addresses + +Manage cXML webhook resources. Standard CRUD with PATCH updates and address listing. + +Access via `client.fabric.cxml_webhooks` on a [`RestClient`][restclient] instance. + +```php +fabric->cxml_webhooks->list(); + + +``` + +## **Methods** + + + + List cXML webhook resources. + + + Create a new cXML webhook resource. + + + Retrieve a single cXML webhook resource. + + + Partially update a cXML webhook resource. + + + Delete a cXML webhook resource. + + + List addresses for a cXML webhook resource. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/list-addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/list-addresses.mdx new file mode 100644 index 000000000..ccc297e74 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/list-addresses.mdx @@ -0,0 +1,38 @@ +--- +title: "listAddresses" +slug: /reference/php/rest/fabric/cxml-webhooks/list-addresses +description: List addresses associated with a cXML webhook resource. +max-toc-depth: 3 +--- + +List addresses associated with a cXML webhook resource. + +## **Parameters** + + + The unique identifier of the cXML webhook. + + +## **Returns** + +`dict` -- List of addresses assigned to this resource. + +## **Example** + +```php {9} +fabric->cxml_webhooks->list_addresses("webhook-id"); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/list.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/list.mdx new file mode 100644 index 000000000..fc344d362 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/list.mdx @@ -0,0 +1,42 @@ +--- +title: "list" +slug: /reference/php/rest/fabric/cxml-webhooks/list +description: List cXML webhook resources. +max-toc-depth: 3 +--- + +List cXML webhook resources in the project. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing cXML webhook resources. + +## **Example** + +```php {9} +fabric->cxml_webhooks->list(); +foreach ($response["data"] ?? [] as $webhook) { + echo "{$webhook['name']}: {$webhook['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/update.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/update.mdx new file mode 100644 index 000000000..ee66ec788 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/cxml-webhooks/update.mdx @@ -0,0 +1,38 @@ +--- +title: "update" +slug: /reference/php/rest/fabric/cxml-webhooks/update +description: Partially update a cXML webhook resource. +max-toc-depth: 3 +--- + +Partially update a cXML webhook resource. Uses PATCH for partial. + +## **Parameters** + + + The unique identifier of the cXML webhook. + + +Additional keyword arguments are the fields to update. + +## **Returns** + +`dict` -- The updated cXML webhook resource. + +## **Example** + +```php {9} +fabric->cxml_webhooks->update("webhook-id", name: "updated-name"); +echo "Updated: {$updated['name']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/dial-plans.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/dial-plans.mdx new file mode 100644 index 000000000..673708266 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/dial-plans.mdx @@ -0,0 +1,35 @@ +--- +title: "dialPlans" +slug: /reference/php/rest/fabric/dial-plans +description: Access the Dial Plans resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/fabric + +Access the Dial Plans resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +fabric(); + +$result = $fabric->dialPlans(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/freeclimb-apps.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/freeclimb-apps.mdx new file mode 100644 index 000000000..e52465db7 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/freeclimb-apps.mdx @@ -0,0 +1,35 @@ +--- +title: "freeclimbApps" +slug: /reference/php/rest/fabric/freeclimb-apps +description: Access the FreeClimb Apps resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/fabric + +Access the FreeClimb Apps resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +fabric(); + +$result = $fabric->freeclimbApps(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/create.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/create.mdx new file mode 100644 index 000000000..b0eedf510 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/create.mdx @@ -0,0 +1,40 @@ +--- +title: "create" +slug: /reference/php/rest/fabric/freeswitch-connectors/create +description: Create a new FreeSWITCH connector resource. +max-toc-depth: 3 +--- + +Create a new FreeSWITCH connector resource. + +## **Parameters** + + + Display name of the FreeSWITCH connector. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created FreeSWITCH connector resource. + +## **Example** + +```php {9} +fabric->freeswitch_connectors->create( + name: "my-connector", +); +echo "Created: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/delete.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/delete.mdx new file mode 100644 index 000000000..698a0956c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/fabric/freeswitch-connectors/delete +description: Delete a FreeSWITCH connector resource. +max-toc-depth: 3 +--- + +Delete a FreeSWITCH connector resource. + +## **Parameters** + + + The unique identifier of the FreeSWITCH connector to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->freeswitch_connectors->delete("connector-id"); +echo "Freeswitch Connector deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/get.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/get.mdx new file mode 100644 index 000000000..1f76233a3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/fabric/freeswitch-connectors/get +description: Retrieve a single FreeSWITCH connector resource. +max-toc-depth: 3 +--- + +Retrieve a single FreeSWITCH connector resource. + +## **Parameters** + + + The unique identifier of the FreeSWITCH connector. + + +## **Returns** + +`dict` -- The FreeSWITCH connector resource. + +## **Example** + +```php {9} +fabric->freeswitch_connectors->get("connector-id"); +echo "Freeswitch Connector: {$connector['name']}, ID: {$connector['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/index.mdx new file mode 100644 index 000000000..646441cdc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/index.mdx @@ -0,0 +1,56 @@ +--- +title: "FreeSWITCH Connectors" +slug: /reference/php/rest/fabric/freeswitch-connectors +description: Manage FreeSWITCH connector resources via the Fabric namespace. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/fabric/freeswitch-connectors/list +[create]: /docs/sdks/reference/php/rest/fabric/freeswitch-connectors/create +[get]: /docs/sdks/reference/php/rest/fabric/freeswitch-connectors/get +[update]: /docs/sdks/reference/php/rest/fabric/freeswitch-connectors/update +[delete]: /docs/sdks/reference/php/rest/fabric/freeswitch-connectors/delete +[listaddresses]: /docs/sdks/reference/php/rest/fabric/freeswitch-connectors/list-addresses + +Manage FreeSWITCH connector resources. Standard CRUD with PUT updates and address listing. + +Access via `client.fabric.freeswitch_connectors` on a [`RestClient`][restclient] instance. + +```php +fabric->freeswitch_connectors->list(); + + +``` + +## **Methods** + + + + List FreeSWITCH connector resources. + + + Create a new FreeSWITCH connector resource. + + + Retrieve a single FreeSWITCH connector resource. + + + Replace a FreeSWITCH connector resource. + + + Delete a FreeSWITCH connector resource. + + + List addresses for a FreeSWITCH connector resource. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/list-addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/list-addresses.mdx new file mode 100644 index 000000000..3834aa1af --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/list-addresses.mdx @@ -0,0 +1,38 @@ +--- +title: "listAddresses" +slug: /reference/php/rest/fabric/freeswitch-connectors/list-addresses +description: List addresses associated with a FreeSWITCH connector resource. +max-toc-depth: 3 +--- + +List addresses associated with a FreeSWITCH connector resource. + +## **Parameters** + + + The unique identifier of the FreeSWITCH connector. + + +## **Returns** + +`dict` -- List of addresses assigned to this resource. + +## **Example** + +```php {9} +fabric->freeswitch_connectors->list_addresses("connector-id"); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/list.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/list.mdx new file mode 100644 index 000000000..10e723dc6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/list.mdx @@ -0,0 +1,42 @@ +--- +title: "list" +slug: /reference/php/rest/fabric/freeswitch-connectors/list +description: List FreeSWITCH connector resources. +max-toc-depth: 3 +--- + +List FreeSWITCH connector resources in the project. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing FreeSWITCH connector resources. + +## **Example** + +```php {9} +fabric->freeswitch_connectors->list(); +foreach ($response["data"] ?? [] as $connector) { + echo "{$connector['name']}: {$connector['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/update.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/update.mdx new file mode 100644 index 000000000..ee646f964 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/freeswitch-connectors/update.mdx @@ -0,0 +1,38 @@ +--- +title: "update" +slug: /reference/php/rest/fabric/freeswitch-connectors/update +description: Replace a FreeSWITCH connector resource. +max-toc-depth: 3 +--- + +Replace a FreeSWITCH connector resource. Uses PUT for full replacement. + +## **Parameters** + + + The unique identifier of the FreeSWITCH connector. + + +Additional keyword arguments are the full replacement body. + +## **Returns** + +`dict` -- The updated FreeSWITCH connector resource. + +## **Example** + +```php {9} +fabric->freeswitch_connectors->update("connector-id", name: "updated-name"); +echo "Updated: {$updated['name']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/get-client.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/get-client.mdx new file mode 100644 index 000000000..812a36086 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/get-client.mdx @@ -0,0 +1,35 @@ +--- +title: "getClient" +slug: /reference/php/rest/fabric/get-client +description: Get the client of the Fabric namespace. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/fabric + +Get the client of the Fabric namespace. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`HttpClient` -- The underlying HTTP client. + +## **Example** + +```php +fabric(); + +$result = $fabric->getClient(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/index.mdx new file mode 100644 index 000000000..6fa4bc90d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/index.mdx @@ -0,0 +1,176 @@ +--- +title: "Fabric" +slug: /reference/php/rest/fabric +description: Manage AI agents, call flows, subscribers, conference rooms, tokens, and other Fabric resources. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[ai-agents]: /docs/sdks/reference/php/rest/fabric/ai-agents +[swml-scripts]: /docs/sdks/reference/php/rest/fabric/swml-scripts +[relay-applications]: /docs/sdks/reference/php/rest/fabric/relay-applications +[call-flows]: /docs/sdks/reference/php/rest/fabric/call-flows +[conference-rooms]: /docs/sdks/reference/php/rest/fabric/conference-rooms +[subscribers]: /docs/sdks/reference/php/rest/fabric/subscribers +[sip-endpoints]: /docs/sdks/reference/php/rest/fabric/sip-endpoints +[cxml-scripts]: /docs/sdks/reference/php/rest/fabric/cxml-scripts +[cxml-applications]: /docs/sdks/reference/php/rest/fabric/cxml-applications +[swml-webhooks]: /docs/sdks/reference/php/rest/fabric/swml-webhooks +[sip-gateways]: /docs/sdks/reference/php/rest/fabric/sip-gateways +[cxml-webhooks]: /docs/sdks/reference/php/rest/fabric/cxml-webhooks +[freeswitch-connectors]: /docs/sdks/reference/php/rest/fabric/freeswitch-connectors +[resources]: /docs/sdks/reference/php/rest/fabric/resources +[addresses]: /docs/sdks/reference/php/rest/fabric/addresses +[tokens]: /docs/sdks/reference/php/rest/fabric/tokens + +The `FabricNamespace` provides access to all SignalWire Fabric resources through the +[`RestClient`][restclient]. It organizes 16 sub-resources +for managing AI agents, SWML scripts, RELAY applications, call flows, conference rooms, +subscribers, SIP infrastructure, cXML resources, and authentication tokens. + +Access via `client.fabric` on a [`RestClient`][restclient] instance. + +```php +fabric->ai_agents->list(); +foreach ($agents["data"] ?? [] as $agent) { + echo "{$agent['name']}: {$agent['id']}"; +} + + +``` + + +Fabric resources use two update strategies. Resources like `ai_agents`, `swml_webhooks`, +`sip_gateways`, and `cxml_webhooks` use PATCH for partial updates. Resources like +`swml_scripts`, `relay_applications`, `call_flows`, `conference_rooms`, `subscribers`, +and others use PUT for full replacement updates. The SDK handles this automatically. + + + + + AI agent resources with PATCH updates and address listing. + + + SWML script resources with PUT updates and address listing. + + + RELAY application resources with PUT updates and address listing. + + + Call flow resources with versioning and deployment. + + + Conference room resources with PUT updates. + + + Subscriber resources with SIP endpoint management. + + + Top-level SIP endpoint resources. + + + cXML script resources with PUT updates. + + + cXML application resources (no create). + + + SWML webhook resources with PATCH updates. + + + SIP gateway resources with PATCH updates. + + + cXML webhook resources with PATCH updates. + + + FreeSWITCH connector resources with PUT updates. + + + Cross-type generic resource operations with routing. + + + Read-only fabric address lookup. + + + Subscriber, guest, invite, and embed token creation. + + + Access the Call Queues resource. + + + Access the Conversations resource. + + + Access the Dial Plans resource. + + + Access the FreeClimb Apps resource. + + + Get the REST client instance. + + + Access the Phone Numbers resource. + + + Access the SIP Profiles resource. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/phone-numbers.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/phone-numbers.mdx new file mode 100644 index 000000000..1219c6862 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/phone-numbers.mdx @@ -0,0 +1,35 @@ +--- +title: "phoneNumbers" +slug: /reference/php/rest/fabric/phone-numbers +description: Access the Phone Numbers resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/fabric + +Access the Phone Numbers resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +fabric(); + +$result = $fabric->phoneNumbers(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/create.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/create.mdx new file mode 100644 index 000000000..6aa5e8555 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/create.mdx @@ -0,0 +1,40 @@ +--- +title: "create" +slug: /reference/php/rest/fabric/relay-applications/create +description: Create a new RELAY application resource. +max-toc-depth: 3 +--- + +Create a new RELAY application resource. + +## **Parameters** + + + Display name of the RELAY application. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created RELAY application resource. + +## **Example** + +```php {9} +fabric->relay_applications->create( + name: "my-item", +); +echo "Created: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/delete.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/delete.mdx new file mode 100644 index 000000000..b8f514d09 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/fabric/relay-applications/delete +description: Delete a RELAY application resource. +max-toc-depth: 3 +--- + +Delete a RELAY application resource. + +## **Parameters** + + + The unique identifier of the RELAY application to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->relay_applications->delete("resource-id"); +echo "Relay Application deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/get.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/get.mdx new file mode 100644 index 000000000..e4f4fdf58 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/fabric/relay-applications/get +description: Retrieve a single RELAY application resource. +max-toc-depth: 3 +--- + +Retrieve a single RELAY application resource. + +## **Parameters** + + + The unique identifier of the RELAY application. + + +## **Returns** + +`dict` -- The RELAY application resource. + +## **Example** + +```php {9} +fabric->relay_applications->get("resource-id"); +echo "Relay Application: {$item['name']}, ID: {$item['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/index.mdx new file mode 100644 index 000000000..c84cbdc62 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/index.mdx @@ -0,0 +1,56 @@ +--- +title: "RELAY Applications" +slug: /reference/php/rest/fabric/relay-applications +description: Manage RELAY application resources via the Fabric namespace. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/fabric/relay-applications/list +[create]: /docs/sdks/reference/php/rest/fabric/relay-applications/create +[get]: /docs/sdks/reference/php/rest/fabric/relay-applications/get +[update]: /docs/sdks/reference/php/rest/fabric/relay-applications/update +[delete]: /docs/sdks/reference/php/rest/fabric/relay-applications/delete +[listaddresses]: /docs/sdks/reference/php/rest/fabric/relay-applications/list-addresses + +Manage RELAY application resources. Standard CRUD with PUT updates and address listing. + +Access via `client.fabric.relay_applications` on a [`RestClient`][restclient] instance. + +```php +fabric->relay_applications->list(); + + +``` + +## **Methods** + + + + List RELAY application resources. + + + Create a new RELAY application resource. + + + Retrieve a single RELAY application resource. + + + Replace a RELAY application resource. + + + Delete a RELAY application resource. + + + List addresses for a RELAY application resource. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/list-addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/list-addresses.mdx new file mode 100644 index 000000000..33df19b85 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/list-addresses.mdx @@ -0,0 +1,38 @@ +--- +title: "listAddresses" +slug: /reference/php/rest/fabric/relay-applications/list-addresses +description: List addresses associated with a RELAY application resource. +max-toc-depth: 3 +--- + +List addresses associated with a RELAY application resource. + +## **Parameters** + + + The unique identifier of the RELAY application. + + +## **Returns** + +`dict` -- List of addresses assigned to this resource. + +## **Example** + +```php {9} +fabric->relay_applications->list_addresses("resource-id"); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/list.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/list.mdx new file mode 100644 index 000000000..76297e912 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/list.mdx @@ -0,0 +1,42 @@ +--- +title: "list" +slug: /reference/php/rest/fabric/relay-applications/list +description: List RELAY application resources. +max-toc-depth: 3 +--- + +List RELAY application resources in the project. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing RELAY application resources. + +## **Example** + +```php {9} +fabric->relay_applications->list(); +foreach ($response["data"] ?? [] as $item) { + echo "{$item['name']}: {$item['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/update.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/update.mdx new file mode 100644 index 000000000..a733202fc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/relay-applications/update.mdx @@ -0,0 +1,38 @@ +--- +title: "update" +slug: /reference/php/rest/fabric/relay-applications/update +description: Replace a RELAY application resource. +max-toc-depth: 3 +--- + +Replace a RELAY application resource. Uses PUT for full replacement. + +## **Parameters** + + + The unique identifier of the RELAY application. + + +Additional keyword arguments are the full replacement body. + +## **Returns** + +`dict` -- The updated RELAY application resource. + +## **Example** + +```php {9} +fabric->relay_applications->update("resource-id", name: "updated-name"); +echo "Updated: {$updated['name']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/resources/assign-domain-application.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/resources/assign-domain-application.mdx new file mode 100644 index 000000000..418485104 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/resources/assign-domain-application.mdx @@ -0,0 +1,40 @@ +--- +title: "assignDomainApplication" +slug: /reference/php/rest/fabric/resources/assign-domain-application +description: Assign a domain application to a Fabric resource. +max-toc-depth: 3 +--- + +Assign a domain application to a Fabric resource. + +## **Parameters** + + + The unique identifier of the resource. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The assigned domain application. + +## **Example** + +```php {9} +fabric->resources->assign_domain_application( + "resource-id", domain: "example.signalwire.com", +); +echo "Domain application assigned: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/resources/assign-phone-route.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/resources/assign-phone-route.mdx new file mode 100644 index 000000000..bd056ea82 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/resources/assign-phone-route.mdx @@ -0,0 +1,40 @@ +--- +title: "assignPhoneRoute" +slug: /reference/php/rest/fabric/resources/assign-phone-route +description: Assign a phone route to a Fabric resource. +max-toc-depth: 3 +--- + +Assign a phone route to a Fabric resource. + +## **Parameters** + + + The unique identifier of the resource. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The assigned phone route. + +## **Example** + +```php {9} +fabric->resources->assign_phone_route( + "resource-id", phone_number: "+15551234567", +); +echo "Phone route assigned: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/resources/delete.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/resources/delete.mdx new file mode 100644 index 000000000..28e365f1d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/resources/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/fabric/resources/delete +description: Delete a Fabric resource. +max-toc-depth: 3 +--- + +Delete a Fabric resource. + +## **Parameters** + + + The unique identifier of the resource to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->resources->delete("resource-id"); +echo "Resource deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/resources/get.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/resources/get.mdx new file mode 100644 index 000000000..12c31623c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/resources/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/fabric/resources/get +description: Retrieve a single Fabric resource. +max-toc-depth: 3 +--- + +Retrieve a single Fabric resource by ID. + +## **Parameters** + + + The unique identifier of the resource. + + +## **Returns** + +`dict` -- The Fabric resource. + +## **Example** + +```php {9} +fabric->resources->get("resource-id"); +echo "{$resource['type']}: {$resource['name']}, ID: {$resource['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/resources/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/resources/index.mdx new file mode 100644 index 000000000..f7ae3238c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/resources/index.mdx @@ -0,0 +1,58 @@ +--- +title: "Resources" +slug: /reference/php/rest/fabric/resources +description: Generic resource operations across all Fabric resource types. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/fabric/resources/list +[get]: /docs/sdks/reference/php/rest/fabric/resources/get +[delete]: /docs/sdks/reference/php/rest/fabric/resources/delete +[listaddresses]: /docs/sdks/reference/php/rest/fabric/resources/list-addresses +[assignphoneroute]: /docs/sdks/reference/php/rest/fabric/resources/assign-phone-route +[assigndomainapplication]: /docs/sdks/reference/php/rest/fabric/resources/assign-domain-application + +Generic resource operations that work across all Fabric resource types. Provides +read-only access (list, get, delete) plus address listing and route assignment. +Does not support create or update methods. + +Access via `client.fabric.resources` on a [`RestClient`][restclient] instance. + +```php +fabric->resources->list(); + + +``` + +## **Methods** + + + + List all Fabric resources. + + + Retrieve a single resource. + + + Delete a resource. + + + List addresses for a resource. + + + Assign a phone route to a resource. + + + Assign a domain application to a resource. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/resources/list-addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/resources/list-addresses.mdx new file mode 100644 index 000000000..0a27a3c29 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/resources/list-addresses.mdx @@ -0,0 +1,38 @@ +--- +title: "listAddresses" +slug: /reference/php/rest/fabric/resources/list-addresses +description: List addresses associated with a Fabric resource. +max-toc-depth: 3 +--- + +List addresses associated with a Fabric resource. + +## **Parameters** + + + The unique identifier of the resource. + + +## **Returns** + +`dict` -- List of addresses assigned to this resource. + +## **Example** + +```php {9} +fabric->resources->list_addresses("resource-id"); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/resources/list.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/resources/list.mdx new file mode 100644 index 000000000..2e27a14b1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/resources/list.mdx @@ -0,0 +1,42 @@ +--- +title: "list" +slug: /reference/php/rest/fabric/resources/list +description: List all Fabric resources. +max-toc-depth: 3 +--- + +List all Fabric resources across all resource types. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing Fabric resources. + +## **Example** + +```php {9} +fabric->resources->list(); +foreach ($response["data"] ?? [] as $resource) { + echo "{$resource['type']}: {$resource['name']} ({$resource['id']})"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints.mdx new file mode 100644 index 000000000..3be23bb25 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints.mdx @@ -0,0 +1,35 @@ +--- +title: "sipEndpoints" +slug: /reference/php/rest/fabric/sip-endpoints +description: Access the SIP Endpoints resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/fabric + +Access the SIP Endpoints resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +fabric(); + +$result = $fabric->sipEndpoints(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/create.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/create.mdx new file mode 100644 index 000000000..47cce79b2 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/create.mdx @@ -0,0 +1,40 @@ +--- +title: "create" +slug: /reference/php/rest/fabric/sip-endpoints/create +description: Create a new SIP endpoint resource. +max-toc-depth: 3 +--- + +Create a new SIP endpoint resource. + +## **Parameters** + + + Display name of the SIP endpoint. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created SIP endpoint resource. + +## **Example** + +```php {9} +fabric->sip_endpoints->create( + name: "my-endpoint", +); +echo "Created: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/delete.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/delete.mdx new file mode 100644 index 000000000..bd6d5e37d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/fabric/sip-endpoints/delete +description: Delete a SIP endpoint resource. +max-toc-depth: 3 +--- + +Delete a SIP endpoint resource. + +## **Parameters** + + + The unique identifier of the SIP endpoint to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->sip_endpoints->delete("endpoint-id"); +echo "Sip Endpoint deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/get.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/get.mdx new file mode 100644 index 000000000..0ee2f9217 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/fabric/sip-endpoints/get +description: Retrieve a single SIP endpoint resource. +max-toc-depth: 3 +--- + +Retrieve a single SIP endpoint resource. + +## **Parameters** + + + The unique identifier of the SIP endpoint. + + +## **Returns** + +`dict` -- The SIP endpoint resource. + +## **Example** + +```php {9} +fabric->sip_endpoints->get("endpoint-id"); +echo "Sip Endpoint: {$endpoint['name']}, ID: {$endpoint['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/index.mdx new file mode 100644 index 000000000..4cc2d504a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/index.mdx @@ -0,0 +1,63 @@ +--- +title: "SIP Endpoints" +slug: /reference/php/rest/fabric/sip-endpoints +description: Manage SIP endpoint resources via the Fabric namespace. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[client-fabric-subscribers-list-sip-endpoints]: /docs/sdks/reference/php/rest/fabric/subscribers/list-sip-endpoints +[list]: /docs/sdks/reference/php/rest/fabric/sip-endpoints/list +[create]: /docs/sdks/reference/php/rest/fabric/sip-endpoints/create +[get]: /docs/sdks/reference/php/rest/fabric/sip-endpoints/get +[update]: /docs/sdks/reference/php/rest/fabric/sip-endpoints/update +[delete]: /docs/sdks/reference/php/rest/fabric/sip-endpoints/delete +[listaddresses]: /docs/sdks/reference/php/rest/fabric/sip-endpoints/list-addresses + +Manage SIP endpoint resources. Standard CRUD with PUT updates and address listing. + +Access via `client.fabric.sip_endpoints` on a [`RestClient`][restclient] instance. + + +This is the top-level SIP endpoint resource. For managing SIP endpoints belonging to a +specific subscriber, use [`client.fabric.subscribers.list_sip_endpoints()`][client-fabric-subscribers-list-sip-endpoints] +and related methods instead. + + +```php +fabric->sip_endpoints->list(); + + +``` + +## **Methods** + + + + List SIP endpoint resources. + + + Create a new SIP endpoint resource. + + + Retrieve a single SIP endpoint resource. + + + Replace a SIP endpoint resource. + + + Delete a SIP endpoint resource. + + + List addresses for a SIP endpoint resource. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/list-addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/list-addresses.mdx new file mode 100644 index 000000000..ddeaf1063 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/list-addresses.mdx @@ -0,0 +1,38 @@ +--- +title: "listAddresses" +slug: /reference/php/rest/fabric/sip-endpoints/list-addresses +description: List addresses associated with a SIP endpoint resource. +max-toc-depth: 3 +--- + +List addresses associated with a SIP endpoint resource. + +## **Parameters** + + + The unique identifier of the SIP endpoint. + + +## **Returns** + +`dict` -- List of addresses assigned to this resource. + +## **Example** + +```php {9} +fabric->sip_endpoints->list_addresses("endpoint-id"); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/list.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/list.mdx new file mode 100644 index 000000000..c6b5be0c8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/list.mdx @@ -0,0 +1,42 @@ +--- +title: "list" +slug: /reference/php/rest/fabric/sip-endpoints/list +description: List SIP endpoint resources. +max-toc-depth: 3 +--- + +List SIP endpoint resources in the project. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing SIP endpoint resources. + +## **Example** + +```php {9} +fabric->sip_endpoints->list(); +foreach ($response["data"] ?? [] as $endpoint) { + echo "{$endpoint['name']}: {$endpoint['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/update.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/update.mdx new file mode 100644 index 000000000..3c26de9a4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-endpoints/update.mdx @@ -0,0 +1,38 @@ +--- +title: "update" +slug: /reference/php/rest/fabric/sip-endpoints/update +description: Replace a SIP endpoint resource. +max-toc-depth: 3 +--- + +Replace a SIP endpoint resource. Uses PUT for full replacement. + +## **Parameters** + + + The unique identifier of the SIP endpoint. + + +Additional keyword arguments are the full replacement body. + +## **Returns** + +`dict` -- The updated SIP endpoint resource. + +## **Example** + +```php {9} +fabric->sip_endpoints->update("endpoint-id", name: "updated-name"); +echo "Updated: {$updated['name']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/create.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/create.mdx new file mode 100644 index 000000000..a63357c3f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/create.mdx @@ -0,0 +1,40 @@ +--- +title: "create" +slug: /reference/php/rest/fabric/sip-gateways/create +description: Create a new SIP gateway resource. +max-toc-depth: 3 +--- + +Create a new SIP gateway resource. + +## **Parameters** + + + Display name of the SIP gateway. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created SIP gateway resource. + +## **Example** + +```php {9} +fabric->sip_gateways->create( + name: "my-gateway", +); +echo "Created: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/delete.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/delete.mdx new file mode 100644 index 000000000..0d865d07b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/fabric/sip-gateways/delete +description: Delete a SIP gateway resource. +max-toc-depth: 3 +--- + +Delete a SIP gateway resource. + +## **Parameters** + + + The unique identifier of the SIP gateway to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->sip_gateways->delete("gateway-id"); +echo "Sip Gateway deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/get.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/get.mdx new file mode 100644 index 000000000..316a94992 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/fabric/sip-gateways/get +description: Retrieve a single SIP gateway resource. +max-toc-depth: 3 +--- + +Retrieve a single SIP gateway resource. + +## **Parameters** + + + The unique identifier of the SIP gateway. + + +## **Returns** + +`dict` -- The SIP gateway resource. + +## **Example** + +```php {9} +fabric->sip_gateways->get("gateway-id"); +echo "Sip Gateway: {$gateway['name']}, ID: {$gateway['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/index.mdx new file mode 100644 index 000000000..6330ff569 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/index.mdx @@ -0,0 +1,56 @@ +--- +title: "SIP Gateways" +slug: /reference/php/rest/fabric/sip-gateways +description: Manage SIP gateway resources via the Fabric namespace. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/fabric/sip-gateways/list +[create]: /docs/sdks/reference/php/rest/fabric/sip-gateways/create +[get]: /docs/sdks/reference/php/rest/fabric/sip-gateways/get +[update]: /docs/sdks/reference/php/rest/fabric/sip-gateways/update +[delete]: /docs/sdks/reference/php/rest/fabric/sip-gateways/delete +[listaddresses]: /docs/sdks/reference/php/rest/fabric/sip-gateways/list-addresses + +Manage SIP gateway resources. Standard CRUD with PATCH updates and address listing. + +Access via `client.fabric.sip_gateways` on a [`RestClient`][restclient] instance. + +```php +fabric->sip_gateways->list(); + + +``` + +## **Methods** + + + + List SIP gateway resources. + + + Create a new SIP gateway resource. + + + Retrieve a single SIP gateway resource. + + + Partially update a SIP gateway resource. + + + Delete a SIP gateway resource. + + + List addresses for a SIP gateway resource. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/list-addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/list-addresses.mdx new file mode 100644 index 000000000..13c8c4bc1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/list-addresses.mdx @@ -0,0 +1,38 @@ +--- +title: "listAddresses" +slug: /reference/php/rest/fabric/sip-gateways/list-addresses +description: List addresses associated with a SIP gateway resource. +max-toc-depth: 3 +--- + +List addresses associated with a SIP gateway resource. + +## **Parameters** + + + The unique identifier of the SIP gateway. + + +## **Returns** + +`dict` -- List of addresses assigned to this resource. + +## **Example** + +```php {9} +fabric->sip_gateways->list_addresses("gateway-id"); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/list.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/list.mdx new file mode 100644 index 000000000..6a69a5341 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/list.mdx @@ -0,0 +1,42 @@ +--- +title: "list" +slug: /reference/php/rest/fabric/sip-gateways/list +description: List SIP gateway resources. +max-toc-depth: 3 +--- + +List SIP gateway resources in the project. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing SIP gateway resources. + +## **Example** + +```php {9} +fabric->sip_gateways->list(); +foreach ($response["data"] ?? [] as $gateway) { + echo "{$gateway['name']}: {$gateway['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/update.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/update.mdx new file mode 100644 index 000000000..ff7a0d527 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-gateways/update.mdx @@ -0,0 +1,38 @@ +--- +title: "update" +slug: /reference/php/rest/fabric/sip-gateways/update +description: Partially update a SIP gateway resource. +max-toc-depth: 3 +--- + +Partially update a SIP gateway resource. Uses PATCH for partial. + +## **Parameters** + + + The unique identifier of the SIP gateway. + + +Additional keyword arguments are the fields to update. + +## **Returns** + +`dict` -- The updated SIP gateway resource. + +## **Example** + +```php {9} +fabric->sip_gateways->update("gateway-id", name: "updated-name"); +echo "Updated: {$updated['name']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/sip-profiles.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/sip-profiles.mdx new file mode 100644 index 000000000..07eafc1e5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/sip-profiles.mdx @@ -0,0 +1,35 @@ +--- +title: "sipProfiles" +slug: /reference/php/rest/fabric/sip-profiles +description: Access the SIP Profiles resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/fabric + +Access the SIP Profiles resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +fabric(); + +$result = $fabric->sipProfiles(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/subscribers.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers.mdx new file mode 100644 index 000000000..ddb8b6fd4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers.mdx @@ -0,0 +1,35 @@ +--- +title: "subscribers" +slug: /reference/php/rest/fabric/subscribers +description: Access the Subscribers resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/fabric + +Access the Subscribers resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +fabric(); + +$result = $fabric->subscribers(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/create-sip-endpoint.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/create-sip-endpoint.mdx new file mode 100644 index 000000000..7036eb51c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/create-sip-endpoint.mdx @@ -0,0 +1,40 @@ +--- +title: "createSipEndpoint" +slug: /reference/php/rest/fabric/subscribers/create-sip-endpoint +description: Create a SIP endpoint for a subscriber. +max-toc-depth: 3 +--- + +Create a new SIP endpoint for a subscriber. + +## **Parameters** + + + The unique identifier of the subscriber. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created SIP endpoint. + +## **Example** + +```php {9} +fabric->subscribers->create_sip_endpoint( + "subscriber-id", username: "alice-sip", password: "s3cret", +); +echo "Created SIP endpoint: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/create.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/create.mdx new file mode 100644 index 000000000..85fe5ab50 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/create.mdx @@ -0,0 +1,40 @@ +--- +title: "create" +slug: /reference/php/rest/fabric/subscribers/create +description: Create a new subscriber resource. +max-toc-depth: 3 +--- + +Create a new subscriber resource. + +## **Parameters** + + + Display name of the subscriber. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created subscriber resource. + +## **Example** + +```php {9} +fabric->subscribers->create( + name: "alice", type: "subscriber", +); +echo "Created: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/delete-sip-endpoint.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/delete-sip-endpoint.mdx new file mode 100644 index 000000000..4beed7677 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/delete-sip-endpoint.mdx @@ -0,0 +1,40 @@ +--- +title: "deleteSipEndpoint" +slug: /reference/php/rest/fabric/subscribers/delete-sip-endpoint +description: Delete a SIP endpoint for a subscriber. +max-toc-depth: 3 +--- + +Delete a SIP endpoint for a subscriber. + +## **Parameters** + + + The unique identifier of the subscriber. + + + + The unique identifier of the SIP endpoint to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->subscribers->delete_sip_endpoint("subscriber-id", "endpoint-id"); +echo "SIP endpoint deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/delete.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/delete.mdx new file mode 100644 index 000000000..0e83a28ae --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/fabric/subscribers/delete +description: Delete a subscriber resource. +max-toc-depth: 3 +--- + +Delete a subscriber resource. + +## **Parameters** + + + The unique identifier of the subscriber to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->subscribers->delete("subscriber-id"); +echo "Subscriber deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/get-sip-endpoint.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/get-sip-endpoint.mdx new file mode 100644 index 000000000..a2f37a760 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/get-sip-endpoint.mdx @@ -0,0 +1,40 @@ +--- +title: "getSipEndpoint" +slug: /reference/php/rest/fabric/subscribers/get-sip-endpoint +description: Retrieve a SIP endpoint for a subscriber. +max-toc-depth: 3 +--- + +Retrieve a single SIP endpoint for a subscriber. + +## **Parameters** + + + The unique identifier of the subscriber. + + + + The unique identifier of the SIP endpoint. + + +## **Returns** + +`dict` -- The SIP endpoint. + +## **Example** + +```php {9} +fabric->subscribers->get_sip_endpoint("subscriber-id", "endpoint-id"); +echo "SIP Endpoint: {$endpoint['username']}, ID: {$endpoint['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/get.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/get.mdx new file mode 100644 index 000000000..dea2721bf --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/fabric/subscribers/get +description: Retrieve a single subscriber resource. +max-toc-depth: 3 +--- + +Retrieve a single subscriber resource. + +## **Parameters** + + + The unique identifier of the subscriber. + + +## **Returns** + +`dict` -- The subscriber resource. + +## **Example** + +```php {9} +fabric->subscribers->get("subscriber-id"); +echo "Subscriber: {$subscriber['name']}, ID: {$subscriber['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/index.mdx new file mode 100644 index 000000000..838cd7d60 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/index.mdx @@ -0,0 +1,77 @@ +--- +title: "Subscribers" +slug: /reference/php/rest/fabric/subscribers +description: Manage subscriber resources with SIP endpoint support. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/fabric/subscribers/list +[create]: /docs/sdks/reference/php/rest/fabric/subscribers/create +[get]: /docs/sdks/reference/php/rest/fabric/subscribers/get +[update]: /docs/sdks/reference/php/rest/fabric/subscribers/update +[delete]: /docs/sdks/reference/php/rest/fabric/subscribers/delete +[listaddresses]: /docs/sdks/reference/php/rest/fabric/subscribers/list-addresses +[listsipendpoints]: /docs/sdks/reference/php/rest/fabric/subscribers/list-sip-endpoints +[createsipendpoint]: /docs/sdks/reference/php/rest/fabric/subscribers/create-sip-endpoint +[getsipendpoint]: /docs/sdks/reference/php/rest/fabric/subscribers/get-sip-endpoint +[updatesipendpoint]: /docs/sdks/reference/php/rest/fabric/subscribers/update-sip-endpoint +[deletesipendpoint]: /docs/sdks/reference/php/rest/fabric/subscribers/delete-sip-endpoint + +Manage subscriber resources. Extends standard CRUD (PUT updates) with address listing +and SIP endpoint management. + +Access via `client.fabric.subscribers` on a [`RestClient`][restclient] instance. + +```php +fabric->subscribers->list(); + + +``` + +## **Methods** + + + + List subscriber resources. + + + Create a new subscriber resource. + + + Retrieve a single subscriber resource. + + + Replace a subscriber resource. + + + Delete a subscriber resource. + + + List addresses for a subscriber resource. + + + List SIP endpoints for a subscriber. + + + Create a SIP endpoint for a subscriber. + + + Retrieve a SIP endpoint for a subscriber. + + + Partially update a SIP endpoint. + + + Delete a SIP endpoint for a subscriber. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/list-addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/list-addresses.mdx new file mode 100644 index 000000000..766e1104b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/list-addresses.mdx @@ -0,0 +1,38 @@ +--- +title: "listAddresses" +slug: /reference/php/rest/fabric/subscribers/list-addresses +description: List addresses associated with a subscriber resource. +max-toc-depth: 3 +--- + +List addresses associated with a subscriber resource. + +## **Parameters** + + + The unique identifier of the subscriber. + + +## **Returns** + +`dict` -- List of addresses assigned to this resource. + +## **Example** + +```php {9} +fabric->subscribers->list_addresses("subscriber-id"); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/list-sip-endpoints.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/list-sip-endpoints.mdx new file mode 100644 index 000000000..44f425349 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/list-sip-endpoints.mdx @@ -0,0 +1,46 @@ +--- +title: "listSipEndpoints" +slug: /reference/php/rest/fabric/subscribers/list-sip-endpoints +description: List SIP endpoints for a subscriber. +max-toc-depth: 3 +--- + +List SIP endpoints associated with a subscriber. + +## **Parameters** + + + The unique identifier of the subscriber. + + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing SIP endpoints for the subscriber. + +## **Example** + +```php {9} +fabric->subscribers->list_sip_endpoints("subscriber-id"); +foreach ($response["data"] ?? [] as $ep) { + echo "{$ep['username']}: {$ep['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/list.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/list.mdx new file mode 100644 index 000000000..6a12005c5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/list.mdx @@ -0,0 +1,42 @@ +--- +title: "list" +slug: /reference/php/rest/fabric/subscribers/list +description: List subscriber resources. +max-toc-depth: 3 +--- + +List subscriber resources in the project. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing subscriber resources. + +## **Example** + +```php {9} +fabric->subscribers->list(); +foreach ($response["data"] ?? [] as $subscriber) { + echo "{$subscriber['name']}: {$subscriber['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/update-sip-endpoint.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/update-sip-endpoint.mdx new file mode 100644 index 000000000..cab6d478f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/update-sip-endpoint.mdx @@ -0,0 +1,44 @@ +--- +title: "updateSipEndpoint" +slug: /reference/php/rest/fabric/subscribers/update-sip-endpoint +description: Partially update a SIP endpoint for a subscriber. +max-toc-depth: 3 +--- + +Partially update a SIP endpoint for a subscriber. Uses PATCH, so only provided fields are changed. + +## **Parameters** + + + The unique identifier of the subscriber. + + + + The unique identifier of the SIP endpoint. + + +Additional keyword arguments are the fields to update. + +## **Returns** + +`dict` -- The updated SIP endpoint. + +## **Example** + +```php {9} +fabric->subscribers->update_sip_endpoint( + "subscriber-id", "endpoint-id", username: "new-username", +); +echo "Updated: {$updated['username']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/update.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/update.mdx new file mode 100644 index 000000000..e9e05fe29 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/subscribers/update.mdx @@ -0,0 +1,38 @@ +--- +title: "update" +slug: /reference/php/rest/fabric/subscribers/update +description: Replace a subscriber resource. +max-toc-depth: 3 +--- + +Replace a subscriber resource. Uses PUT, so the full resource body must be provided. + +## **Parameters** + + + The unique identifier of the subscriber. + + +Additional keyword arguments are the fields for the replacement resource body. + +## **Returns** + +`dict` -- The updated subscriber resource. + +## **Example** + +```php {9} +fabric->subscribers->update("subscriber-id", name: "bob"); +echo "Updated: {$updated['name']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts.mdx new file mode 100644 index 000000000..ac2ab421a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts.mdx @@ -0,0 +1,35 @@ +--- +title: "swmlScripts" +slug: /reference/php/rest/fabric/swml-scripts +description: Access the SWML Scripts resource. +max-toc-depth: 3 +--- + +[ref-class]: /docs/sdks/reference/php/rest/fabric + +Access the SWML Scripts resource. + +## **Parameters** + +This method takes no parameters. + +## **Returns** + +`CrudResource` -- A CRUD resource instance for performing operations. + +## **Example** + +```php +fabric(); + +$result = $fabric->swmlScripts(); +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/create.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/create.mdx new file mode 100644 index 000000000..da4edfcdd --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/create.mdx @@ -0,0 +1,40 @@ +--- +title: "create" +slug: /reference/php/rest/fabric/swml-scripts/create +description: Create a new SWML script resource. +max-toc-depth: 3 +--- + +Create a new SWML script resource. + +## **Parameters** + + + Display name of the SWML script. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created SWML script resource. + +## **Example** + +```php {9} +fabric->swml_scripts->create( + name: "my-item", +); +echo "Created: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/delete.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/delete.mdx new file mode 100644 index 000000000..03c5247e0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/fabric/swml-scripts/delete +description: Delete a SWML script resource. +max-toc-depth: 3 +--- + +Delete a SWML script resource. + +## **Parameters** + + + The unique identifier of the SWML script to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->swml_scripts->delete("resource-id"); +echo "Swml Script deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/get.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/get.mdx new file mode 100644 index 000000000..7cbd88b7b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/fabric/swml-scripts/get +description: Retrieve a single SWML script resource. +max-toc-depth: 3 +--- + +Retrieve a single SWML script resource. + +## **Parameters** + + + The unique identifier of the SWML script. + + +## **Returns** + +`dict` -- The SWML script resource. + +## **Example** + +```php {9} +fabric->swml_scripts->get("resource-id"); +echo "Swml Script: {$item['name']}, ID: {$item['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/index.mdx new file mode 100644 index 000000000..dd65d2f10 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/index.mdx @@ -0,0 +1,56 @@ +--- +title: "SWML Scripts" +slug: /reference/php/rest/fabric/swml-scripts +description: Manage SWML script resources via the Fabric namespace. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/fabric/swml-scripts/list +[create]: /docs/sdks/reference/php/rest/fabric/swml-scripts/create +[get]: /docs/sdks/reference/php/rest/fabric/swml-scripts/get +[update]: /docs/sdks/reference/php/rest/fabric/swml-scripts/update +[delete]: /docs/sdks/reference/php/rest/fabric/swml-scripts/delete +[listaddresses]: /docs/sdks/reference/php/rest/fabric/swml-scripts/list-addresses + +Manage SWML script resources. Standard CRUD with PUT updates and address listing. + +Access via `client.fabric.swml_scripts` on a [`RestClient`][restclient] instance. + +```php +fabric->swml_scripts->list(); + + +``` + +## **Methods** + + + + List SWML script resources. + + + Create a new SWML script resource. + + + Retrieve a single SWML script resource. + + + Replace a SWML script resource. + + + Delete a SWML script resource. + + + List addresses for a SWML script resource. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/list-addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/list-addresses.mdx new file mode 100644 index 000000000..4e4e86a6e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/list-addresses.mdx @@ -0,0 +1,38 @@ +--- +title: "listAddresses" +slug: /reference/php/rest/fabric/swml-scripts/list-addresses +description: List addresses associated with a SWML script resource. +max-toc-depth: 3 +--- + +List addresses associated with a SWML script resource. + +## **Parameters** + + + The unique identifier of the SWML script. + + +## **Returns** + +`dict` -- List of addresses assigned to this resource. + +## **Example** + +```php {9} +fabric->swml_scripts->list_addresses("resource-id"); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/list.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/list.mdx new file mode 100644 index 000000000..62d322b72 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/list.mdx @@ -0,0 +1,42 @@ +--- +title: "list" +slug: /reference/php/rest/fabric/swml-scripts/list +description: List SWML script resources. +max-toc-depth: 3 +--- + +List SWML script resources in the project. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing SWML script resources. + +## **Example** + +```php {9} +fabric->swml_scripts->list(); +foreach ($response["data"] ?? [] as $item) { + echo "{$item['name']}: {$item['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/update.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/update.mdx new file mode 100644 index 000000000..c3c6367ff --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-scripts/update.mdx @@ -0,0 +1,38 @@ +--- +title: "update" +slug: /reference/php/rest/fabric/swml-scripts/update +description: Replace a SWML script resource. +max-toc-depth: 3 +--- + +Replace a SWML script resource. Uses PUT for full replacement. + +## **Parameters** + + + The unique identifier of the SWML script. + + +Additional keyword arguments are the full replacement body. + +## **Returns** + +`dict` -- The updated SWML script resource. + +## **Example** + +```php {9} +fabric->swml_scripts->update("resource-id", name: "updated-name"); +echo "Updated: {$updated['name']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/create.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/create.mdx new file mode 100644 index 000000000..233cc9f4c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/create.mdx @@ -0,0 +1,40 @@ +--- +title: "create" +slug: /reference/php/rest/fabric/swml-webhooks/create +description: Create a new SWML webhook resource. +max-toc-depth: 3 +--- + +Create a new SWML webhook resource. + +## **Parameters** + + + Display name of the SWML webhook. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created SWML webhook resource. + +## **Example** + +```php {9} +fabric->swml_webhooks->create( + name: "my-webhook", +); +echo "Created: {$result['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/delete.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/delete.mdx new file mode 100644 index 000000000..c6ce2d952 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/fabric/swml-webhooks/delete +description: Delete a SWML webhook resource. +max-toc-depth: 3 +--- + +Delete a SWML webhook resource. + +## **Parameters** + + + The unique identifier of the SWML webhook to delete. + + +## **Returns** + +`dict` -- Empty dict on success (HTTP 204). + +## **Example** + +```php {9} +fabric->swml_webhooks->delete("webhook-id"); +echo "Swml Webhook deleted"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/get.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/get.mdx new file mode 100644 index 000000000..adc3b4012 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/fabric/swml-webhooks/get +description: Retrieve a single SWML webhook resource. +max-toc-depth: 3 +--- + +Retrieve a single SWML webhook resource. + +## **Parameters** + + + The unique identifier of the SWML webhook. + + +## **Returns** + +`dict` -- The SWML webhook resource. + +## **Example** + +```php {9} +fabric->swml_webhooks->get("webhook-id"); +echo "Swml Webhook: {$webhook['name']}, ID: {$webhook['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/index.mdx new file mode 100644 index 000000000..07177f47f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/index.mdx @@ -0,0 +1,56 @@ +--- +title: "SWML Webhooks" +slug: /reference/php/rest/fabric/swml-webhooks +description: Manage SWML webhook resources via the Fabric namespace. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/fabric/swml-webhooks/list +[create]: /docs/sdks/reference/php/rest/fabric/swml-webhooks/create +[get]: /docs/sdks/reference/php/rest/fabric/swml-webhooks/get +[update]: /docs/sdks/reference/php/rest/fabric/swml-webhooks/update +[delete]: /docs/sdks/reference/php/rest/fabric/swml-webhooks/delete +[listaddresses]: /docs/sdks/reference/php/rest/fabric/swml-webhooks/list-addresses + +Manage SWML webhook resources. Standard CRUD with PATCH updates and address listing. + +Access via `client.fabric.swml_webhooks` on a [`RestClient`][restclient] instance. + +```php +fabric->swml_webhooks->list(); + + +``` + +## **Methods** + + + + List SWML webhook resources. + + + Create a new SWML webhook resource. + + + Retrieve a single SWML webhook resource. + + + Partially update a SWML webhook resource. + + + Delete a SWML webhook resource. + + + List addresses for a SWML webhook resource. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/list-addresses.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/list-addresses.mdx new file mode 100644 index 000000000..f52d75fff --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/list-addresses.mdx @@ -0,0 +1,38 @@ +--- +title: "listAddresses" +slug: /reference/php/rest/fabric/swml-webhooks/list-addresses +description: List addresses associated with a SWML webhook resource. +max-toc-depth: 3 +--- + +List addresses associated with a SWML webhook resource. + +## **Parameters** + + + The unique identifier of the SWML webhook. + + +## **Returns** + +`dict` -- List of addresses assigned to this resource. + +## **Example** + +```php {9} +fabric->swml_webhooks->list_addresses("webhook-id"); +foreach ($addresses["data"] ?? [] as $addr) { + echo "{$addr['display_name']}: {$addr['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/list.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/list.mdx new file mode 100644 index 000000000..a048b2a8a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/list.mdx @@ -0,0 +1,42 @@ +--- +title: "list" +slug: /reference/php/rest/fabric/swml-webhooks/list +description: List SWML webhook resources. +max-toc-depth: 3 +--- + +List SWML webhook resources in the project. + +## **Parameters** + + + Number of results per page. + + + + Pagination token for the next page of results. + + +## **Returns** + +`dict` -- Paginated response containing SWML webhook resources. + +## **Example** + +```php {9} +fabric->swml_webhooks->list(); +foreach ($response["data"] ?? [] as $webhook) { + echo "{$webhook['name']}: {$webhook['id']}"; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/update.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/update.mdx new file mode 100644 index 000000000..87c64bc0c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/swml-webhooks/update.mdx @@ -0,0 +1,38 @@ +--- +title: "update" +slug: /reference/php/rest/fabric/swml-webhooks/update +description: Partially update a SWML webhook resource. +max-toc-depth: 3 +--- + +Partially update a SWML webhook resource. Uses PATCH for partial. + +## **Parameters** + + + The unique identifier of the SWML webhook. + + +Additional keyword arguments are the fields to update. + +## **Returns** + +`dict` -- The updated SWML webhook resource. + +## **Example** + +```php {9} +fabric->swml_webhooks->update("webhook-id", name: "updated-name"); +echo "Updated: {$updated['name']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-embed-token.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-embed-token.mdx new file mode 100644 index 000000000..6ff3a42cd --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-embed-token.mdx @@ -0,0 +1,34 @@ +--- +title: "createEmbedToken" +slug: /reference/php/rest/fabric/tokens/create-embed-token +description: Create an embed authentication token. +max-toc-depth: 3 +--- + +Create an embed authentication token. + +## **Parameters** + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created embed token. + +## **Example** + +```php {9} +fabric->tokens->create_embed_token(resource_id: "resource-id"); +echo "Embed token: {$token['token']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-guest-token.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-guest-token.mdx new file mode 100644 index 000000000..dc591985b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-guest-token.mdx @@ -0,0 +1,34 @@ +--- +title: "createGuestToken" +slug: /reference/php/rest/fabric/tokens/create-guest-token +description: Create a guest authentication token. +max-toc-depth: 3 +--- + +Create a guest authentication token. + +## **Parameters** + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created guest token. + +## **Example** + +```php {9} +fabric->tokens->create_guest_token(name: "guest-user"); +echo "Guest token: {$token['token']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-invite-token.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-invite-token.mdx new file mode 100644 index 000000000..486d9f922 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-invite-token.mdx @@ -0,0 +1,34 @@ +--- +title: "createInviteToken" +slug: /reference/php/rest/fabric/tokens/create-invite-token +description: Create an invite token for a subscriber. +max-toc-depth: 3 +--- + +Create an invite token for a subscriber. + +## **Parameters** + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created invite token. + +## **Example** + +```php {9} +fabric->tokens->create_invite_token(subscriber_id: "subscriber-id"); +echo "Invite token: {$token['token']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-subscriber-token.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-subscriber-token.mdx new file mode 100644 index 000000000..07418d598 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/tokens/create-subscriber-token.mdx @@ -0,0 +1,38 @@ +--- +title: "createSubscriberToken" +slug: /reference/php/rest/fabric/tokens/create-subscriber-token +description: Create a subscriber authentication token. +max-toc-depth: 3 +--- + +Create a subscriber authentication token. + +## **Parameters** + + + The unique identifier of the subscriber. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The created subscriber token. + +## **Example** + +```php {9} +fabric->tokens->create_subscriber_token(subscriber_id: "subscriber-id"); +echo "Token: {$token['token']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/tokens/index.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/tokens/index.mdx new file mode 100644 index 000000000..de0339c5f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/tokens/index.mdx @@ -0,0 +1,52 @@ +--- +title: "Tokens" +slug: /reference/php/rest/fabric/tokens +description: Create and manage Fabric authentication tokens. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[createsubscribertoken]: /docs/sdks/reference/php/rest/fabric/tokens/create-subscriber-token +[refreshsubscribertoken]: /docs/sdks/reference/php/rest/fabric/tokens/refresh-subscriber-token +[createinvitetoken]: /docs/sdks/reference/php/rest/fabric/tokens/create-invite-token +[createguesttoken]: /docs/sdks/reference/php/rest/fabric/tokens/create-guest-token +[createembedtoken]: /docs/sdks/reference/php/rest/fabric/tokens/create-embed-token + +Create subscriber, guest, invite, and embed tokens for Fabric authentication. + +Access via `client.fabric.tokens` on a [`RestClient`][restclient] instance. + +```php +fabric->tokens->create_subscriber_token(subscriber_id: "sub-id"); + + +``` + +## **Methods** + + + + Create a subscriber authentication token. + + + Refresh an existing subscriber token. + + + Create an invite token for a subscriber. + + + Create a guest authentication token. + + + Create an embed authentication token. + + diff --git a/fern/products/sdks/pages/reference/php/rest/fabric/tokens/refresh-subscriber-token.mdx b/fern/products/sdks/pages/reference/php/rest/fabric/tokens/refresh-subscriber-token.mdx new file mode 100644 index 000000000..0444c3114 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/fabric/tokens/refresh-subscriber-token.mdx @@ -0,0 +1,38 @@ +--- +title: "refreshSubscriberToken" +slug: /reference/php/rest/fabric/tokens/refresh-subscriber-token +description: Refresh an existing subscriber token. +max-toc-depth: 3 +--- + +Refresh an existing subscriber authentication token. + +## **Parameters** + + + The existing subscriber token to refresh. + + +Additional keyword arguments are passed directly to the API as the request body. + +## **Returns** + +`dict` -- The refreshed subscriber token. + +## **Example** + +```php {9} +fabric->tokens->refresh_subscriber_token(token: "existing-token"); +echo "Refreshed token: {$refreshed['token']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/imported-numbers.mdx b/fern/products/sdks/pages/reference/php/rest/imported-numbers.mdx new file mode 100644 index 000000000..2d1e610e1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/imported-numbers.mdx @@ -0,0 +1,65 @@ +--- +title: "Imported Numbers" +slug: /reference/php/rest/imported-numbers +description: "Import phone numbers from other providers." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client + +Import externally-hosted phone numbers into your SignalWire project. This allows +you to route calls through SignalWire for numbers hosted by another carrier. Only +the create operation is supported. + +Access via `client.importedNumbers` on a [`RestClient`][restclient] instance. + +```php + + The phone number in E.164 format (e.g., `"+15551234567"`). + + + + Additional import parameters (e.g., `name`, `call_handler`, + `call_request_url`). + + +## **Returns** + +`dict` -- The imported phone number object. + +## **Example** + +```php +importedNumbers->create( + number: "+15551234567", + name: "External Support Line", +); +echo "Imported:", $imported["id"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/logs/index.mdx b/fern/products/sdks/pages/reference/php/rest/logs/index.mdx new file mode 100644 index 000000000..70c695895 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/logs/index.mdx @@ -0,0 +1,40 @@ +--- +title: "Logs" +slug: /reference/php/rest/logs +description: "Message, voice, fax, and conference logs." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[voice]: /docs/sdks/reference/php/rest/logs/voice + +Query read-only logs for messages, voice calls, faxes, and conferences. Each +log type is accessed as a sub-resource with `list()` and `get()` methods. Voice +logs also support listing individual call events. + +Access via `client.logs` on a [`RestClient`][restclient] instance. + +```php +logs->voice->list(page_size: 5); +foreach ($voice_logs["data"] ?? [] as $log) { + echo $log["id"], $log["from"] ?? null, "->", $log["to"] ?? null; +} + +``` + +## **Sub-resources** + + + + Query voice call log entries. + + diff --git a/fern/products/sdks/pages/reference/php/rest/logs/voice/get.mdx b/fern/products/sdks/pages/reference/php/rest/logs/voice/get.mdx new file mode 100644 index 000000000..82bc094cc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/logs/voice/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/logs/voice/get +description: Retrieve a specific voice log entry. +max-toc-depth: 3 +--- + +Retrieve a specific voice call log entry. + +## **Parameters** + + + The voice log ID. + + +## **Returns** + +`dict` -- The voice log object. + +## **Example** + +```php {9-10} +logs->voice->get("voice-log-id"); +echo $call["from"] ?? null, "->", $call["to"] ?? null, $call["duration"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/logs/voice/index.mdx b/fern/products/sdks/pages/reference/php/rest/logs/voice/index.mdx new file mode 100644 index 000000000..7c74d1ffc --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/logs/voice/index.mdx @@ -0,0 +1,48 @@ +--- +title: "Voice Logs" +slug: /reference/php/rest/logs/voice +description: "Query voice call log entries." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/logs/voice/list +[get]: /docs/sdks/reference/php/rest/logs/voice/get +[listevents]: /docs/sdks/reference/php/rest/logs/voice/list-events + +Query voice call log entries. Voice logs provide a read-only view of call +activity in your project, including per-call event timelines. + +Access via `client.logs.voice` on a [`RestClient`][restclient] instance. + +```php +logs->voice->list(page_size: 5); +foreach ($logs["data"] ?? [] as $log) { + echo $log["id"], $log["from"] ?? null, "->", $log["to"] ?? null; +} + + +``` + +## **Methods** + + + + List voice call log entries. + + + Retrieve a specific voice log entry. + + + List events for a specific voice call. + + diff --git a/fern/products/sdks/pages/reference/php/rest/logs/voice/list-events.mdx b/fern/products/sdks/pages/reference/php/rest/logs/voice/list-events.mdx new file mode 100644 index 000000000..8320c5d04 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/logs/voice/list-events.mdx @@ -0,0 +1,43 @@ +--- +title: "listEvents" +slug: /reference/php/rest/logs/voice/list-events +description: List events for a specific voice call. +max-toc-depth: 3 +--- + +List events for a specific voice call. Events include state transitions +(ringing, answered, ended), media events, and other call lifecycle data. + +## **Parameters** + + + The voice log ID. + + + + Optional query parameters for filtering and pagination. + + +## **Returns** + +`dict` -- JSON response containing a `data` list of event objects. + +## **Example** + +```php {9} +logs->voice->list_events("voice-log-id"); +foreach ($events["data"] ?? [] as $event) { + echo $event["type"] ?? null, $event["timestamp"] ?? null; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/logs/voice/list.mdx b/fern/products/sdks/pages/reference/php/rest/logs/voice/list.mdx new file mode 100644 index 000000000..d7f457638 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/logs/voice/list.mdx @@ -0,0 +1,38 @@ +--- +title: "list" +slug: /reference/php/rest/logs/voice/list +description: List voice call log entries. +max-toc-depth: 3 +--- + +List voice call log entries. + +## **Parameters** + + + Optional query parameters for filtering and pagination. + + +## **Returns** + +`dict` -- JSON response containing a `data` list of voice log objects. + +## **Example** + +```php {9} +logs->voice->list(page_size: 20); +foreach ($calls["data"] ?? [] as $call) { + echo $call["from"] ?? null, "->", $call["to"] ?? null, $call["duration"] ?? null; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/lookup.mdx b/fern/products/sdks/pages/reference/php/rest/lookup.mdx new file mode 100644 index 000000000..5c9fd351f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/lookup.mdx @@ -0,0 +1,63 @@ +--- +title: "Lookup" +slug: /reference/php/rest/lookup +description: "Look up phone number information." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client + +Look up carrier and CNAM information for a phone number. This is useful for +validating phone numbers, identifying carriers, and checking caller name data +before placing calls. + +Access via `client.lookup` on a [`RestClient`][restclient] instance. + +```php + + The phone number in E.164 format (e.g., `"+15551234567"`). + + + + Optional query parameters to control what data is included in the response + (e.g., `include` to request specific data types like carrier or CNAM). + + +## **Returns** + +`dict` -- Lookup result containing carrier, CNAM, and number format details. + +## **Example** + +```php +lookup->phone_number("+15551234567"); +echo "Carrier:", $info["carrier"] ?? {}.$get("name"); +echo "Type:", $info["carrier"] ?? {}.$get("type"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/mfa/index.mdx b/fern/products/sdks/pages/reference/php/rest/mfa/index.mdx new file mode 100644 index 000000000..4b12aaf21 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/mfa/index.mdx @@ -0,0 +1,34 @@ +--- +title: "MFA" +slug: /reference/php/rest/mfa +description: "Multi-factor authentication via SMS and voice." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client + +Send and verify multi-factor authentication (MFA) codes via SMS or voice call. +The typical flow is: request a code with `sms()` or `call()`, then confirm it +with `verify()`. + +Access via `client.mfa` on a [`RestClient`][restclient] instance. + +```php +mfa->sms(to: "+15551234567", from_: "+15559876543"); +echo $request["id"]; + +``` + +## **Methods** + + + diff --git a/fern/products/sdks/pages/reference/php/rest/number-groups/create.mdx b/fern/products/sdks/pages/reference/php/rest/number-groups/create.mdx new file mode 100644 index 000000000..7bd8ae7aa --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/number-groups/create.mdx @@ -0,0 +1,40 @@ +--- +title: "create" +slug: /reference/php/rest/number-groups/create +description: Create a new number group. +max-toc-depth: 3 +--- + +Create a new number group. + +## **Parameters** + + + Group name. + + + + Additional group configuration. + + +## **Returns** + +`dict` -- The newly created group object. + +## **Example** + +```php {9} +numberGroups->create(name: "Sales Numbers"); +echo "Group ID:", $group["id"]; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/number-groups/delete.mdx b/fern/products/sdks/pages/reference/php/rest/number-groups/delete.mdx new file mode 100644 index 000000000..e973c8894 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/number-groups/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/number-groups/delete +description: Delete a number group. +max-toc-depth: 3 +--- + +Delete a number group. + +## **Parameters** + + + The group resource ID. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +numberGroups->delete("group-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/number-groups/get.mdx b/fern/products/sdks/pages/reference/php/rest/number-groups/get.mdx new file mode 100644 index 000000000..770795284 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/number-groups/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/number-groups/get +description: Retrieve a specific number group. +max-toc-depth: 3 +--- + +Retrieve a specific number group by ID. + +## **Parameters** + + + The group resource ID. + + +## **Returns** + +`dict` -- The group object. + +## **Example** + +```php {9} +numberGroups->get("group-id"); +echo $group["name"]; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/number-groups/index.mdx b/fern/products/sdks/pages/reference/php/rest/number-groups/index.mdx new file mode 100644 index 000000000..f49aa9b22 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/number-groups/index.mdx @@ -0,0 +1,57 @@ +--- +title: "Number Groups" +slug: /reference/php/rest/number-groups +description: "Manage number groups and membership." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/number-groups/list +[create]: /docs/sdks/reference/php/rest/number-groups/create +[get]: /docs/sdks/reference/php/rest/number-groups/get +[update]: /docs/sdks/reference/php/rest/number-groups/update +[delete]: /docs/sdks/reference/php/rest/number-groups/delete + +Manage number groups and their memberships. Number groups let you organize phone +numbers into logical collections for routing, billing, or management purposes. +This resource provides full CRUD on groups (with PUT for updates) plus membership +operations for adding and removing numbers. + +Access via `client.numberGroups` on a [`RestClient`][restclient] instance. + +```php +numberGroups->list(); +foreach ($groups["data"] ?? [] as $group) { + echo $group["id"], $group["name"] ?? null; +} + +``` + +## **Methods** + + + + List number groups in the project. + + + Create a new number group. + + + Retrieve a specific number group. + + + Update a number group. + + + Delete a number group. + + diff --git a/fern/products/sdks/pages/reference/php/rest/number-groups/list.mdx b/fern/products/sdks/pages/reference/php/rest/number-groups/list.mdx new file mode 100644 index 000000000..2993839a4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/number-groups/list.mdx @@ -0,0 +1,38 @@ +--- +title: "list" +slug: /reference/php/rest/number-groups/list +description: List number groups in the project. +max-toc-depth: 3 +--- + +List number groups in the project. + +## **Parameters** + + + Optional query parameters to filter and paginate results. + + +## **Returns** + +`dict` -- JSON response containing a `data` list of group objects. + +## **Example** + +```php {9} +numberGroups->list(); +foreach ($result["data"] ?? [] as $group) { + echo $group["name"], $group["id"] ?? null; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/number-groups/update.mdx b/fern/products/sdks/pages/reference/php/rest/number-groups/update.mdx new file mode 100644 index 000000000..23687b308 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/number-groups/update.mdx @@ -0,0 +1,40 @@ +--- +title: "update" +slug: /reference/php/rest/number-groups/update +description: Update a number group. +max-toc-depth: 3 +--- + +Update a number group. Uses PUT to replace fields. + +## **Parameters** + + + The group resource ID. + + + + Fields to update (e.g., `name`). + + +## **Returns** + +`dict` -- The updated group object. + +## **Example** + +```php {9} +numberGroups->update("group-id", name: "Support Numbers"); +echo $updated["name"]; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/overview.mdx b/fern/products/sdks/pages/reference/php/rest/overview.mdx new file mode 100644 index 000000000..daf817c2d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/overview.mdx @@ -0,0 +1,153 @@ +--- +title: "REST Client" +sidebar-title: Overview +subtitle: "PHP API reference for RestClient and resource namespaces" +slug: /reference/php/rest +description: "HTTP client for SignalWire REST API resource management." +max-toc-depth: 3 +position: 0 +--- + +[client]: /docs/sdks/reference/php/rest/client +[phone-numbers]: /docs/sdks/reference/php/rest/phone-numbers +[fabric]: /docs/sdks/reference/php/rest/fabric +[calling]: /docs/sdks/reference/php/rest/calling +[video]: /docs/sdks/reference/php/rest/video +[datasphere]: /docs/sdks/reference/php/rest/datasphere +[logs]: /docs/sdks/reference/php/rest/logs +[registry]: /docs/sdks/reference/php/rest/registry +[compat]: /docs/sdks/reference/php/rest/compat +[mfa]: /docs/sdks/reference/php/rest/mfa + +The REST namespace provides a synchronous HTTP client for the SignalWire platform +APIs. It organizes every HTTP endpoint into namespaced resource objects with +standard CRUD operations, letting you manage phone numbers, fabric resources, +call logs, video rooms, datasphere documents, and more from PHP. + +## Example + +Search for available phone numbers, purchase one, and assign it to a fabric +AI agent resource: + +```php +phoneNumbers()->search(['area_code' => '512', 'quantity' => 3]); +foreach ($available['data'] ?? [] as $number) { + echo "{$number['number']} - {$number['region']}\n"; +} + +// Purchase the first available number +$purchased = $client->phoneNumbers()->create(['number' => $available['data'][0]['number']]); +echo "Purchased: {$purchased['number']}\n"; + +// List your AI agent resources +$response = $client->fabric()->aiAgents()->list(); +foreach ($response['data'] ?? [] as $agent) { + echo "Agent: {$agent['name']} ({$agent['id']})\n"; +} + +// Query recent voice call logs +$logs = $client->logs()->voice()->list(['page_size' => 5]); +foreach ($logs['data'] ?? [] as $log) { + echo "Call from {$log['from']} to {$log['to']}\n"; +} +``` + + +All three constructor arguments can also be provided via environment variables: +`SIGNALWIRE_PROJECT_ID`, `SIGNALWIRE_API_TOKEN`, and `SIGNALWIRE_SPACE`. +When those are set, you can instantiate with `RestClient()` and no arguments. + + +## Error Handling + +REST errors raise `SignalWireRestError`: + +```php +phoneNumbers()->get('nonexistent-id'); +} catch (SignalWireRestError $e) { + echo "HTTP {$e->statusCode}: {$e->body}\n"; + echo "URL: {$e->method} {$e->url}\n"; +} +``` + +## Resources + + + + Constructor, authentication, and all namespace properties. + + + Search, purchase, and manage phone numbers. + + + AI agents, SWML scripts, subscribers, call flows, and tokens. + + + REST-based call control with 37+ commands. + + + Rooms, conferences, sessions, recordings, and streams. + + + Document management and semantic search. + + + Message, voice, fax, and conference log queries. + + + 10DLC brand and campaign registration. + + + Twilio-compatible LAML API for migration. + + + Multi-factor authentication via SMS and voice. + + diff --git a/fern/products/sdks/pages/reference/php/rest/phone-numbers/create.mdx b/fern/products/sdks/pages/reference/php/rest/phone-numbers/create.mdx new file mode 100644 index 000000000..dc8694fc2 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/phone-numbers/create.mdx @@ -0,0 +1,43 @@ +--- +title: "create" +slug: /reference/php/rest/phone-numbers/create +description: Purchase a phone number. +max-toc-depth: 3 +--- + +Purchase a phone number. The exact keyword arguments depend on the number being +purchased (typically obtained from a prior `search()` call). + +## **Parameters** + + + Number details. Common fields include `number` (the E.164 phone number to + purchase). + + +## **Returns** + +`dict` -- The newly purchased phone number object. + +## **Example** + +```php {13} +phoneNumbers->search(area_code: "512", quantity: 1); +$numbers = $available["data"] ?? []; +if ($numbers) { + $purchased = $client->phoneNumbers->create(number: numbers[0]["number"]); + echo "Purchased:", $purchased["number"]; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/phone-numbers/delete.mdx b/fern/products/sdks/pages/reference/php/rest/phone-numbers/delete.mdx new file mode 100644 index 000000000..90779c89d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/phone-numbers/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/phone-numbers/delete +description: Release a phone number from the project. +max-toc-depth: 3 +--- + +Release (delete) a phone number from the project. + +## **Parameters** + + + The phone number resource ID. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +phoneNumbers->delete("phone-number-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/phone-numbers/get.mdx b/fern/products/sdks/pages/reference/php/rest/phone-numbers/get.mdx new file mode 100644 index 000000000..1abe688db --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/phone-numbers/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/phone-numbers/get +description: Retrieve details for a specific phone number. +max-toc-depth: 3 +--- + +Retrieve details for a specific phone number. + +## **Parameters** + + + The phone number resource ID. + + +## **Returns** + +`dict` -- The phone number object. + +## **Example** + +```php {9-10} +phoneNumbers->get("phone-number-id"); +echo $number["number"], $number["name"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/phone-numbers/index.mdx b/fern/products/sdks/pages/reference/php/rest/phone-numbers/index.mdx new file mode 100644 index 000000000..c72a9d1c4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/phone-numbers/index.mdx @@ -0,0 +1,56 @@ +--- +title: "Phone Numbers" +slug: /reference/php/rest/phone-numbers +description: "Search and manage phone numbers." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/phone-numbers/list +[create]: /docs/sdks/reference/php/rest/phone-numbers/create +[get]: /docs/sdks/reference/php/rest/phone-numbers/get +[update]: /docs/sdks/reference/php/rest/phone-numbers/update +[delete]: /docs/sdks/reference/php/rest/phone-numbers/delete + +Search for available phone numbers, purchase them, and manage the numbers in your +SignalWire project. This resource extends the standard CRUD pattern with a `search()` +method for discovering available numbers and uses PUT for updates. + +Access via `client.phoneNumbers` on a [`RestClient`][restclient] instance. + +```php +phoneNumbers->search(area_code: "512"); +foreach ($available["data"] ?? [] as $number) { + echo $number["phone_number"]; +} + +``` + +## **Methods** + + + + List phone numbers owned by the project. + + + Purchase a phone number. + + + Retrieve details for a specific phone number. + + + Update configuration for a phone number. + + + Release a phone number from the project. + + diff --git a/fern/products/sdks/pages/reference/php/rest/phone-numbers/list.mdx b/fern/products/sdks/pages/reference/php/rest/phone-numbers/list.mdx new file mode 100644 index 000000000..deae8517b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/phone-numbers/list.mdx @@ -0,0 +1,40 @@ +--- +title: "list" +slug: /reference/php/rest/phone-numbers/list +description: List phone numbers owned by the project. +max-toc-depth: 3 +--- + +List phone numbers owned by the project. + +## **Parameters** + + + Optional query parameters to filter and paginate results (e.g., `page_size`, + `page_token`). + + +## **Returns** + +`dict` -- JSON response containing a `data` list of phone number objects and +pagination links. + +## **Example** + +```php {9} +phoneNumbers->list(page_size: 10); +foreach ($result["data"] ?? [] as $number) { + echo $number["number"], $number["name"] ?? null; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/phone-numbers/update.mdx b/fern/products/sdks/pages/reference/php/rest/phone-numbers/update.mdx new file mode 100644 index 000000000..b64ba0933 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/phone-numbers/update.mdx @@ -0,0 +1,39 @@ +--- +title: "update" +slug: /reference/php/rest/phone-numbers/update +description: Update configuration for a phone number. +max-toc-depth: 3 +--- + +Update configuration for a phone number. Uses PUT. + +## **Parameters** + + + The phone number resource ID. + + + + Fields to update (e.g., `name`, `call_handler`, `call_request_url`). + + +## **Returns** + +`dict` -- The updated phone number object. + +## **Example** + +```php {9-9} +phoneNumbers->update("phone-number-id", name: "Support Line"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/project/create.mdx b/fern/products/sdks/pages/reference/php/rest/project/create.mdx new file mode 100644 index 000000000..58e37e3d6 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/project/create.mdx @@ -0,0 +1,39 @@ +--- +title: "create" +slug: /reference/php/rest/project/create +description: Create a new API token for the project. +max-toc-depth: 3 +--- + +### tokens.create + +Create a new API token for the project. + +## **Parameters** + + + Token configuration fields (e.g., `name`, `scopes`). + + +## **Returns** + +`dict` -- The newly created token object, including the token value. + +## **Example** + +```php {9} +project->tokens->create(name: "ci-token"); +echo "Token:", $token["token"] ?? null; +echo "ID:", $token["id"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/project/delete.mdx b/fern/products/sdks/pages/reference/php/rest/project/delete.mdx new file mode 100644 index 000000000..9c9bb819f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/project/delete.mdx @@ -0,0 +1,37 @@ +--- +title: "delete" +slug: /reference/php/rest/project/delete +description: Revoke and delete an API token. +max-toc-depth: 3 +--- + +### tokens.delete + +Revoke and delete an API token. + +## **Parameters** + + + The token resource ID. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +project->tokens->delete("token-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/project/index.mdx b/fern/products/sdks/pages/reference/php/rest/project/index.mdx new file mode 100644 index 000000000..1a9a33dd4 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/project/index.mdx @@ -0,0 +1,46 @@ +--- +title: "Project" +slug: /reference/php/rest/project +description: "Project information and API tokens." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[create]: /docs/sdks/reference/php/rest/project/create +[update]: /docs/sdks/reference/php/rest/project/update +[delete]: /docs/sdks/reference/php/rest/project/delete + +Manage project-level API tokens. Tokens control access to your SignalWire project +and can be created, updated, and revoked. + +Access via `client.project.tokens` on a [`RestClient`][restclient] instance. + +```php +project->tokens->create(name: "ci-token"); +echo $token["id"]; + + +``` + +## **Methods** + + + + Create a new API token for the project. + + + Update an existing API token. + + + Revoke and delete an API token. + + diff --git a/fern/products/sdks/pages/reference/php/rest/project/update.mdx b/fern/products/sdks/pages/reference/php/rest/project/update.mdx new file mode 100644 index 000000000..57ad6de58 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/project/update.mdx @@ -0,0 +1,41 @@ +--- +title: "update" +slug: /reference/php/rest/project/update +description: Update an existing API token. +max-toc-depth: 3 +--- + +### tokens.update + +Update an existing API token. Uses PATCH. + +## **Parameters** + + + The token resource ID. + + + + Fields to update (e.g., `name`). + + +## **Returns** + +`dict` -- The updated token object. + +## **Example** + +```php {9-9} +project->tokens->update("token-id", name: "renamed-token"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/pubsub.mdx b/fern/products/sdks/pages/reference/php/rest/pubsub.mdx new file mode 100644 index 000000000..e46403034 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/pubsub.mdx @@ -0,0 +1,73 @@ +--- +title: "PubSub" +slug: /reference/php/rest/pubsub +description: "Publish-subscribe real-time messaging." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client + +Generate tokens for the SignalWire PubSub (publish-subscribe) real-time messaging +service. PubSub tokens authenticate client-side connections to subscribe to +channels and publish messages. + +Access via `client.pubsub` on a [`RestClient`][restclient] instance. + +```php + + List of channel names the token grants access to. + + + + Identifier for the connecting member. + + + + Token time-to-live in seconds. + + + + Additional token parameters (e.g., `state`, `permissions`). + + +## **Returns** + +`dict` -- The token object containing the JWT token string. + +## **Example** + +```php +pubsub->create_token( + channels: ["notifications", "updates"], + member_id: "user-123", + ttl: 3600, +); +echo "PubSub token:", $token["token"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/queues/create.mdx b/fern/products/sdks/pages/reference/php/rest/queues/create.mdx new file mode 100644 index 000000000..a3cd4a38b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/queues/create.mdx @@ -0,0 +1,40 @@ +--- +title: "create" +slug: /reference/php/rest/queues/create +description: Create a new queue. +max-toc-depth: 3 +--- + +Create a new queue. + +## **Parameters** + + + Queue name. + + + + Additional queue configuration fields (e.g., `max_size`, `fifo`). + + +## **Returns** + +`dict` -- The newly created queue object. + +## **Example** + +```php {9} +queues->create(name: "support", max_size: 50); +echo "Queue ID:", $queue["id"]; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/queues/delete.mdx b/fern/products/sdks/pages/reference/php/rest/queues/delete.mdx new file mode 100644 index 000000000..4e097ba1e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/queues/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/queues/delete +description: Delete a queue. +max-toc-depth: 3 +--- + +Delete a queue. + +## **Parameters** + + + The queue resource ID. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9} +queues->delete("queue-id"); +echo "Deleted successfully"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/queues/get.mdx b/fern/products/sdks/pages/reference/php/rest/queues/get.mdx new file mode 100644 index 000000000..ce03cd74f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/queues/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/queues/get +description: Retrieve a specific queue. +max-toc-depth: 3 +--- + +Retrieve a specific queue. + +## **Parameters** + + + The queue resource ID. + + +## **Returns** + +`dict` -- The queue object. + +## **Example** + +```php {9-10} +queues->get("queue-id"); +echo $queue["name"], $queue["current_size"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/queues/index.mdx b/fern/products/sdks/pages/reference/php/rest/queues/index.mdx new file mode 100644 index 000000000..971a9bdc1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/queues/index.mdx @@ -0,0 +1,56 @@ +--- +title: "Queues" +slug: /reference/php/rest/queues +description: "Manage call queues and members." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/queues/list +[create]: /docs/sdks/reference/php/rest/queues/create +[get]: /docs/sdks/reference/php/rest/queues/get +[update]: /docs/sdks/reference/php/rest/queues/update +[delete]: /docs/sdks/reference/php/rest/queues/delete + +Manage call queues and their members. Queues allow you to hold callers and +distribute them to available agents. This resource provides full CRUD on queues +(with PUT for updates) plus member management operations. + +Access via `client.queues` on a [`RestClient`][restclient] instance. + +```php +queues->list(); +foreach ($queues["data"] ?? [] as $q) { + echo $q["id"], $q["friendly_name"] ?? null; +} + +``` + +## **Methods** + + + + List queues in the project. + + + Create a new queue. + + + Retrieve a specific queue. + + + Update a queue. + + + Delete a queue. + + diff --git a/fern/products/sdks/pages/reference/php/rest/queues/list.mdx b/fern/products/sdks/pages/reference/php/rest/queues/list.mdx new file mode 100644 index 000000000..f4bd0f5f3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/queues/list.mdx @@ -0,0 +1,38 @@ +--- +title: "list" +slug: /reference/php/rest/queues/list +description: List queues in the project. +max-toc-depth: 3 +--- + +List queues in the project. + +## **Parameters** + + + Optional query parameters to filter and paginate results. + + +## **Returns** + +`dict` -- JSON response containing a `data` list of queue objects. + +## **Example** + +```php {9} +queues->list(); +foreach ($result["data"] ?? [] as $q) { + echo $q["name"], $q["current_size"] ?? null; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/queues/update.mdx b/fern/products/sdks/pages/reference/php/rest/queues/update.mdx new file mode 100644 index 000000000..3516fc088 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/queues/update.mdx @@ -0,0 +1,40 @@ +--- +title: "update" +slug: /reference/php/rest/queues/update +description: Update a queue. +max-toc-depth: 3 +--- + +Update a queue. Uses PUT. + +## **Parameters** + + + The queue resource ID. + + + + Fields to update (e.g., `name`, `max_size`). + + +## **Returns** + +`dict` -- The updated queue object. + +## **Example** + +```php {9} +queues->update("queue-id", name: "priority-support"); +echo "Updated: {$updated['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/recordings/delete.mdx b/fern/products/sdks/pages/reference/php/rest/recordings/delete.mdx new file mode 100644 index 000000000..159b106e3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/recordings/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/recordings/delete +description: Delete a recording. +max-toc-depth: 3 +--- + +Delete a recording. + +## **Parameters** + + + The recording resource ID. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +recordings->delete("recording-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/recordings/get.mdx b/fern/products/sdks/pages/reference/php/rest/recordings/get.mdx new file mode 100644 index 000000000..dda0f8198 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/recordings/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/recordings/get +description: Retrieve a specific recording. +max-toc-depth: 3 +--- + +Retrieve a specific recording. + +## **Parameters** + + + The recording resource ID. + + +## **Returns** + +`dict` -- The recording object, including download URL and metadata. + +## **Example** + +```php {9-10} +recordings->get("recording-id"); +echo $rec["duration"] ?? null, $rec["url"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/recordings/index.mdx b/fern/products/sdks/pages/reference/php/rest/recordings/index.mdx new file mode 100644 index 000000000..0a608516c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/recordings/index.mdx @@ -0,0 +1,49 @@ +--- +title: "Recordings" +slug: /reference/php/rest/recordings +description: "List, get, and delete call recordings." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/recordings/list +[get]: /docs/sdks/reference/php/rest/recordings/get +[delete]: /docs/sdks/reference/php/rest/recordings/delete + +Manage call recordings in your SignalWire project. This is a read-only resource +with delete support -- there is no create or update operation since recordings are +generated automatically during calls. + +Access via `client.recordings` on a [`RestClient`][restclient] instance. + +```php +recordings->list(); +foreach ($recordings["data"] ?? [] as $rec) { + echo $rec["id"], $rec["duration"] ?? null; +} + + +``` + +## **Methods** + + + + List recordings in the project. + + + Retrieve a specific recording. + + + Delete a recording. + + diff --git a/fern/products/sdks/pages/reference/php/rest/recordings/list.mdx b/fern/products/sdks/pages/reference/php/rest/recordings/list.mdx new file mode 100644 index 000000000..dbc746e2d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/recordings/list.mdx @@ -0,0 +1,38 @@ +--- +title: "list" +slug: /reference/php/rest/recordings/list +description: List recordings in the project. +max-toc-depth: 3 +--- + +List recordings in the project. + +## **Parameters** + + + Optional query parameters to filter and paginate results. + + +## **Returns** + +`dict` -- JSON response containing a `data` list of recording objects. + +## **Example** + +```php {9} +recordings->list(page_size: 20); +foreach ($result["data"] ?? [] as $rec) { + echo $rec["id"] ?? null, $rec["duration"] ?? null, $rec["state"] ?? null; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/registry/brands/create-campaign.mdx b/fern/products/sdks/pages/reference/php/rest/registry/brands/create-campaign.mdx new file mode 100644 index 000000000..e29ada20e --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/registry/brands/create-campaign.mdx @@ -0,0 +1,56 @@ +--- +title: "createCampaign" +slug: /reference/php/rest/registry/brands/create-campaign +description: Create a messaging campaign under a brand. +max-toc-depth: 3 +--- + +Create a messaging campaign under a brand. + +## **Parameters** + + + The brand resource ID. + + + + Campaign description. + + + + Campaign use case. + + - `"MIXED"` -- multiple or general-purpose messaging use cases + - `"MARKETING"` -- promotional or marketing messages + - `"CUSTOMER_CARE"` -- customer support and service messages + + + + Additional campaign fields. + + +## **Returns** + +`dict` -- The newly created campaign object. + +## **Example** + +```php {9} +registry->brands->create_campaign( + "brand-id", + description: "Customer notifications", + usecase: "MIXED", +); +echo "Campaign ID:", $campaign["id"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/registry/brands/create.mdx b/fern/products/sdks/pages/reference/php/rest/registry/brands/create.mdx new file mode 100644 index 000000000..e38ba1314 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/registry/brands/create.mdx @@ -0,0 +1,51 @@ +--- +title: "create" +slug: /reference/php/rest/registry/brands/create +description: Register a new 10DLC brand. +max-toc-depth: 3 +--- + +Register a new 10DLC brand. + +## **Parameters** + + + The entity type. Valid values: + - `"PRIVATE_PROFIT"` -- privately held for-profit company + - `"PUBLIC_PROFIT"` -- publicly traded for-profit company + - `"NON_PROFIT"` -- non-profit organization + + + + Display name for the brand. + + + + Additional brand registration fields (e.g., `ein`, `website`, `vertical`). + + +## **Returns** + +`dict` -- The newly created brand object. + +## **Example** + +```php {9} +registry->brands->create( + entity_type: "PRIVATE_PROFIT", + display_name: "My Company", + website: "https://example.com", +); +echo "Brand ID:", $brand["id"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/registry/brands/get.mdx b/fern/products/sdks/pages/reference/php/rest/registry/brands/get.mdx new file mode 100644 index 000000000..1134ce1ac --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/registry/brands/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/registry/brands/get +description: Retrieve a specific brand. +max-toc-depth: 3 +--- + +Retrieve a specific 10DLC brand by ID. + +## **Parameters** + + + The brand resource ID. + + +## **Returns** + +`dict` -- The brand object. + +## **Example** + +```php {9-10} +registry->brands->get("brand-id"); +echo $brand["display_name"] ?? null, $brand["entity_type"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/registry/brands/index.mdx b/fern/products/sdks/pages/reference/php/rest/registry/brands/index.mdx new file mode 100644 index 000000000..0098a636a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/registry/brands/index.mdx @@ -0,0 +1,56 @@ +--- +title: "Brands" +slug: /reference/php/rest/registry/brands +description: "10DLC brand management." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/registry/brands/list +[create]: /docs/sdks/reference/php/rest/registry/brands/create +[get]: /docs/sdks/reference/php/rest/registry/brands/get +[listcampaigns]: /docs/sdks/reference/php/rest/registry/brands/list-campaigns +[createcampaign]: /docs/sdks/reference/php/rest/registry/brands/create-campaign + +Register and manage 10DLC brands. Brands represent the business entity behind +messaging campaigns. Each brand can have one or more campaigns associated with it. + +Access via `client.registry.brands` on a [`RestClient`][restclient] instance. + +```php +registry->brands->list(); +foreach ($brands["data"] ?? [] as $brand) { + echo $brand["id"], $brand["name"] ?? null; +} + + +``` + +## **Methods** + + + + List registered 10DLC brands. + + + Register a new 10DLC brand. + + + Retrieve a specific brand. + + + List campaigns under a brand. + + + Create a messaging campaign under a brand. + + diff --git a/fern/products/sdks/pages/reference/php/rest/registry/brands/list-campaigns.mdx b/fern/products/sdks/pages/reference/php/rest/registry/brands/list-campaigns.mdx new file mode 100644 index 000000000..fe386af39 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/registry/brands/list-campaigns.mdx @@ -0,0 +1,42 @@ +--- +title: "listCampaigns" +slug: /reference/php/rest/registry/brands/list-campaigns +description: List campaigns under a brand. +max-toc-depth: 3 +--- + +List messaging campaigns under a brand. + +## **Parameters** + + + The brand resource ID. + + + + Optional query parameters. + + +## **Returns** + +`dict` -- JSON response containing a `data` list of campaign objects. + +## **Example** + +```php {9} +registry->brands->list_campaigns("brand-id"); +foreach ($campaigns["data"] ?? [] as $c) { + echo $c["description"] ?? null, $c["usecase"] ?? null; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/registry/brands/list.mdx b/fern/products/sdks/pages/reference/php/rest/registry/brands/list.mdx new file mode 100644 index 000000000..6f4b8fb18 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/registry/brands/list.mdx @@ -0,0 +1,38 @@ +--- +title: "list" +slug: /reference/php/rest/registry/brands/list +description: List registered 10DLC brands. +max-toc-depth: 3 +--- + +List registered 10DLC brands. + +## **Parameters** + + + Optional query parameters for filtering and pagination. + + +## **Returns** + +`dict` -- JSON response containing a `data` list of brand objects. + +## **Example** + +```php {9} +registry->brands->list(); +foreach ($brands["data"] ?? [] as $brand) { + echo $brand["display_name"] ?? null, $brand["entity_type"] ?? null; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/registry/campaigns/create-order.mdx b/fern/products/sdks/pages/reference/php/rest/registry/campaigns/create-order.mdx new file mode 100644 index 000000000..91bc2803d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/registry/campaigns/create-order.mdx @@ -0,0 +1,47 @@ +--- +title: "createOrder" +slug: /reference/php/rest/registry/campaigns/create-order +description: Create a number assignment order for a campaign. +max-toc-depth: 3 +--- + +Create a number assignment order to assign phone numbers to a campaign. + +## **Parameters** + + + The campaign resource ID. + + + + List of phone number resource IDs to assign. + + + + Additional order parameters. + + +## **Returns** + +`dict` -- The newly created order object. + +## **Example** + +```php {9} +registry->campaigns->create_order( + "campaign-id", + phone_number_ids: ["number-id-1", "number-id-2"], +); +echo "Order ID:", $order["id"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/registry/campaigns/get.mdx b/fern/products/sdks/pages/reference/php/rest/registry/campaigns/get.mdx new file mode 100644 index 000000000..d3d17be95 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/registry/campaigns/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/registry/campaigns/get +description: Retrieve a specific campaign. +max-toc-depth: 3 +--- + +Retrieve a specific 10DLC campaign by ID. + +## **Parameters** + + + The campaign resource ID. + + +## **Returns** + +`dict` -- The campaign object. + +## **Example** + +```php {9-10} +registry->campaigns->get("campaign-id"); +echo $campaign["description"] ?? null, $campaign["usecase"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/registry/campaigns/index.mdx b/fern/products/sdks/pages/reference/php/rest/registry/campaigns/index.mdx new file mode 100644 index 000000000..af4623955 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/registry/campaigns/index.mdx @@ -0,0 +1,54 @@ +--- +title: "Campaigns" +slug: /reference/php/rest/registry/campaigns +description: "10DLC campaign management." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[get]: /docs/sdks/reference/php/rest/registry/campaigns/get +[update]: /docs/sdks/reference/php/rest/registry/campaigns/update +[listnumbers]: /docs/sdks/reference/php/rest/registry/campaigns/list-numbers +[listorders]: /docs/sdks/reference/php/rest/registry/campaigns/list-orders +[createorder]: /docs/sdks/reference/php/rest/registry/campaigns/create-order + +Manage 10DLC messaging campaigns. Campaigns define the use case and messaging +behavior for a set of phone numbers under a registered brand. + +Access via `client.registry.campaigns` on a [`RestClient`][restclient] instance. + +```php +registry->campaigns->get("campaign-id"); +echo $campaign["id"], $campaign["description"] ?? null; + + +``` + +## **Methods** + + + + Retrieve a specific campaign. + + + Update a campaign. + + + List phone numbers assigned to a campaign. + + + List number assignment orders for a campaign. + + + Create a number assignment order for a campaign. + + diff --git a/fern/products/sdks/pages/reference/php/rest/registry/campaigns/list-numbers.mdx b/fern/products/sdks/pages/reference/php/rest/registry/campaigns/list-numbers.mdx new file mode 100644 index 000000000..069af79ea --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/registry/campaigns/list-numbers.mdx @@ -0,0 +1,42 @@ +--- +title: "listNumbers" +slug: /reference/php/rest/registry/campaigns/list-numbers +description: List phone numbers assigned to a campaign. +max-toc-depth: 3 +--- + +List phone numbers assigned to a campaign. + +## **Parameters** + + + The campaign resource ID. + + + + Optional query parameters. + + +## **Returns** + +`dict` -- JSON response containing a `data` list of number objects. + +## **Example** + +```php {9} +registry->campaigns->list_numbers("campaign-id"); +foreach ($numbers["data"] ?? [] as $n) { + echo $n["number"] ?? null, $n["id"] ?? null; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/registry/campaigns/list-orders.mdx b/fern/products/sdks/pages/reference/php/rest/registry/campaigns/list-orders.mdx new file mode 100644 index 000000000..d84fe9097 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/registry/campaigns/list-orders.mdx @@ -0,0 +1,42 @@ +--- +title: "listOrders" +slug: /reference/php/rest/registry/campaigns/list-orders +description: List number assignment orders for a campaign. +max-toc-depth: 3 +--- + +List number assignment orders for a campaign. + +## **Parameters** + + + The campaign resource ID. + + + + Optional query parameters. + + +## **Returns** + +`dict` -- JSON response containing a `data` list of order objects. + +## **Example** + +```php {9} +registry->campaigns->list_orders("campaign-id"); +foreach ($orders["data"] ?? [] as $order) { + echo $order["id"] ?? null, $order["status"] ?? null; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/registry/campaigns/update.mdx b/fern/products/sdks/pages/reference/php/rest/registry/campaigns/update.mdx new file mode 100644 index 000000000..dbfa50d42 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/registry/campaigns/update.mdx @@ -0,0 +1,43 @@ +--- +title: "update" +slug: /reference/php/rest/registry/campaigns/update +description: Update a campaign. +max-toc-depth: 3 +--- + +Update a 10DLC campaign. Uses PUT to replace fields. + +## **Parameters** + + + The campaign resource ID. + + + + Fields to update (e.g., `description`, `usecase`). + + +## **Returns** + +`dict` -- The updated campaign object. + +## **Example** + +```php {9} +registry->campaigns->update( + "campaign-id", + description: "Updated campaign description", +); +echo $updated["description"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/registry/index.mdx b/fern/products/sdks/pages/reference/php/rest/registry/index.mdx new file mode 100644 index 000000000..e75bab4db --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/registry/index.mdx @@ -0,0 +1,49 @@ +--- +title: "Registry" +slug: /reference/php/rest/registry +description: "10DLC brand and campaign registration." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[brands]: /docs/sdks/reference/php/rest/registry/brands +[campaigns]: /docs/sdks/reference/php/rest/registry/campaigns + +Manage 10DLC (10-digit long code) brand and campaign registration for A2P +(Application-to-Person) messaging compliance. The registry namespace is organized +into four sub-resources: brands, campaigns, orders, and numbers. + +Access via `client.registry` on a [`RestClient`][restclient] instance. + +```php +registry->brands->list(); +foreach ($brands["data"] ?? [] as $brand) { + echo $brand["id"], $brand["name"] ?? null; +} + +``` + +## **Sub-resources** + + + + 10DLC brand management. + + + 10DLC campaign management. + + + + +The registry API is under the `/api/relay/rest/registry/beta` path. The +interface may evolve as the 10DLC ecosystem matures. + diff --git a/fern/products/sdks/pages/reference/php/rest/short-codes/get.mdx b/fern/products/sdks/pages/reference/php/rest/short-codes/get.mdx new file mode 100644 index 000000000..54bae1b38 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/short-codes/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/short-codes/get +description: Retrieve a specific short code. +max-toc-depth: 3 +--- + +Retrieve a specific short code. + +## **Parameters** + + + The short code resource ID. + + +## **Returns** + +`dict` -- The short code object. + +## **Example** + +```php {9-10} +shortCodes->get("short-code-id"); +echo $code["short_code"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/short-codes/index.mdx b/fern/products/sdks/pages/reference/php/rest/short-codes/index.mdx new file mode 100644 index 000000000..f3c6c5bab --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/short-codes/index.mdx @@ -0,0 +1,49 @@ +--- +title: "Short Codes" +slug: /reference/php/rest/short-codes +description: "Manage short codes." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/short-codes/list +[get]: /docs/sdks/reference/php/rest/short-codes/get +[update]: /docs/sdks/reference/php/rest/short-codes/update + +Manage short codes assigned to your SignalWire project. Short codes are +pre-provisioned, so this resource supports listing, retrieving, and updating +only -- there are no create or delete operations. + +Access via `client.shortCodes` on a [`RestClient`][restclient] instance. + +```php +shortCodes->list(); +foreach ($codes["data"] ?? [] as $code) { + echo $code["id"], $code["short_code"] ?? null; +} + + +``` + +## **Methods** + + + + List short codes in the project. + + + Retrieve a specific short code. + + + Update a short code's configuration. + + diff --git a/fern/products/sdks/pages/reference/php/rest/short-codes/list.mdx b/fern/products/sdks/pages/reference/php/rest/short-codes/list.mdx new file mode 100644 index 000000000..67af13a33 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/short-codes/list.mdx @@ -0,0 +1,38 @@ +--- +title: "list" +slug: /reference/php/rest/short-codes/list +description: List short codes in the project. +max-toc-depth: 3 +--- + +List short codes in the project. + +## **Parameters** + + + Optional query parameters to filter and paginate results. + + +## **Returns** + +`dict` -- JSON response containing a `data` list of short code objects. + +## **Example** + +```php {9} +shortCodes->list(); +foreach ($result["data"] ?? [] as $code) { + echo $code["short_code"] ?? null, $code["id"] ?? null; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/short-codes/update.mdx b/fern/products/sdks/pages/reference/php/rest/short-codes/update.mdx new file mode 100644 index 000000000..b8e7dee1f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/short-codes/update.mdx @@ -0,0 +1,42 @@ +--- +title: "update" +slug: /reference/php/rest/short-codes/update +description: Update a short code's configuration. +max-toc-depth: 3 +--- + +Update a short code's configuration. Uses PUT. + +## **Parameters** + + + The short code resource ID. + + + + Fields to update (e.g., `message_handler`, `message_request_url`). + + +## **Returns** + +`dict` -- The updated short code object. + +## **Example** + +```php {9} +shortCodes->update( + "short-code-id", + message_request_url: "https://example.com/sms", +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/sip-profile.mdx b/fern/products/sdks/pages/reference/php/rest/sip-profile.mdx new file mode 100644 index 000000000..656cf6ea0 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/sip-profile.mdx @@ -0,0 +1,88 @@ +--- +title: "SIP Profile" +slug: /reference/php/rest/sip-profile +description: "Get and update SIP profile settings." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client + +Retrieve and update the project-level SIP profile. This is a singleton resource -- +there is one SIP profile per project, so no resource ID is needed. + +Access via `client.sipProfile` on a [`RestClient`][restclient] instance. + +```php + + Fields to update on the SIP profile (e.g., `username`, `password`, + `ciphers`, `codecs`). + + +## **Returns** + +`dict` -- The updated SIP profile object. + +## **Examples** + +### Get the SIP profile + +```php +sipProfile->get(); +echo $profile["username"] ?? null, $profile["domain"] ?? null; + + +``` + +### Update the SIP profile + +```php +sipProfile->update(username: "my-sip-user"); +echo "Updated username:", $updated["username"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/verified-callers/create.mdx b/fern/products/sdks/pages/reference/php/rest/verified-callers/create.mdx new file mode 100644 index 000000000..bca32f8d8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/verified-callers/create.mdx @@ -0,0 +1,41 @@ +--- +title: "create" +slug: /reference/php/rest/verified-callers/create +description: Create a new caller ID entry and initiate verification. +max-toc-depth: 3 +--- + +Create a new caller ID entry and initiate verification. SignalWire will place +a phone call or send an SMS to verify ownership. + +## **Parameters** + + + The phone number to verify in E.164 format. + + + + Additional parameters (e.g., `friendly_name`). + + +## **Returns** + +`dict` -- The newly created caller ID object with its verification state. + +## **Example** + +```php {9} +verifiedCallers->create(phone_number: "+15551234567"); +echo "Verification state:", $caller["verification_state"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/verified-callers/delete.mdx b/fern/products/sdks/pages/reference/php/rest/verified-callers/delete.mdx new file mode 100644 index 000000000..abd9fe1c3 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/verified-callers/delete.mdx @@ -0,0 +1,36 @@ +--- +title: "delete" +slug: /reference/php/rest/verified-callers/delete +description: Delete a verified caller ID. +max-toc-depth: 3 +--- + +Delete a verified caller ID. + +## **Parameters** + + + The caller ID resource ID. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9} +verifiedCallers->delete("caller-id"); +echo "Deleted successfully"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/verified-callers/get.mdx b/fern/products/sdks/pages/reference/php/rest/verified-callers/get.mdx new file mode 100644 index 000000000..f2618cd48 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/verified-callers/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/verified-callers/get +description: Retrieve a specific verified caller ID. +max-toc-depth: 3 +--- + +Retrieve a specific verified caller ID. + +## **Parameters** + + + The caller ID resource ID. + + +## **Returns** + +`dict` -- The caller ID object. + +## **Example** + +```php {9-10} +verifiedCallers->get("caller-id"); +echo $caller["phone_number"] ?? null, $caller["verification_state"] ?? null; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/verified-callers/index.mdx b/fern/products/sdks/pages/reference/php/rest/verified-callers/index.mdx new file mode 100644 index 000000000..bc5f4228b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/verified-callers/index.mdx @@ -0,0 +1,56 @@ +--- +title: "Verified Callers" +slug: /reference/php/rest/verified-callers +description: "Manage verified caller IDs." +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/verified-callers/list +[create]: /docs/sdks/reference/php/rest/verified-callers/create +[get]: /docs/sdks/reference/php/rest/verified-callers/get +[update]: /docs/sdks/reference/php/rest/verified-callers/update +[delete]: /docs/sdks/reference/php/rest/verified-callers/delete + +Manage verified caller IDs for your SignalWire project. Before using a phone +number as a caller ID for outbound calls, it must be verified. This resource +provides full CRUD (with PUT for updates) plus a two-step verification flow. + +Access via `client.verifiedCallers` on a [`RestClient`][restclient] instance. + +```php +verifiedCallers->list(); +foreach ($callers["data"] ?? [] as $caller) { + echo $caller["id"], $caller["phone_number"] ?? null; +} + +``` + +## **Methods** + + + + List verified caller IDs in the project. + + + Create a new caller ID entry and initiate verification. + + + Retrieve a specific verified caller ID. + + + Update a verified caller ID. + + + Delete a verified caller ID. + + diff --git a/fern/products/sdks/pages/reference/php/rest/verified-callers/list.mdx b/fern/products/sdks/pages/reference/php/rest/verified-callers/list.mdx new file mode 100644 index 000000000..11dbf311c --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/verified-callers/list.mdx @@ -0,0 +1,38 @@ +--- +title: "list" +slug: /reference/php/rest/verified-callers/list +description: List verified caller IDs in the project. +max-toc-depth: 3 +--- + +List verified caller IDs in the project. + +## **Parameters** + + + Optional query parameters to filter and paginate results. + + +## **Returns** + +`dict` -- JSON response containing a `data` list of verified caller objects. + +## **Example** + +```php {9} +verifiedCallers->list(); +foreach ($result["data"] ?? [] as $caller) { + echo $caller["phone_number"] ?? null, $caller["verification_state"] ?? null; +} + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/verified-callers/update.mdx b/fern/products/sdks/pages/reference/php/rest/verified-callers/update.mdx new file mode 100644 index 000000000..8b16efa54 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/verified-callers/update.mdx @@ -0,0 +1,40 @@ +--- +title: "update" +slug: /reference/php/rest/verified-callers/update +description: Update a verified caller ID. +max-toc-depth: 3 +--- + +Update a verified caller ID. Uses PUT. + +## **Parameters** + + + The caller ID resource ID. + + + + Fields to update (e.g., `friendly_name`). + + +## **Returns** + +`dict` -- The updated caller ID object. + +## **Example** + +```php {9} +verifiedCallers->update("caller-id", friendly_name: "Main Office"); +echo "Updated: {$updated['id']}"; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/conference-tokens/get.mdx b/fern/products/sdks/pages/reference/php/rest/video/conference-tokens/get.mdx new file mode 100644 index 000000000..fdff35f2d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/conference-tokens/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/video/conference-tokens/get +description: "Retrieve a specific conference token." +max-toc-depth: 3 +--- + +Retrieve a specific conference token. + +## **Parameters** + + + The unique identifier of the conference token. + + +## **Returns** + +`dict` -- The conference token resource. + +## **Example** + +```php {9} +video->conference_tokens->get("token-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/conference-tokens/index.mdx b/fern/products/sdks/pages/reference/php/rest/video/conference-tokens/index.mdx new file mode 100644 index 000000000..40b1ba669 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/conference-tokens/index.mdx @@ -0,0 +1,26 @@ +--- +title: "VideoConferenceTokens" +slug: /reference/php/rest/video/conference-tokens +description: Retrieve and reset video conference tokens. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[get]: /docs/sdks/reference/php/rest/video/conference-tokens/get +[reset]: /docs/sdks/reference/php/rest/video/conference-tokens/reset + +Manage and reset video conference tokens. Resetting a token invalidates the +current value and generates a replacement. + +Access via `client.video.conference_tokens` on a [`RestClient`][restclient] instance. + +## **Methods** + + + + Retrieve a specific conference token. + + + Reset a conference token, invalidating the current token and generating a new one. + + diff --git a/fern/products/sdks/pages/reference/php/rest/video/conference-tokens/reset.mdx b/fern/products/sdks/pages/reference/php/rest/video/conference-tokens/reset.mdx new file mode 100644 index 000000000..752f729da --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/conference-tokens/reset.mdx @@ -0,0 +1,35 @@ +--- +title: "reset" +slug: /reference/php/rest/video/conference-tokens/reset +description: "Reset a conference token, invalidating the current token and generating a new one." +max-toc-depth: 3 +--- + +Reset a conference token, invalidating the current token and generating a new one. + +## **Parameters** + + + The unique identifier of the conference token to reset. + + +## **Returns** + +`dict` -- The reset result, including the new token. + +## **Example** + +```php {9} +video->conference_tokens->reset("token-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/conferences/create-stream.mdx b/fern/products/sdks/pages/reference/php/rest/video/conferences/create-stream.mdx new file mode 100644 index 000000000..64767e75d --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/conferences/create-stream.mdx @@ -0,0 +1,45 @@ +--- +title: "createStream" +slug: /reference/php/rest/video/conferences/create-stream +description: Create a new stream for a conference. +max-toc-depth: 3 +--- + +Create a new stream for a conference, enabling external streaming output +(e.g., RTMP to a streaming platform). + +## **Parameters** + + + The unique identifier of the conference. + + + + The streaming destination URL (e.g., an RTMP endpoint). + + +Additional keyword arguments define the stream configuration. + +## **Returns** + +`dict` -- The created stream resource. + +## **Example** + +```php {9} +video->conferences->create_stream( + "conference-id", + url: "rtmp://live.example.com/key" +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/conferences/create.mdx b/fern/products/sdks/pages/reference/php/rest/video/conferences/create.mdx new file mode 100644 index 000000000..d41ff5ef5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/conferences/create.mdx @@ -0,0 +1,37 @@ +--- +title: "create" +slug: /reference/php/rest/video/conferences/create +description: Create a new video conference. +max-toc-depth: 3 +--- + +Create a new video conference. + +## **Parameters** + + + The name of the conference. + + +Additional keyword arguments define the conference configuration. + +## **Returns** + +`dict` -- The created conference resource. + +## **Example** + +```php {9-9} +video->conferences->create(name: "team-meeting"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/conferences/delete.mdx b/fern/products/sdks/pages/reference/php/rest/video/conferences/delete.mdx new file mode 100644 index 000000000..feceff1b8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/conferences/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/video/conferences/delete +description: Delete a video conference. +max-toc-depth: 3 +--- + +Delete a video conference. + +## **Parameters** + + + The unique identifier of the conference. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +video->conferences->delete("conference-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/conferences/get.mdx b/fern/products/sdks/pages/reference/php/rest/video/conferences/get.mdx new file mode 100644 index 000000000..af25d35af --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/conferences/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/video/conferences/get +description: Retrieve a single video conference. +max-toc-depth: 3 +--- + +Retrieve a single video conference by its unique identifier. + +## **Parameters** + + + The unique identifier of the conference. + + +## **Returns** + +`dict` -- The conference resource. + +## **Example** + +```php {9-9} +video->conferences->get("conference-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/conferences/index.mdx b/fern/products/sdks/pages/reference/php/rest/video/conferences/index.mdx new file mode 100644 index 000000000..f967967ad --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/conferences/index.mdx @@ -0,0 +1,65 @@ +--- +title: "VideoConferences" +slug: /reference/php/rest/video/conferences +description: Video conference CRUD with token and stream management. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/video/conferences/list +[create]: /docs/sdks/reference/php/rest/video/conferences/create +[get]: /docs/sdks/reference/php/rest/video/conferences/get +[update]: /docs/sdks/reference/php/rest/video/conferences/update +[delete]: /docs/sdks/reference/php/rest/video/conferences/delete +[listconferencetokens]: /docs/sdks/reference/php/rest/video/conferences/list-conference-tokens +[liststreams]: /docs/sdks/reference/php/rest/video/conferences/list-streams +[createstream]: /docs/sdks/reference/php/rest/video/conferences/create-stream + +Manage video conferences with full CRUD operations, token listing, and stream +management. Uses PUT for updates (full replacement). + +Access via `client.video.conferences` on a [`RestClient`][restclient] instance. + +```php +video->conferences->list(); + + +``` + +## **Methods** + + + + List video conferences. + + + Create a new video conference. + + + Retrieve a single video conference. + + + Replace a video conference using PUT. + + + Delete a video conference. + + + List tokens associated with a conference. + + + List active streams for a conference. + + + Create a new stream for a conference. + + diff --git a/fern/products/sdks/pages/reference/php/rest/video/conferences/list-conference-tokens.mdx b/fern/products/sdks/pages/reference/php/rest/video/conferences/list-conference-tokens.mdx new file mode 100644 index 000000000..7b955cd84 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/conferences/list-conference-tokens.mdx @@ -0,0 +1,37 @@ +--- +title: "listConferenceTokens" +slug: /reference/php/rest/video/conferences/list-conference-tokens +description: List tokens associated with a conference. +max-toc-depth: 3 +--- + +List tokens associated with a conference. + +## **Parameters** + + + The unique identifier of the conference. + + +Additional keyword arguments are passed as query parameters for filtering. + +## **Returns** + +`dict` -- List of conference tokens. + +## **Example** + +```php {9-9} +video->conferences->list_conference_tokens("conference-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/conferences/list-streams.mdx b/fern/products/sdks/pages/reference/php/rest/video/conferences/list-streams.mdx new file mode 100644 index 000000000..afd3a35c9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/conferences/list-streams.mdx @@ -0,0 +1,37 @@ +--- +title: "listStreams" +slug: /reference/php/rest/video/conferences/list-streams +description: List active streams for a conference. +max-toc-depth: 3 +--- + +List active streams for a conference. + +## **Parameters** + + + The unique identifier of the conference. + + +Additional keyword arguments are passed as query parameters for filtering. + +## **Returns** + +`dict` -- List of streams in the conference. + +## **Example** + +```php {9-9} +video->conferences->list_streams("conference-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/conferences/list.mdx b/fern/products/sdks/pages/reference/php/rest/video/conferences/list.mdx new file mode 100644 index 000000000..5c8a75733 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/conferences/list.mdx @@ -0,0 +1,37 @@ +--- +title: "list" +slug: /reference/php/rest/video/conferences/list +description: List video conferences. +max-toc-depth: 3 +--- + +List video conferences in the project. + +## **Parameters** + + + Number of results per page. + + +Additional keyword arguments are passed as query parameters for filtering and pagination. + +## **Returns** + +`dict` -- Paginated response containing video conferences. + +## **Example** + +```php {9-9} +video->conferences->list(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/conferences/update.mdx b/fern/products/sdks/pages/reference/php/rest/video/conferences/update.mdx new file mode 100644 index 000000000..d6b06ce40 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/conferences/update.mdx @@ -0,0 +1,43 @@ +--- +title: "update" +slug: /reference/php/rest/video/conferences/update +description: Replace a video conference using PUT. +max-toc-depth: 3 +--- + +Replace a video conference. Uses PUT for full replacement, so all fields must be +provided in the request body. + + +This method performs a full replacement (PUT), not a partial update (PATCH). +Include all fields you want to keep in the request body. + + +## **Parameters** + + + The unique identifier of the conference. + + +Additional keyword arguments are the full replacement body. + +## **Returns** + +`dict` -- The updated conference. + +## **Example** + +```php {9-9} +video->conferences->update("conference-id", name: "team-meeting-v2"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/index.mdx b/fern/products/sdks/pages/reference/php/rest/video/index.mdx new file mode 100644 index 000000000..84ccf0eb9 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/index.mdx @@ -0,0 +1,63 @@ +--- +title: "Video" +slug: /reference/php/rest/video +description: Manage video rooms, conferences, sessions, recordings, tokens, and streams. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[rooms]: /docs/sdks/reference/php/rest/video/rooms +[room-tokens]: /docs/sdks/reference/php/rest/video/room-tokens +[room-sessions]: /docs/sdks/reference/php/rest/video/room-sessions +[room-recordings]: /docs/sdks/reference/php/rest/video/room-recordings +[conferences]: /docs/sdks/reference/php/rest/video/conferences +[conference-tokens]: /docs/sdks/reference/php/rest/video/conference-tokens +[streams]: /docs/sdks/reference/php/rest/video/streams + +The `VideoNamespace` provides access to SignalWire's video infrastructure through the +[`RestClient`][restclient]. It organizes 7 sub-resources +for managing video rooms, room tokens, room sessions, room recordings, conferences, +conference tokens, and streams. + +Access via `client.video` on a [`RestClient`][restclient] instance. + +```php +video->rooms->list(); + + +``` + +## **Sub-resources** + + + + Video room CRUD with stream management. + + + Generate tokens to authorize participants to join rooms. + + + Query room session history with events, members, and recordings. + + + Manage room recordings with event history. + + + Conference CRUD with token and stream management. + + + Retrieve and reset video conference tokens. + + + Top-level stream get, update, and delete. + + diff --git a/fern/products/sdks/pages/reference/php/rest/video/room-recordings/delete.mdx b/fern/products/sdks/pages/reference/php/rest/video/room-recordings/delete.mdx new file mode 100644 index 000000000..06a443e81 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/room-recordings/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/video/room-recordings/delete +description: Delete a room recording. +max-toc-depth: 3 +--- + +Delete a room recording. + +## **Parameters** + + + The unique identifier of the recording to delete. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +video->room_recordings->delete("recording-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/room-recordings/get.mdx b/fern/products/sdks/pages/reference/php/rest/video/room-recordings/get.mdx new file mode 100644 index 000000000..69efa1c95 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/room-recordings/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/video/room-recordings/get +description: Retrieve a single room recording. +max-toc-depth: 3 +--- + +Retrieve a single room recording by its unique identifier. + +## **Parameters** + + + The unique identifier of the recording. + + +## **Returns** + +`dict` -- The room recording resource, including download URL and metadata. + +## **Example** + +```php {9-9} +video->room_recordings->get("recording-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/room-recordings/index.mdx b/fern/products/sdks/pages/reference/php/rest/video/room-recordings/index.mdx new file mode 100644 index 000000000..78a94afa5 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/room-recordings/index.mdx @@ -0,0 +1,49 @@ +--- +title: "VideoRoomRecordings" +slug: /reference/php/rest/video/room-recordings +description: Manage video room recordings with event history. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/video/room-recordings/list +[get]: /docs/sdks/reference/php/rest/video/room-recordings/get +[delete]: /docs/sdks/reference/php/rest/video/room-recordings/delete +[listevents]: /docs/sdks/reference/php/rest/video/room-recordings/list-events + +Manage video room recordings. Supports listing, retrieval, deletion, and +querying recording-level events. + +Access via `client.video.room_recordings` on a [`RestClient`][restclient] instance. + +```php +video->room_recordings->list(); + + +``` + +## **Methods** + + + + List video room recordings. + + + Retrieve a single room recording. + + + Delete a room recording. + + + List events associated with a recording. + + diff --git a/fern/products/sdks/pages/reference/php/rest/video/room-recordings/list-events.mdx b/fern/products/sdks/pages/reference/php/rest/video/room-recordings/list-events.mdx new file mode 100644 index 000000000..32e60ef96 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/room-recordings/list-events.mdx @@ -0,0 +1,38 @@ +--- +title: "listEvents" +slug: /reference/php/rest/video/room-recordings/list-events +description: List events associated with a recording. +max-toc-depth: 3 +--- + +List events associated with a recording (e.g., recording started, paused, +completed). + +## **Parameters** + + + The unique identifier of the recording. + + +Additional keyword arguments are passed as query parameters for filtering. + +## **Returns** + +`dict` -- Paginated list of recording events. + +## **Example** + +```php {9-9} +video->room_recordings->list_events("recording-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/room-recordings/list.mdx b/fern/products/sdks/pages/reference/php/rest/video/room-recordings/list.mdx new file mode 100644 index 000000000..d58b8d951 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/room-recordings/list.mdx @@ -0,0 +1,37 @@ +--- +title: "list" +slug: /reference/php/rest/video/room-recordings/list +description: List video room recordings. +max-toc-depth: 3 +--- + +List video room recordings. + +## **Parameters** + + + Number of results per page. + + +Additional keyword arguments are passed as query parameters for filtering and pagination. + +## **Returns** + +`dict` -- Paginated response containing room recordings. + +## **Example** + +```php {9-9} +video->room_recordings->list(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/room-sessions/get.mdx b/fern/products/sdks/pages/reference/php/rest/video/room-sessions/get.mdx new file mode 100644 index 000000000..b818a1f30 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/room-sessions/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/video/room-sessions/get +description: Retrieve a single room session. +max-toc-depth: 3 +--- + +Retrieve a single room session by its unique identifier. + +## **Parameters** + + + The unique identifier of the room session. + + +## **Returns** + +`dict` -- The room session resource. + +## **Example** + +```php {9-9} +video->room_sessions->get("session-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/room-sessions/index.mdx b/fern/products/sdks/pages/reference/php/rest/video/room-sessions/index.mdx new file mode 100644 index 000000000..d54dce87f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/room-sessions/index.mdx @@ -0,0 +1,53 @@ +--- +title: "VideoRoomSessions" +slug: /reference/php/rest/video/room-sessions +description: Query video room sessions with events, members, and recordings. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/video/room-sessions/list +[get]: /docs/sdks/reference/php/rest/video/room-sessions/get +[listevents]: /docs/sdks/reference/php/rest/video/room-sessions/list-events +[listmembers]: /docs/sdks/reference/php/rest/video/room-sessions/list-members +[listrecordings]: /docs/sdks/reference/php/rest/video/room-sessions/list-recordings + +Query video room sessions and their associated events, members, and recordings. +Sessions represent the period during which a room is active with participants. + +Access via `client.video.room_sessions` on a [`RestClient`][restclient] instance. + +```php +video->room_sessions->list(); + + +``` + +## **Methods** + + + + List video room sessions. + + + Retrieve a single room session. + + + List events that occurred during a room session. + + + List members who joined a room session. + + + List recordings created during a room session. + + diff --git a/fern/products/sdks/pages/reference/php/rest/video/room-sessions/list-events.mdx b/fern/products/sdks/pages/reference/php/rest/video/room-sessions/list-events.mdx new file mode 100644 index 000000000..b15b8944b --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/room-sessions/list-events.mdx @@ -0,0 +1,38 @@ +--- +title: "listEvents" +slug: /reference/php/rest/video/room-sessions/list-events +description: List events that occurred during a room session. +max-toc-depth: 3 +--- + +List events that occurred during a room session (e.g., participant joins, +leaves, audio/video mute changes). + +## **Parameters** + + + The unique identifier of the room session. + + +Additional keyword arguments are passed as query parameters for filtering. + +## **Returns** + +`dict` -- Paginated list of session events. + +## **Example** + +```php {9-9} +video->room_sessions->list_events("session-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/room-sessions/list-members.mdx b/fern/products/sdks/pages/reference/php/rest/video/room-sessions/list-members.mdx new file mode 100644 index 000000000..376acfdba --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/room-sessions/list-members.mdx @@ -0,0 +1,37 @@ +--- +title: "listMembers" +slug: /reference/php/rest/video/room-sessions/list-members +description: List members who joined a room session. +max-toc-depth: 3 +--- + +List members (participants) who joined the room during a session. + +## **Parameters** + + + The unique identifier of the room session. + + +Additional keyword arguments are passed as query parameters for filtering. + +## **Returns** + +`dict` -- Paginated list of session members. + +## **Example** + +```php {9-9} +video->room_sessions->list_members("session-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/room-sessions/list-recordings.mdx b/fern/products/sdks/pages/reference/php/rest/video/room-sessions/list-recordings.mdx new file mode 100644 index 000000000..b6f66cf24 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/room-sessions/list-recordings.mdx @@ -0,0 +1,37 @@ +--- +title: "listRecordings" +slug: /reference/php/rest/video/room-sessions/list-recordings +description: List recordings created during a room session. +max-toc-depth: 3 +--- + +List recordings created during a room session. + +## **Parameters** + + + The unique identifier of the room session. + + +Additional keyword arguments are passed as query parameters for filtering. + +## **Returns** + +`dict` -- Paginated list of session recordings. + +## **Example** + +```php {9-9} +video->room_sessions->list_recordings("session-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/room-sessions/list.mdx b/fern/products/sdks/pages/reference/php/rest/video/room-sessions/list.mdx new file mode 100644 index 000000000..e5354f225 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/room-sessions/list.mdx @@ -0,0 +1,37 @@ +--- +title: "list" +slug: /reference/php/rest/video/room-sessions/list +description: List video room sessions. +max-toc-depth: 3 +--- + +List video room sessions. + +## **Parameters** + + + Number of results per page. + + +Additional keyword arguments are passed as query parameters for filtering and pagination. + +## **Returns** + +`dict` -- Paginated response containing room sessions. + +## **Example** + +```php {9-9} +video->room_sessions->list(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/room-tokens/create.mdx b/fern/products/sdks/pages/reference/php/rest/video/room-tokens/create.mdx new file mode 100644 index 000000000..74885c095 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/room-tokens/create.mdx @@ -0,0 +1,63 @@ +--- +title: "create" +slug: /reference/php/rest/video/room-tokens/create +description: "Create a room token that a participant uses to connect to a video room." +max-toc-depth: 3 +--- + +Create a room token that a participant uses to connect to a video room. The token +encodes the room name, user identity, and granted permissions. + +## **Parameters** + + + The name of the room to join. + + + + The display name of the participant. + + + + List of permissions to grant. + + - `"room.self.audio_mute"` -- allow the participant to mute their own audio + - `"room.self.audio_unmute"` -- allow the participant to unmute their own audio + - `"room.self.video_mute"` -- allow the participant to turn off their own video + - `"room.self.video_unmute"` -- allow the participant to turn on their own video + - `"room.list_available_layouts"` -- allow the participant to list available room layouts + - `"room.set_layout"` -- allow the participant to change the room layout + + +Additional keyword arguments define the token configuration (expiration, metadata, etc.). + +## **Returns** + +`dict` -- The created token, including the JWT string. + +## **Example** + +```php {9} +video->room_tokens->create( + room_name: "standup", + user_name: "Alice", + permissions: [ + "room.self.audio_mute", + "room.self.audio_unmute", + "room.self.video_mute", + "room.self.video_unmute", + ] +); +echo $token["token"]; + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/room-tokens/index.mdx b/fern/products/sdks/pages/reference/php/rest/video/room-tokens/index.mdx new file mode 100644 index 000000000..9aa8f9a42 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/room-tokens/index.mdx @@ -0,0 +1,22 @@ +--- +title: "VideoRoomTokens" +slug: /reference/php/rest/video/room-tokens +description: Generate tokens to authorize participants to join video rooms. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[create]: /docs/sdks/reference/php/rest/video/room-tokens/create + +Generate tokens that authorize participants to join a video room. Each token +encodes the room name, user identity, and granted permissions. + +Access via `client.video.room_tokens` on a [`RestClient`][restclient] instance. + +## **Methods** + + + + Create a room token that a participant uses to connect to a video room. + + diff --git a/fern/products/sdks/pages/reference/php/rest/video/rooms/create-stream.mdx b/fern/products/sdks/pages/reference/php/rest/video/rooms/create-stream.mdx new file mode 100644 index 000000000..1228f2c2f --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/rooms/create-stream.mdx @@ -0,0 +1,45 @@ +--- +title: "createStream" +slug: /reference/php/rest/video/rooms/create-stream +description: Create a new stream for a video room. +max-toc-depth: 3 +--- + +Create a new stream for a video room, enabling external streaming output +(e.g., RTMP to a streaming platform). + +## **Parameters** + + + The unique identifier of the video room. + + + + The streaming destination URL (e.g., an RTMP endpoint). + + +Additional keyword arguments define the stream configuration. + +## **Returns** + +`dict` -- The created stream resource. + +## **Example** + +```php {9} +video->rooms->create_stream( + "room-id", + url: "rtmp://live.example.com/stream-key" +); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/rooms/create.mdx b/fern/products/sdks/pages/reference/php/rest/video/rooms/create.mdx new file mode 100644 index 000000000..2f327ee35 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/rooms/create.mdx @@ -0,0 +1,41 @@ +--- +title: "create" +slug: /reference/php/rest/video/rooms/create +description: Create a new video room. +max-toc-depth: 3 +--- + +Create a new video room. + +## **Parameters** + + + The name of the video room. + + + + Maximum number of participants allowed in the room. + + +Additional keyword arguments are passed to the API as the request body. + +## **Returns** + +`dict` -- The created video room. + +## **Example** + +```php {9-9} +video->rooms->create(name: "standup", max_participants: 10); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/rooms/delete.mdx b/fern/products/sdks/pages/reference/php/rest/video/rooms/delete.mdx new file mode 100644 index 000000000..8d6038aa8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/rooms/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/video/rooms/delete +description: Delete a video room. +max-toc-depth: 3 +--- + +Delete a video room. + +## **Parameters** + + + The unique identifier of the video room. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +video->rooms->delete("room-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/rooms/get.mdx b/fern/products/sdks/pages/reference/php/rest/video/rooms/get.mdx new file mode 100644 index 000000000..a1fc11fa2 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/rooms/get.mdx @@ -0,0 +1,35 @@ +--- +title: "get" +slug: /reference/php/rest/video/rooms/get +description: Retrieve a single video room. +max-toc-depth: 3 +--- + +Retrieve a single video room by its unique identifier. + +## **Parameters** + + + The unique identifier of the video room. + + +## **Returns** + +`dict` -- The video room resource. + +## **Example** + +```php {9-9} +video->rooms->get("room-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/rooms/index.mdx b/fern/products/sdks/pages/reference/php/rest/video/rooms/index.mdx new file mode 100644 index 000000000..0f1b10674 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/rooms/index.mdx @@ -0,0 +1,61 @@ +--- +title: "VideoRooms" +slug: /reference/php/rest/video/rooms +description: Video room CRUD operations with stream management. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[list]: /docs/sdks/reference/php/rest/video/rooms/list +[create]: /docs/sdks/reference/php/rest/video/rooms/create +[get]: /docs/sdks/reference/php/rest/video/rooms/get +[update]: /docs/sdks/reference/php/rest/video/rooms/update +[delete]: /docs/sdks/reference/php/rest/video/rooms/delete +[liststreams]: /docs/sdks/reference/php/rest/video/rooms/list-streams +[createstream]: /docs/sdks/reference/php/rest/video/rooms/create-stream + +Manage video rooms with full CRUD operations and stream management. Uses PUT +for updates (full replacement). + +Access via `client.video.rooms` on a [`RestClient`][restclient] instance. + +```php +video->rooms->list(); + + +``` + +## **Methods** + + + + List video rooms in the project. + + + Create a new video room. + + + Retrieve a single video room. + + + Replace a video room using PUT. + + + Delete a video room. + + + List active streams for a video room. + + + Create a new stream for a video room. + + diff --git a/fern/products/sdks/pages/reference/php/rest/video/rooms/list-streams.mdx b/fern/products/sdks/pages/reference/php/rest/video/rooms/list-streams.mdx new file mode 100644 index 000000000..abbb701a1 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/rooms/list-streams.mdx @@ -0,0 +1,37 @@ +--- +title: "listStreams" +slug: /reference/php/rest/video/rooms/list-streams +description: List active streams for a video room. +max-toc-depth: 3 +--- + +List active streams for a video room. + +## **Parameters** + + + The unique identifier of the video room. + + +Additional keyword arguments are passed as query parameters for filtering. + +## **Returns** + +`dict` -- List of streams in the room. + +## **Example** + +```php {9-9} +video->rooms->list_streams("room-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/rooms/list.mdx b/fern/products/sdks/pages/reference/php/rest/video/rooms/list.mdx new file mode 100644 index 000000000..8fc60a9e8 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/rooms/list.mdx @@ -0,0 +1,37 @@ +--- +title: "list" +slug: /reference/php/rest/video/rooms/list +description: List video rooms in the project. +max-toc-depth: 3 +--- + +List video rooms in the project. + +## **Parameters** + + + Number of results per page. + + +Additional keyword arguments are passed as query parameters for filtering and pagination. + +## **Returns** + +`dict` -- Paginated response containing video rooms. + +## **Example** + +```php {9-9} +video->rooms->list(); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/rooms/update.mdx b/fern/products/sdks/pages/reference/php/rest/video/rooms/update.mdx new file mode 100644 index 000000000..8c2637770 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/rooms/update.mdx @@ -0,0 +1,43 @@ +--- +title: "update" +slug: /reference/php/rest/video/rooms/update +description: Replace a video room using PUT. +max-toc-depth: 3 +--- + +Replace a video room. Uses PUT for full replacement, so all fields must be +provided in the request body. + + +This method performs a full replacement (PUT), not a partial update (PATCH). +Include all fields you want to keep in the request body. + + +## **Parameters** + + + The unique identifier of the video room. + + +Additional keyword arguments are the full replacement body. + +## **Returns** + +`dict` -- The updated video room. + +## **Example** + +```php {9-9} +video->rooms->update("room-id", name: "standup-v2", max_participants: 20); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/streams/delete.mdx b/fern/products/sdks/pages/reference/php/rest/video/streams/delete.mdx new file mode 100644 index 000000000..4af948f50 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/streams/delete.mdx @@ -0,0 +1,35 @@ +--- +title: "delete" +slug: /reference/php/rest/video/streams/delete +description: Delete a stream. +max-toc-depth: 3 +--- + +Delete a stream. + +## **Parameters** + + + The unique identifier of the stream to delete. + + +## **Returns** + +`dict` -- Empty dict on success. + +## **Example** + +```php {9-9} +video->streams->delete("stream-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/streams/get.mdx b/fern/products/sdks/pages/reference/php/rest/video/streams/get.mdx new file mode 100644 index 000000000..ea0b31f11 --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/streams/get.mdx @@ -0,0 +1,36 @@ +--- +title: "get" +slug: /reference/php/rest/video/streams/get +description: Retrieve a specific stream. +max-toc-depth: 3 +--- + +Retrieve a specific stream by its unique identifier, regardless of which room +or conference it belongs to. + +## **Parameters** + + + The unique identifier of the stream. + + +## **Returns** + +`dict` -- The stream resource. + +## **Example** + +```php {9-9} +video->streams->get("stream-id"); + + +``` diff --git a/fern/products/sdks/pages/reference/php/rest/video/streams/index.mdx b/fern/products/sdks/pages/reference/php/rest/video/streams/index.mdx new file mode 100644 index 000000000..98534290a --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/streams/index.mdx @@ -0,0 +1,45 @@ +--- +title: "VideoStreams" +slug: /reference/php/rest/video/streams +description: Top-level stream management for get, update, and delete. +max-toc-depth: 3 +--- + +[restclient]: /docs/sdks/reference/php/rest/client +[get]: /docs/sdks/reference/php/rest/video/streams/get +[update]: /docs/sdks/reference/php/rest/video/streams/update +[delete]: /docs/sdks/reference/php/rest/video/streams/delete + +Top-level stream management for retrieving, updating, and deleting individual +streams regardless of which room or conference they belong to. + +Access via `client.video.streams` on a [`RestClient`][restclient] instance. + +```php +video->streams->get("stream-id"); + + +``` + +## **Methods** + + + + Retrieve a specific stream. + + + Update a stream using PUT. + + + Delete a stream. + + diff --git a/fern/products/sdks/pages/reference/php/rest/video/streams/update.mdx b/fern/products/sdks/pages/reference/php/rest/video/streams/update.mdx new file mode 100644 index 000000000..3c61750ec --- /dev/null +++ b/fern/products/sdks/pages/reference/php/rest/video/streams/update.mdx @@ -0,0 +1,46 @@ +--- +title: "update" +slug: /reference/php/rest/video/streams/update +description: Update a stream using PUT. +max-toc-depth: 3 +--- + +Update a stream. Uses PUT for full replacement, so all fields must be provided +in the request body. + + +This method performs a full replacement (PUT), not a partial update (PATCH). +Include all fields you want to keep in the request body. + + +## **Parameters** + + + The unique identifier of the stream. + + +Additional keyword arguments are the full replacement body. + +## **Returns** + +`dict` -- The updated stream. + +## **Example** + +```php {9} +video->streams->update( + "stream-id", + url: "rtmp://new-destination.example.com/key" +); + + +``` diff --git a/fern/products/sdks/pages/reference/python/agents/agent-base/auto-map-sip-usernames.mdx b/fern/products/sdks/pages/reference/python/agents/agent-base/auto-map-sip-usernames.mdx deleted file mode 100644 index a914696c4..000000000 --- a/fern/products/sdks/pages/reference/python/agents/agent-base/auto-map-sip-usernames.mdx +++ /dev/null @@ -1,56 +0,0 @@ ---- -title: "auto_map_sip_usernames" -slug: /reference/python/agents/agent-base/auto-map-sip-usernames -description: Automatically register common SIP usernames derived from the agent's name and route. -max-toc-depth: 3 ---- - -[ref-agentbase]: /docs/sdks/reference/python/agents/agent-base -[enable-sip-routing]: /docs/sdks/reference/python/agents/agent-base/enable-sip-routing -[register-sip-username]: /docs/sdks/reference/python/agents/agent-base/register-sip-username - -Automatically register SIP usernames based on the agent's `name` and `route` -properties. This is a convenience method that derives common username variations -so callers can reach the agent via SIP without manual registration. - -The method registers: -- A lowercase, alphanumeric version of the agent name (e.g., `"support"`) -- A lowercase, alphanumeric version of the route (e.g., `"sales"`) -- A consonant-only abbreviation of the name when it is longer than 3 characters - - -[`enable_sip_routing()`][enable-sip-routing] -calls this method automatically when `auto_map=True` (the default). You only need -to call `auto_map_sip_usernames()` directly if you disabled auto-mapping and want -to trigger it later. - - -## **Parameters** - -None. - -## **Returns** - -[`AgentBase`][ref-agentbase] -- Returns self for method chaining. - -## **Example** - -```python {6} -from signalwire import AgentBase - -agent = AgentBase(name="Support Agent", route="/support") -agent.set_prompt_text("You are a support assistant.") -agent.enable_sip_routing(auto_map=False) -agent.auto_map_sip_usernames() -# Registers: "supportagent", "support", "spprtgnt" -agent.serve() -``` - -To register specific usernames instead, use -[`register_sip_username()`][register-sip-username]: - -```python -agent.enable_sip_routing(auto_map=False) -agent.register_sip_username("helpdesk") -agent.register_sip_username("support") -``` diff --git a/fern/products/sdks/pages/reference/python/agents/agent-base/define-contexts.mdx b/fern/products/sdks/pages/reference/python/agents/agent-base/define-contexts.mdx index 4ca828337..9cbcb9418 100644 --- a/fern/products/sdks/pages/reference/python/agents/agent-base/define-contexts.mdx +++ b/fern/products/sdks/pages/reference/python/agents/agent-base/define-contexts.mdx @@ -44,11 +44,21 @@ with no arguments. from signalwire import AgentBase agent = AgentBase(name="intake", route="/intake") -ctx = agent.define_contexts() -default = ctx.add_context("default") -default.add_step("greeting").set_text("Greet the caller and ask for their name.").set_step_criteria("The caller has provided their name.").set_functions(["lookup_account"]).set_valid_steps(["verify"]) -default.add_step("verify").set_text("Verify the caller's identity.").set_step_criteria("Identity verified.").set_valid_steps(["assist"]) -default.add_step("assist").set_text("Help the caller with their request.").set_functions(["search_orders", "process_return"]) +(agent.define_contexts() + .add_context("default") + .add_step("greeting") + .set_text("Greet the caller and ask for their name.") + .set_step_criteria("The caller has provided their name.") + .set_functions(["lookup_account"]) + .set_valid_steps(["verify"]) + .add_step("verify") + .set_text("Verify the caller's identity.") + .set_step_criteria("Identity verified.") + .set_valid_steps(["assist"]) + .add_step("assist") + .set_text("Help the caller with their request.") + .set_functions(["search_orders", "process_return"]) +) agent.serve() ``` diff --git a/fern/products/sdks/pages/reference/python/agents/agent-base/define-tools.mdx b/fern/products/sdks/pages/reference/python/agents/agent-base/define-tools.mdx deleted file mode 100644 index c21d2bd71..000000000 --- a/fern/products/sdks/pages/reference/python/agents/agent-base/define-tools.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: "define_tools" -slug: /reference/python/agents/agent-base/define-tools -description: Override hook that returns the list of SWAIG tools available to the AI. -max-toc-depth: 3 ---- - -[define-tool]: /docs/sdks/reference/python/agents/agent-base/define-tool -[tool-decorator]: /docs/sdks/reference/python/agents/agent-base#tool -[register-swaig-function]: /docs/sdks/reference/python/agents/agent-base/register-swaig-function - -Returns the list of SWAIG functions registered on this agent. The default -implementation collects all tools added via -[`define_tool()`][define-tool], -the [`@tool` decorator][tool-decorator], or -[`register_swaig_function()`][register-swaig-function]. - -Override this method in a subclass to dynamically filter, reorder, or inject -tools at SWML generation time. - - -In most cases you do not need to override this method. Use -[`define_tool()`][define-tool] or the -[`@tool` decorator][tool-decorator] to register -tools instead. - - -## **Parameters** - -None. - -## **Returns** - -`list[SWAIGFunction | dict]` -- List of `SWAIGFunction` objects and/or raw -dictionaries (for DataMap-based tools). - -## **Example** - -```python {14-19} -from signalwire import AgentBase -from signalwire.core.function_result import FunctionResult - -class FilteredAgent(AgentBase): - def __init__(self): - super().__init__(name="filtered", route="/filtered") - self.set_prompt_text("You are a helpful assistant.") - self._disabled_tools = set() - - @AgentBase.tool(description="Check the weather") - def check_weather(self, args, raw_data=None): - return FunctionResult("It's sunny and 72F.") - - def define_tools(self): - """Filter out any disabled tools before SWML generation.""" - all_tools = super().define_tools() - return [ - t for t in all_tools - if getattr(t, 'name', None) not in self._disabled_tools - ] - -agent = FilteredAgent() -agent.run() -``` diff --git a/fern/products/sdks/pages/reference/python/agents/agent-base/enable-debug-routes.mdx b/fern/products/sdks/pages/reference/python/agents/agent-base/enable-debug-routes.mdx deleted file mode 100644 index b2c6b98e0..000000000 --- a/fern/products/sdks/pages/reference/python/agents/agent-base/enable-debug-routes.mdx +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: "enable_debug_routes" -slug: /reference/python/agents/agent-base/enable-debug-routes -description: Enable debug and testing routes on the agent's HTTP server. -max-toc-depth: 3 ---- - -[ref-agentbase]: /docs/sdks/reference/python/agents/agent-base - -Enable debug routes on the agent's FastAPI server for development and testing. -Debug routes are registered automatically during route setup; this method exists -as an explicit opt-in for backward compatibility. - -## **Parameters** - -None. - -## **Returns** - -[`AgentBase`][ref-agentbase] -- Returns self for method chaining. - -## **Example** - -```python {5} -from signalwire import AgentBase - -agent = AgentBase(name="dev-agent", route="/dev") -agent.set_prompt_text("You are a helpful assistant.") -agent.enable_debug_routes() -agent.serve() -``` diff --git a/fern/products/sdks/pages/reference/python/agents/agent-base/index.mdx b/fern/products/sdks/pages/reference/python/agents/agent-base/index.mdx index d4771460e..2859c21e5 100644 --- a/fern/products/sdks/pages/reference/python/agents/agent-base/index.mdx +++ b/fern/products/sdks/pages/reference/python/agents/agent-base/index.mdx @@ -77,11 +77,6 @@ max-toc-depth: 3 [setwebhookurl]: /docs/sdks/reference/python/agents/agent-base/set-web-hook-url [updateglobaldata]: /docs/sdks/reference/python/agents/agent-base/update-global-data [validatebasicauth]: /docs/sdks/reference/python/agents/agent-base/validate-basic-auth -[automapsipusernames]: /docs/sdks/reference/python/agents/agent-base/auto-map-sip-usernames -[definetools]: /docs/sdks/reference/python/agents/agent-base/define-tools -[enabledebugroutes]: /docs/sdks/reference/python/agents/agent-base/enable-debug-routes -[onfunctioncall]: /docs/sdks/reference/python/agents/agent-base/on-function-call -[onswmlrequest]: /docs/sdks/reference/python/agents/agent-base/on-swml-request [ref-datamap]: /docs/sdks/reference/python/agents/data-map `AgentBase` is the central class in the SignalWire AI Agents SDK. It provides a @@ -423,9 +418,6 @@ agent.run() Get the agent's endpoints as a FastAPI APIRouter for mounting in larger applications. - - Automatically register SIP usernames derived from the agent's name and route. - Remove all post-AI verbs from the call flow. @@ -444,15 +436,9 @@ agent.run() Programmatically define a SWAIG tool that the AI can invoke during conversations. - - Override hook that returns the list of SWAIG tools available to the AI. - Enable real-time debug event webhooks from the AI module during calls. - - Enable debug and testing routes on the agent's HTTP server. - Expose the agent's tools as an MCP server endpoint. @@ -492,15 +478,9 @@ agent.run() Register a callback for debug events received at the /debug_events endpoint. - - Override hook called when a SWAIG function is invoked during a conversation. - Handle post-prompt summaries generated after a conversation ends. - - Override hook for customizing the SWML document on a per-request basis. - Add a new section to the agent's structured prompt. diff --git a/fern/products/sdks/pages/reference/python/agents/agent-base/on-function-call.mdx b/fern/products/sdks/pages/reference/python/agents/agent-base/on-function-call.mdx deleted file mode 100644 index a81a1104b..000000000 --- a/fern/products/sdks/pages/reference/python/agents/agent-base/on-function-call.mdx +++ /dev/null @@ -1,69 +0,0 @@ ---- -title: "on_function_call" -slug: /reference/python/agents/agent-base/on-function-call -description: Override hook called when a SWAIG function is invoked during a conversation. -max-toc-depth: 3 ---- - -[functionresult]: /docs/sdks/reference/python/agents/function-result -[define-tool]: /docs/sdks/reference/python/agents/agent-base/define-tool -[tool-decorator]: /docs/sdks/reference/python/agents/agent-base#tool - -Called when the SignalWire platform invokes a SWAIG function on this agent. -The default implementation looks up the function in the tool registry and -executes it. Override this method in a subclass to intercept tool calls -for logging, metrics, pre/post-processing, or custom dispatch logic. - - -Most agents do not need to override this method. The default implementation -handles function lookup, argument validation, and execution automatically. -Token verification occurs upstream in the HTTP handler before this method is -called. Override only when you need cross-cutting behavior across all tool calls. - - -## **Parameters** - - - The name of the SWAIG function being invoked. - - - - Arguments passed by the AI, conforming to the function's parameter schema. - - - - The complete raw POST data from the SWAIG request, including metadata such as - `call_id`, `caller_id_number`, and `global_data`. - - -## **Returns** - -[`FunctionResult`][functionresult] or `dict` -- The tool's response. The default -implementation returns the result of executing the registered handler. - -## **Example** - -```python {14-19} -from signalwire import AgentBase -from signalwire.core.function_result import FunctionResult - -class LoggingAgent(AgentBase): - def __init__(self): - super().__init__(name="logging-agent", route="/logging") - self.set_prompt_text("You are a helpful assistant.") - - @AgentBase.tool(description="Look up an order") - def lookup_order(self, args, raw_data=None): - order_id = args.get("order_id") - return FunctionResult(f"Order {order_id} is in transit.") - - def on_function_call(self, name, args, raw_data=None): - call_id = raw_data.get("call_id", "unknown") if raw_data else "unknown" - print(f"[{call_id}] Tool called: {name}({args})") - result = super().on_function_call(name, args, raw_data) - print(f"[{call_id}] Tool result: {result}") - return result - -agent = LoggingAgent() -agent.run() -``` diff --git a/fern/products/sdks/pages/reference/python/agents/agent-base/on-swml-request.mdx b/fern/products/sdks/pages/reference/python/agents/agent-base/on-swml-request.mdx deleted file mode 100644 index 4fc586928..000000000 --- a/fern/products/sdks/pages/reference/python/agents/agent-base/on-swml-request.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: "on_swml_request" -slug: /reference/python/agents/agent-base/on-swml-request -description: Override hook for customizing the SWML document on a per-request basis. -max-toc-depth: 3 ---- - -[set-dynamic-config-callback]: /docs/sdks/reference/python/agents/agent-base/set-dynamic-config-callback -[on-request-swml]: /docs/sdks/reference/python/agents/swml-service/on-request - -Customization point called during SWML rendering, before the document is -returned to the caller. Override this method in a subclass to inspect request -data and return modifications to apply to the SWML document. - -The default implementation checks for a -[`set_dynamic_config_callback()`][set-dynamic-config-callback] -and, if one is registered, returns an internal marker that triggers ephemeral -agent cloning. For most per-request customization, -[`set_dynamic_config_callback()`][set-dynamic-config-callback] -is the simpler approach. - - -This is the AgentBase-specific override of the lower-level -[`SWMLService.on_request()`][on-request-swml]. It adds -support for dynamic configuration and ephemeral agent copies. - - -## **Parameters** - - - Parsed POST body from the incoming request, if available. - - - - The path segment that triggered this request. - - - - The FastAPI `Request` object, providing access to query parameters, headers, - and other HTTP metadata. - - -## **Returns** - -`Optional[dict]` -- A dictionary of modifications to apply to the SWML document, -or `None` for no modifications. The keys and structure depend on the rendering -pipeline. - -## **Example** - -```python {10-17} -from signalwire import AgentBase - -class MultiTenantAgent(AgentBase): - def __init__(self): - super().__init__(name="multi-tenant", route="/agent") - self.set_prompt_text("You are a helpful assistant.") - - def on_swml_request(self, request_data=None, callback_path=None, request=None): - """Add custom verbs based on a request header.""" - tenant = None - if request: - tenant = request.headers.get("X-Tenant-ID") - if tenant == "premium": - # Return modifications for premium tenants - return {"__inject_verbs": [{"play": {"url": "https://example.com/premium-greeting.mp3"}}]} - return super().on_swml_request(request_data, callback_path, request) - -agent = MultiTenantAgent() -agent.run() -``` - - -For most per-request customization scenarios, prefer -[`set_dynamic_config_callback()`][set-dynamic-config-callback] -which provides a higher-level interface with access to query params, body, headers, -and the agent instance. - diff --git a/fern/products/sdks/pages/reference/python/agents/agent-base/register-swaig-function.mdx b/fern/products/sdks/pages/reference/python/agents/agent-base/register-swaig-function.mdx index ce880a595..7ef196804 100644 --- a/fern/products/sdks/pages/reference/python/agents/agent-base/register-swaig-function.mdx +++ b/fern/products/sdks/pages/reference/python/agents/agent-base/register-swaig-function.mdx @@ -32,7 +32,7 @@ server (for DataMap functions) or at an external webhook URL. ## **Example** ```python {20} -from signalwire import AgentBase, FunctionResult +from signalwire import AgentBase from signalwire.core.data_map import DataMap agent = AgentBase(name="weather-agent", route="/weather") @@ -42,9 +42,12 @@ agent.set_prompt_text("You are a helpful assistant.") weather_tool = ( DataMap("get_weather") .description("Get the current weather") - .parameter("city", param_type="string", description="City name", required=True) + .parameter("city", type="string", description="City name", required=True) .webhook("GET", "https://api.weather.example.com/current?city=${args.city}") - .output(FunctionResult("The weather in ${args.city} is ${response.temp}F.")) + .output( + response="The weather in ${args.city} is ${response.temp}F.", + action=[{"say": "Here is the weather information."}] + ) ) # Register the DataMap as a SWAIG function diff --git a/fern/products/sdks/pages/reference/python/agents/helpers.mdx b/fern/products/sdks/pages/reference/python/agents/helpers.mdx index 545f44496..05e66ad26 100644 --- a/fern/products/sdks/pages/reference/python/agents/helpers.mdx +++ b/fern/products/sdks/pages/reference/python/agents/helpers.mdx @@ -264,7 +264,7 @@ class MyWeatherSkill: register_skill(MyWeatherSkill) -agent = AgentBase(name="my-agent") +agent = AgentBase() agent.add_skill("my_weather") ``` diff --git a/fern/products/sdks/pages/reference/python/agents/livewire/plugins.mdx b/fern/products/sdks/pages/reference/python/agents/livewire/plugins.mdx index 979451273..744e0f4eb 100644 --- a/fern/products/sdks/pages/reference/python/agents/livewire/plugins.mdx +++ b/fern/products/sdks/pages/reference/python/agents/livewire/plugins.mdx @@ -142,7 +142,7 @@ tts = inference.TTS(model="cartesia/sonic") Stub for `livekit.agents.inference.STT`. ```python -from signalwire.livewire import InferenceSTT +from signalwire.livewire.plugins import InferenceSTT stt = InferenceSTT(model="deepgram/nova-2") ``` @@ -184,7 +184,7 @@ Accepts additional keyword arguments. All are ignored. Stub for `livekit.agents.inference.TTS`. ```python -from signalwire.livewire import InferenceTTS +from signalwire.livewire.plugins import InferenceTTS tts = InferenceTTS(model="cartesia/sonic") ``` diff --git a/fern/products/sdks/pages/reference/python/agents/swml-builder/index.mdx b/fern/products/sdks/pages/reference/python/agents/swml-builder/index.mdx index ccc7e4b09..7c7a54dcb 100644 --- a/fern/products/sdks/pages/reference/python/agents/swml-builder/index.mdx +++ b/fern/products/sdks/pages/reference/python/agents/swml-builder/index.mdx @@ -69,10 +69,9 @@ The `sleep` verb is a special case -- it accepts a positional `duration` argumen (milliseconds) instead of keyword arguments: ```python -from signalwire import SWMLBuilder, SWMLService +from signalwire import SWMLBuilder -service = SWMLService(name="demo") -builder = SWMLBuilder(service) +builder = SWMLBuilder() builder.add_section("main") builder.sleep(duration=2000) diff --git a/fern/products/sdks/pages/reference/python/relay/client/index.mdx b/fern/products/sdks/pages/reference/python/relay/client/index.mdx index f335019dc..42b7564e4 100644 --- a/fern/products/sdks/pages/reference/python/relay/client/index.mdx +++ b/fern/products/sdks/pages/reference/python/relay/client/index.mdx @@ -158,7 +158,8 @@ async def main(): contexts=["default"], ) as client: call = await client.dial( - devices=[[{"type": "phone", "params": {"to_number": "+15559876543", "from_number": "+15551234567"}}]] + to="+15559876543", + from_number="+15551234567", ) # Automatically disconnects on exit diff --git a/fern/products/sdks/pages/reference/python/relay/relay-error.mdx b/fern/products/sdks/pages/reference/python/relay/relay-error.mdx index 24ac2b398..5fe0bc3a4 100644 --- a/fern/products/sdks/pages/reference/python/relay/relay-error.mdx +++ b/fern/products/sdks/pages/reference/python/relay/relay-error.mdx @@ -41,7 +41,7 @@ client = RelayClient( @client.on_call async def handle_call(call): try: - await call.connect(devices=[[{"type": "phone", "params": {"to_number": "+15559876543"}}]]) + await call.connect(devices=[{"type": "phone", "params": {"to_number": "+15559876543"}}]) except RelayError as e: print(f"Error {e.code}: {e.message}") await call.hangup() diff --git a/fern/products/sdks/pages/reference/python/rest/mfa/index.mdx b/fern/products/sdks/pages/reference/python/rest/mfa/index.mdx index 7ff644499..a2259b962 100644 --- a/fern/products/sdks/pages/reference/python/rest/mfa/index.mdx +++ b/fern/products/sdks/pages/reference/python/rest/mfa/index.mdx @@ -25,7 +25,7 @@ client = RestClient( host="your-space.signalwire.com", ) -request = client.mfa.sms(**{"to": "+15551234567", "from": "+15559876543"}) +request = client.mfa.sms(to="+15551234567", from_="+15559876543") print(request["id"]) ``` diff --git a/fern/products/sdks/sdks.yml b/fern/products/sdks/sdks.yml index d4cc2f4c4..5e7c7f1b4 100644 --- a/fern/products/sdks/sdks.yml +++ b/fern/products/sdks/sdks.yml @@ -38,3 +38,19 @@ navigation: - folder: ./pages/reference/python/rest title: REST Client collapsed: false + + - title: PHP + icon: brands fa-php + layout: + - folder: ./pages/reference/core + title: Core + collapsed: false + - folder: ./pages/reference/php/agents + title: Agents + collapsed: false + - folder: ./pages/reference/php/relay + title: RELAY + collapsed: false + - folder: ./pages/reference/php/rest + title: REST Client + collapsed: false