Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

feat: Added timeout support for some Telephony package's dialogs #1479

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

luislera
Copy link
Collaborator

@luislera luislera commented Mar 8, 2023

Purpose

This PR includes timeout support for the following dialogs:

  • Aggregate DTMF (n)
  • Aggregate input Regex
  • Aggregate DTMF (#)

The timeout timer will be initialized when the dialog begins. If the user sends a valid input but does not meet the batch length, termination char or regex expression, the timer will start again.

Changes

  • Added the Timeout, Default Value and Default Value Response properties
  • Updated the schema files
  • Updated the package README file

Tests

No tests added. The existing tests were executed successfully.

imagen

#minor

@@ -120,19 +120,22 @@ The Stop Recording action stops recording of the conversation. Note that it is n
## **Aggregate DTMF Input (n)**
Prompts the user for multiple inputs that are aggregated until a specified character length is met or exceeded.
Speech, DTMF inputs, and chat provided characters can all be used to provide input, but any inputs that aren't the characters 1,2,3,4,5,6,7,8,9,0,#,*, or some combination of said characters are dropped.
In case the timeout in milliseconds is reached, the dialog will end and show the Default Value property to the user.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Show the Default Value property to the user" could be reworded better to indicate that the Default Value property will be spoken to the user, if that's the intent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Steven, sure!. As requested, we will be doing additional changes to this PR. If you want I can let you know as soon as we pushed them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @luislera, I synced with Jim and agree with his requested changes, please disregard my comment for now and perform his changes. After his reqs are complete, I'll take another look at the PR ☺️

@luislera luislera removed the request for review from jameslew March 15, 2023 19:12
@luislera luislera force-pushed the southworks/feature/telephony-package branch from 3d1bd9f to ff0bbc5 Compare March 15, 2023 19:13
@luislera luislera requested a review from stevengum March 15, 2023 19:24
@jameslew
Copy link
Contributor

@stevengum , @ninilang - can you review this? Has added the additional experience changes we discussed (splitting the default message from the default value, supporting speech field, etc).

Comment on lines 272 to 273
BotAdapter adapter = dc.Context.Adapter;
ConversationReference conversationReference = dc.Context.Activity.GetConversationReference();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These explicit typings are unnecessary and don't align with the rest of the changes, can you use var instead?

@@ -120,23 +120,27 @@ The Stop Recording action stops recording of the conversation. Note that it is n
## **Aggregate DTMF Input (n)**
Prompts the user for multiple inputs that are aggregated until a specified character length is met or exceeded.
Speech, DTMF inputs, and chat provided characters can all be used to provide input, but any inputs that aren't the characters 1,2,3,4,5,6,7,8,9,0,#,*, or some combination of said characters are dropped.
A timeout timer will be initialized when the dialog begins or when the user sent a response that has not meet or exceed the batch length.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Timeout parameter isn't required, and in the code when the timeOutInMilliseconds value is null or less than 0, no timer is set.

The first part of the sentence is inaccurate and should be updated to reflect the functionality of the code.

If we want to make the timeout a requirement, there should be a default value of probably 20-40s and it needs to be signed off by @jameslew. I support the idea of making the timeout a required parameter due to the headless experience of phone calls, where a user might be distracted and forget what the bot asked, and the user has no easy way to ask the bot to repeat itself.

This IVR experience is different from the experience of interacting with a bot by typing messages over WebChat, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the current functionality in the code, a more accurate pair of statements would be:

When the Timeout parameter is set an integer greater than 0, a timer will be set whenever the Aggreate DTMF Input(n) node begins. This timer will be reset whenever the user responds to the bot, until the expected batch length is met.

@@ -120,6 +151,19 @@ public override async Task<DialogTurnResult> ContinueDialogAsync(DialogContext d
}
else
{
//If we didn't timeout then we have to manage our timer somehow.
//For starters, complete our existing timer.
var timerId = dc.State.GetValue<string>("this.TimerId");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please turn this string into a private const.

Comment on lines 154 to 165
//If we didn't timeout then we have to manage our timer somehow.
//For starters, complete our existing timer.
var timerId = dc.State.GetValue<string>("this.TimerId");

//Should never happen but if it does, it shouldn't be fatal.
if (timerId != null)
{
await stateMatrix.CompleteAsync(timerId).ConfigureAwait(false);
}

// Restart the timeout timer
await InitTimeoutTimerAsync(dc, cancellationToken).ConfigureAwait(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A timer isn't always set for this prompt, because users aren't required to provide a timeOutInMilliseconds value, which is the precusor to a timerId being generated. So timerId can be null.

It seems that placing await InitTimeoutTimerAsync(dc, cancellationToken).ConfigureAwait(false); inside of the if(timerId != null) { } block would be better for human readability, and a slight optimization.

Comment on lines +98 to +114
/// <summary>
/// Gets or sets the default value for the input dialog when a Timeout is reached.
/// </summary>
/// <value>
/// Value or expression which evaluates to a value.
/// </value>
[JsonProperty("defaultValue")]
public ValueExpression DefaultValue { get; set; }

/// <summary>
/// Gets or sets the activity template to send when a Timeout is reached and the default value is used.
/// </summary>
/// <value>
/// An activity template.
/// </value>
[JsonProperty("defaultValueResponse")]
public ITemplate<Activity> DefaultValueResponse { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that it should be straightforward to add a unit test verifying the functionality tied to defaultValue and defaultValueResponse when timeOutInMilliseconds is some small number, e.g., 1.

When timeOutInMilliseconds is 1, the bot should ask the user its prompt, then immediately send any defaultValueResponse and end with the defaultValue in the DialogTurnResult.

Please add a test that covers this scenario.

@tracyboehrer
Copy link
Member

Is this still active?

@luislera
Copy link
Collaborator Author

Is this still active?

Hi Tracy, I think it is still pending the PR's revision.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants