You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the REST client to manage SignalWire resources
Running Examples
export JAVA_HOME=/home/devuser/jdk-21
GRADLE=/home/devuser/gradle/gradle-8.5/bin/gradle
# Build the SDK firstcd /home/devuser/src/signalwire-agents-java
$GRADLE jar
# Run an example (using the SDK jar + dependencies)
CP="build/libs/signalwire-agents-1.1.0.jar:$(find build -name '*.jar'| tr '\n'':')"$JAVA_HOME/bin/javac -cp "$CP" examples/SimpleAgent.java
$JAVA_HOME/bin/java -cp "$CP:examples" SimpleAgent
Environment Variables
All examples respect these environment variables:
Variable
Description
Default
PORT
HTTP server port
3000
SWML_BASIC_AUTH_USER
Override auth username
agent name
SWML_BASIC_AUTH_PASSWORD
Override auth password
auto-generated
SWML_PROXY_URL_BASE
Proxy URL for webhooks
auto-detected
SIGNALWIRE_PROJECT_ID
Project ID (RELAY/REST)
-
SIGNALWIRE_API_TOKEN
API token (RELAY/REST)
-
SIGNALWIRE_SPACE
Space hostname (RELAY/REST)
-
Some examples require additional environment variables:
Variable
Used By
Description
API_NINJAS_KEY
JokeAgent
API Ninjas API key
GOOGLE_SEARCH_API_KEY
WebSearchAgent
Google Custom Search API key
GOOGLE_SEARCH_ENGINE_ID
WebSearchAgent
Google Custom Search Engine ID
MCP_GATEWAY_URL
McpGateway
MCP gateway service URL
MCP_GATEWAY_AUTH_USER
McpGateway
MCP gateway basic auth user
MCP_GATEWAY_AUTH_PASSWORD
McpGateway
MCP gateway basic auth password
Deploying to AWS Lambda
The SDK ships a LambdaAgentHandler that translates API Gateway (v1 or
v2) and Lambda Function URL events into the same dispatch logic the
in-process HTTP server uses. See LambdaAgent.java.
Package a shaded JAR (e.g. with the Gradle Shadow plugin) that contains
the SDK and its transitive dependencies, upload it to Lambda, and set
the handler to LambdaAgent::handleLambdaRequest.
Lambda auto-populates the environment variables the SDK reads
(AWS_LAMBDA_FUNCTION_URL, AWS_LAMBDA_FUNCTION_NAME, AWS_REGION).
Set SWML_BASIC_AUTH_USER / SWML_BASIC_AUTH_PASSWORD in the Lambda
configuration so external callers can authenticate. Optionally set
SWML_PROXY_URL_BASE if you front the Lambda with a custom domain.