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
      • Configuration
      • ContextBuilder
      • DataMap
        • body
        • description
        • enableEnvExpansion
        • errorKeys
        • expression
        • fallbackOutput
        • foreach
        • globalErrorKeys
        • helpers
        • output
        • parameter
        • params
        • purpose
        • registerWithAgent
        • setAllowedEnvPrefixes
        • toSwaigFunction
        • webhook
        • webhookExpressions
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • ChatResource
      • Compat
      • Datasphere
      • Fabric
      • ImportedNumbersResource
      • Logs
      • LookupResource
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSubResource
      • Queues
      • Recordings
      • Registry
      • RestClient
      • RestError
      • Short Codes
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Example
AgentsDataMap

foreach

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

globalErrorKeys

Next
Built with

Process an array from the webhook response, building a formatted string from each element.

Parameters

config
{ input_key: string; output_key: string; append: string; max?: number }Required

Configuration object with the following keys:

config.input_key
stringRequired

Key in the API response containing the array.

config.output_key
stringRequired

Variable name for the built string (reference as ${output_key} in output).

config.max
number

Maximum number of items to process.

config.append
stringRequired

Template string to append for each item. Use ${this.field} to reference fields on the current array element.

Returns

DataMap — Self for method chaining. Throws an Error if no webhook has been added yet.

Example

1import { DataMap } from '@signalwire/sdk';
2
3const dm = new DataMap('list_items');
4dm.webhook('GET', 'https://api.example.com/items');
5dm.foreach({
6 input_key: 'response.items',
7 output_key: 'item_list',
8 append: '${this.name}: ${this.price}',
9 max: 5,
10});