> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# getContexts

> Retrieve the agent's contexts as a serialized dictionary.

[define-contexts]: /docs/server-sdks/reference/typescript/agents/agent-base/define-contexts

Return the agent's contexts as a serialized SWML dictionary, or `null` when no
contexts have been defined via [`defineContexts()`][define-contexts].

## **Parameters**

None.

## **Returns**

`Record<string, unknown> | null` -- The serialized contexts dictionary, or
`null` when no contexts are defined.

## **Example**

```typescript {6}
import { AgentBase } from '@signalwire/sdk';

const agent = new AgentBase({ name: 'intake', route: '/intake' });
agent.defineContexts().addContext('default').addStep('greeting').setText('Hi.');

const contexts = agent.getContexts();
console.log(contexts);
```