***
id: e435dca2-4270-4874-b474-7e6f521ea798
title: CallCollect
keywords: >-
SignalWire, Realtime SDK, Node.js, DTMF, digit collection, IVR, speech input,
user input
slug: /node/reference/voice/call-collect
sidebar-title: CallCollect
description: >-
CallCollect object reference for collecting user input during voice calls.
Gather DTMF digits and speech input with configurable prompts and timeouts.
max-toc-depth: 3
----------------
[callcollect]: #
[callingcallcollectresult]: #callingcallcollectresult
[result]: #properties
[type]: #properties
[voice-call]: /docs/server-sdk/v4/node/reference/voice/call/collect
Represents a current or past collect session in a call. You can obtain instances of this class by starting at Collect with the following method:
* [`Call.collect`][voice-call]
#### Example
In this example, we collect digits from the caller. Once the collect session is ended, we print the collected digits
and hangup the call.
```js
import { SignalWire } from "@signalwire/realtime-api";
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })
const voiceClient = client.voice;
const call = await voiceClient.dialPhone({
from: "+YYYYYYYYYY",
to: "+XXXXXXXXXX",
});
// start Collect
await call.collect({
partialResults: true,
sendStartOfInput: true,
digits: {
max: 5,
digitTimeout: 4,
terminators: "#*",
},
listen: {
onStarted: async () => {
console.log("Collect started");
await call.playTTS({
text: "Please enter your PIN"
});
},
onInputStarted: () => {
console.log("Collect input started");
},
onUpdated: (collect) => {
console.log("Collect updated:", collect.digits);
},
onEnded: async (collect) => {
console.log("Collect ended:", collect.result);
console.log("PIN collected:", collect.digits);
call.hangup();
},
onFailed: () => {
console.log("Collect failed")
}
}
}).onStarted();
```
## **Properties**
Confidence level for the speech recognition result (if [`type`][type] is `"speech"`), from 0 to 100. For example, `83.2`.
The digits that have been collected (if [`type`][type] is `"digit"`). For example, `"12345"`.
Whether this is the final result of the collect session. When `partialResults` is `true`, intermediate results will have `final` set to `false`. With `continuous: true`, `final` means the utterance detection has completed but the detector will continue to the next utterance.
The unique id for this collect session.
Alias for [`type`][type], in case of errors. Use this field to check the reason of the error.
The result object containing the collect session outcome. See [`CallingCallCollectResult`][callingcallcollectresult].
The text that has been collected (if [`type`][type] is `"speech"`). Alias for [`text`](#field-text).
The terminator used to complete the collect (if [`type`][type] is `"digit"`). For example, `"#"`.
The text that has been collected (if [`type`][type] is `"speech"`). For example, `"hello who's there"`.
The type of this collect session.
The state of this collect session. Only present when [`type`][type] is `"speech"` and the [`continuous`][voice-call] parameter is set to `true`. Otherwise, the collect state is always `"undefined"`.
Whether the collect has ended. Returns `true` when the state is not `"collecting"`, `final` is not `false`, and the result type is one of: `"error"`, `"no_input"`, `"no_match"`, `"digit"`, or `"speech"`.
## **Methods**
### ended
* **ended**(): `Promise`\<[`CallCollect`][callcollect]>
Returns a promise that is resolved only after this collect finishes (or is stopped).
#### Returns
`Promise`\<[`CallCollect`][callcollect]>
A promise that resolves to the [`CallCollect`][callcollect] object when the collect session is ended.
#### Example
```js
const collect = await call.collect({
digits: {
max: 4,
digitTimeout: 10,
terminators: "#",
},
partialResults: true,
sendStartOfInput: true,
}).onStarted();
await collect.ended();
```
***
### startInputTimers
* **startInputTimers**(): `Promise`\<[`CallCollect`][callcollect]>
Start the `initialTimeout` timer on an active collect.
#### Returns
`Promise`\<[`CallCollect`][callcollect]>
A promise that resolves to the [`CallCollect`][callcollect] object when the collect session `InputTimer` is started.
#### Example
```js
const collect = await call.collect({
digits: {
max: 4,
digitTimeout: 10,
terminators: "#",
},
partialResults: true,
sendStartOfInput: true,
startInputTimers: false,
}).onStarted();
// You can add some logic before starting input timers.
await collect.startInputTimers();
```
***
### stop
* **stop**(): `Promise`\<[`CallCollect`][callcollect]>
Stops the collect session.
#### Returns
`Promise`\<[`CallCollect`][callcollect]>
A promise that resolves to the [`CallCollect`][callcollect] object when the collect session is stopped.
#### Example
```js
const collect = await call.collect({
speech: {
endSilenceTimeout: 2,
speechTimeout: 10,
language: "en-US",
hints: ["sales", "support", "representative"]
},
partialResults: true,
sendStartOfInput: true
}).onStarted();
await collect.stop();
```
***
## **Alias Types**
### CallingCallCollectResult
Ƭ **CallingCallCollectResult**: `Promise`\<[`CallCollect`][callcollect]>
The [result][result] of the collect session.
Depending on the [`type`][type] of the collect session,
the result will return different fields.
#### Digit Collect Results
The result of a collect session when [`type`][type] is `"digit"`.
#### Properties
The type of this collect session.
The parameters of this collect session.
The digits that have been collected.
The terminator used to complete the collect.
#### Speech Collect Results
The result of a collect session when [`type`][type] is `"speech"`.
#### Properties
The type of this collect session.
The parameters of this collect session.
The text that has been collected.
The confidence level for the speech recognition result.
#### Start of Input Collect Results
The result of a collect session when [`type`][type] is `"start_of_input"`.
#### Properties
The type of this collect session.
#### No Input Collect Results
The result of a collect session when [`type`][type] is `"no_input"`.
#### Properties
The type of this collect session.
#### No Match Collect Results
The result of a collect session when [`type`][type] is `"no_match"`.
#### Properties
The type of this collect session.
#### Error Collect Results
The result of a collect session when [`type`][type] is `"error"`.
#### Properties
The type of this collect session.
## **Events**
### onStarted
* **CallCollect.listen**(`{ onStarted: Callback }`)
Emitted when the collect session is started. Your event handler will receive the [`CallCollect`][callcollect] object.
#### Parameters
The [`CallCollect`][callcollect] object that emitted the event.
### onInputStarted
* **CallCollect.listen**(`{ onInputStarted: Callback }`)
Emitted when the collect session starts receiving input. Your event handler will receive the [`CallCollect`][callcollect] object.
#### Parameters
The [`CallCollect`][callcollect] object that emitted the event.
### onUpdated
* **CallCollect.listen**(`{ onUpdated: Callback }`)
Emitted when the collect session is updated. Your event handler will receive the [`CallCollect`][callcollect] object.
#### Parameters
The [`CallCollect`][callcollect] object that emitted the event.
### onFailed
* **CallCollect.listen**(`{ onFailed: Callback }`)
Emitted when the collect session fails. Your event handler will receive the [`CallCollect`][callcollect] object.
#### Parameters
The [`CallCollect`][callcollect] object that emitted the event.
### onEnded
* **CallCollect.listen**(`{ onEnded: Callback }`)
Emitted when the collect session ends. Your event handler will receive the [`CallCollect`][callcollect] object.
#### Parameters
The [`CallCollect`][callcollect] object that emitted the event.