class Dialog::DialogServiceConnector

class Dialog::DialogServiceConnector
  : public std::enable_shared_from_this< DialogServiceConnector >
  : public Utils::NonCopyable
  : public Utils::NonMovable

Object used to connect DirectLineSpeech or CustomCommands.

Objects of this type are created via the FromConfig factory method.

Members

Recognized

Syntax: public EventSignal< const SpeechRecognitionEventArgs & > Recognized;

Signal for events containing speech recognition results.

Recognizing

Syntax: public EventSignal< const SpeechRecognitionEventArgs & > Recognizing;

Signal for events containing intermediate recognition results.

SessionStarted

Syntax: public EventSignal< const SessionEventArgs & > SessionStarted;

Signals that indicates the start of a listening session.

SessionStopped

Syntax: public EventSignal< const SessionEventArgs & > SessionStopped;

Signal that indicates the end of a listening session.

SpeechStartDetected

Syntax: public EventSignal< const RecognitionEventArgs & > SpeechStartDetected;

Signal that indicates the first detection of speech data in the current phrase.

SpeechEndDetected

Syntax: public EventSignal< const RecognitionEventArgs & > SpeechEndDetected;

Signal that indicates the detected end of the current phrase's speech data.

Canceled

Syntax: public EventSignal< const SpeechRecognitionCanceledEventArgs & > Canceled;

Signal for events relating to the cancellation of an interaction. The event indicates if the reason is a direct cancellation or an error.

ActivityReceived

Syntax: public EventSignal< const ActivityReceivedEventArgs & > ActivityReceived;

Signals that an activity was received from the backend.

TurnStatusReceived

Syntax: public EventSignal< const TurnStatusReceivedEventArgs & > TurnStatusReceived;

Signals that a turn status update was received from the backend.

Properties

Syntax: public PropertyCollection & Properties;

A collection of properties and their values defined for this DialogServiceConnector.

~DialogServiceConnector

Syntax: public inline virtual ~DialogServiceConnector ( );

Destroys the instance.

ConnectAsync

Syntax: public inline std::future< void > ConnectAsync ( );

Connects with the back end.

Returns

An asynchronous operation that starts the connection.

DisconnectAsync

Syntax: public inline std::future< void > DisconnectAsync ( );

Disconnects from the back end.

Returns

An asynchronous operation that starts the disconnection.

SendActivityAsync

Syntax: public inline std::future< std::string > SendActivityAsync ( const std::string & activity );

Sends an activity to the backing dialog.

Parameters

  • activity Activity to send

Returns

An asynchronous operation that starts the operation.

StartKeywordRecognitionAsync

Syntax: public inline std::future< void > StartKeywordRecognitionAsync ( std::shared_ptr< KeywordRecognitionModel > model );

Initiates keyword recognition.

Parameters

  • model Specifies the keyword model to be used.

Returns

An asynchronous operation that starts the operation.

StopKeywordRecognitionAsync

Syntax: public inline std::future< void > StopKeywordRecognitionAsync ( );

Stop keyword recognition.

Returns

An asynchronous operation that starts the operation.

ListenOnceAsync

Syntax: public inline std::future< std::shared_ptr< SpeechRecognitionResult > > ListenOnceAsync ( );

Starts a listening session that will terminate after the first utterance.

Returns

An asynchronous operation that starts the operation.

StopListeningAsync

Syntax: public inline std::future< void > StopListeningAsync ( );

Requests that an active listening operation immediately finish, interrupting any ongoing speaking, and provide a result reflecting whatever audio data has been captured so far.

Returns

A task representing the asynchronous operation that stops an active listening session.

SetAuthorizationToken

Syntax: public inline void SetAuthorizationToken ( const std::string & token );

Sets the authorization token that will be used for connecting to the service. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, the caller needs to refresh it by calling this setter with a new valid token. Otherwise, the connector will encounter errors during its operation.

Parameters

  • token The authorization token.

GetAuthorizationToken

Syntax: public inline std::string GetAuthorizationToken ( );

Gets the authorization token.

Returns

Authorization token

SetSpeechActivityTemplate

Syntax: public inline void SetSpeechActivityTemplate ( const std::string & activityTemplate );

Sets a JSON template that will be provided to the speech service for the next conversation. The service will attempt to merge this template into all activities sent to the dialog backend, whether originated by the client with SendActivityAsync or generated by the service, as is the case with speech-to-text results.

Parameters

  • activityTemplate The activity payload, as a JSON string, to be merged into all applicable activity messages.

GetSpeechActivityTemplate

Syntax: public inline std::string GetSpeechActivityTemplate ( );

Gets the JSON template that will be provided to the speech service for the next conversation. The service will attempt to merge this template into all activities sent to the dialog backend, whether originated by the client with SendActivityAsync or generated by the service, as is the case with speech-to-text results.

Returns

The JSON activity template currently set that will be used on subsequent requests.

FromConfig

Syntax: public inline static std::shared_ptr< DialogServiceConnector > FromConfig ( std::shared_ptr< DialogServiceConfig > connectorConfig , std::shared_ptr< Audio::AudioConfig > audioConfig );

Creates a dialog service connector from a DialogServiceConfig and an Audio::AudioConfig. Users should use this function to create a dialog service connector.

Parameters

  • connectorConfig Dialog service config.

  • audioConfig Audio config.

Returns

The shared smart pointer of the created dialog service connector.

auto audioConfig = [Audio::AudioConfig::FromDefaultMicrophoneInput](audio-audioconfig.md#fromdefaultmicrophoneinput)();
auto config = [CustomCommandsConfig::FromAuthorizationToken](dialog-customcommandsconfig.md#fromauthorizationtoken)("my_app_id","my_auth_token", "my_region");
auto connector = [DialogServiceConnector::FromConfig](#fromconfig)(config, audioConfig);

When speaking of DialogServiceConfig we are referring to one of the classes that inherit from it. The specific class to be used depends on the dialog backend being used: