> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # expression > Add a pattern-based response without an API call. [ref-datamap]: /docs/server-sdks/reference/typescript/agents/data-map [ref-functionresult]: /docs/server-sdks/reference/typescript/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** **`testValue`** `string` — required Template string to test (e.g., `"${args.command}"`). --- **`pattern`** `string | RegExp` — required Regex pattern to match against the test value. --- **`output`** `FunctionResult` — required [FunctionResult][ref-functionresult] to return when the pattern matches. --- **`nomatchOutput`** `FunctionResult` Optional FunctionResult to return when the pattern does not match. --- ## **Returns** [`DataMap`][ref-datamap] -- Self for method chaining. ## **Example** ```typescript {4} import { DataMap, FunctionResult } from '@signalwire/sdk'; const dm = new DataMap('route_command'); dm.expression( '${args.command}', /play.*/, new FunctionResult('Playing file.'), new FunctionResult('Unknown command.'), ); ``` > Add a pattern-based response without an API call.