For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • BedrockAgent
      • CLI Tools
      • Configuration
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions
      • LiveWire
      • MCP Gateway
      • PomBuilder
      • Prefabs
      • Search
      • SkillBase
      • Skills
      • SWAIGFunction
      • SWMLBuilder
      • SWMLService
      • WebService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
        • connect
        • dial
        • disconnect
        • execute
        • receive
        • run
        • send_message
        • unreceive
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • Chat
      • Compat
      • Datasphere
      • Fabric
      • Imported Numbers
      • Logs
      • Lookup
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSub
      • Queues
      • Recordings
      • Registry
      • RestClient
      • Short Codes
      • SignalWireRestError
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Examples
  • Add contexts at runtime
  • With inbound call handler
RELAYRelayClient

receive

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

run

Next
Built with

Subscribe to additional contexts for inbound call and message events. Sends a signalwire.receive request 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 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

contexts
list[str]Required

List of context names to subscribe to. If the list is empty, the method returns immediately without sending a request.

Returns

None

Examples

Add contexts at runtime

1import asyncio
2from signalwire.relay import RelayClient
3
4client = RelayClient(
5 project="your-project-id",
6 token="your-api-token",
7 host="your-space.signalwire.com",
8 contexts=["sales"],
9)
10
11async def main():
12 async with client:
13 # Dynamically subscribe to additional contexts after connecting
14 await client.receive(["support", "billing"])
15 print("Now receiving calls on sales, support, and billing")
16
17asyncio.run(main())

With inbound call handler

1from signalwire.relay import RelayClient
2
3client = RelayClient(
4 project="your-project-id",
5 token="your-api-token",
6 host="your-space.signalwire.com",
7 contexts=["sales"],
8)
9
10@client.on_call
11async def handle_call(call):
12 print(f"Call on context: {call.context}")
13 await call.answer()
14 await call.hangup()
15
16# Subscribe to additional contexts at startup via constructor
17# For runtime subscription after connect, use await client.receive(["support"])
18client.run()