-
Notifications
You must be signed in to change notification settings - Fork 84
feat: Added timeout support for some Telephony package's dialogs #1479
base: main
Are you sure you want to change the base?
Conversation
packages/Telephony/Readme.md
Outdated
@@ -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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
3d1bd9f
to
ff0bbc5
Compare
@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). |
BotAdapter adapter = dc.Context.Adapter; | ||
ConversationReference conversationReference = dc.Context.Activity.GetConversationReference(); |
There was a problem hiding this comment.
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?
packages/Telephony/Readme.md
Outdated
@@ -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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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
.
//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); |
There was a problem hiding this comment.
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.
/// <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; } |
There was a problem hiding this comment.
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.
Is this still active? |
Hi Tracy, I think it is still pending the PR's revision. |
Purpose
This PR includes timeout support for the following dialogs:
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
Tests
No tests added. The existing tests were executed successfully.
#minor