Bot Framework composer 1.3.0
Application get crashed.
created custom action class using InputDialog and created schema file. Try to use this custom class in bot composer, while running the application & get crashed.
at Microsoft.Bot.Builder.Dialogs.Adaptive.Input.InputDialog.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Bot.Builder.Dialogs.Adaptive.Input.InputDialog.<PromptUserAsync>d__59.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Bot.Builder.Dialogs.Adaptive.Input.InputDialog.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Bot.Builder.Dialogs.DialogContext.<BeginDialogAsync>d__32.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Bot.Builder.Dialogs.Adaptive.Actions.ActionScope.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Bot.Builder.Dialogs.Adaptive.Actions.ActionScope.<BeginDialogAsync>d__6.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Bot.Builder.Dialogs.DialogContext.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Bot.Builder.Dialogs.Adaptive.AdaptiveDialog.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.Dialogs.Adaptive.AdaptiveDialog.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Bot.Builder.Dialogs.DialogContext.<BeginDialogAsync>d__32.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Bot.Builder.Dialogs.DialogManager.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Bot.Builder.Dialogs.DialogManager.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Bot.Builder.Dialogs.DialogManager.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.BotFramework.Composer.Core.ComposerBot.
Thank you for providing a stack trace. What is the exception?
Please also provide the custom input dialog and schema you've used.
@EricDahlvang Thanks for reply
Exception : Object reference not set to an instance of an object.
class information
public class CustomInput : InputDialog
{
[JsonProperty("$Kind")]
public const string Kind = "CustomInput";
[JsonProperty("customText")]
public StringExpression Text { get; set; }
[JsonProperty("outputFormat")]
public StringExpression OutputFormat { get; set; }
[JsonConstructor]
public CustomInput([CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0)
{
this.RegisterSourceLocation(sourceFilePath, sourceLineNumber);
}
protected override Task<InputState> OnRecognizeInputAsync(DialogContext dc, CancellationToken cancellationToken)
{
var input = dc.State.GetValue<object>(VALUE_PROPERTY);
if (!(input is string strInput))
{
return Task.FromResult(InputState.Invalid);
}
if (this.OutputFormat != null)
{
var (outputValue, error) = this.OutputFormat.TryGetValue(dc.State);
if (error == null)
{
if (!string.IsNullOrWhiteSpace(outputValue))
{
strInput = outputValue.ToString();
}
}
else
{
throw new InvalidOperationException($"In TextInput, OutputFormat Expression evaluation resulted in an error. Expression: {OutputFormat.ToString()}. Error: {error}");
}
}
dc.State.SetValue(VALUE_PROPERTY, strInput);
return strInput.Length > 0 ? Task.FromResult(InputState.Valid) : Task.FromResult(InputState.Unrecognized);
}
}
CustomInput.schema
{
"$schema": "https://schemas.botframework.com/schemas/component/v1.0/component.schema",
"$role": ["implements(Microsoft.IDialog)", "extends(Microsoft.InputDialog)"],
"title": "customText",
"description": "Sample custom input dialog",
"type": "object",
"additionalProperties": false,
"maxTurnCount": 3,
"properties": {
"customText": {
"$ref": "schema:#/definitions/stringExpression",
"title": "Text",
"description": "Value from callers memory"
},
"outputFormat": {
"$ref": "schema:#/definitions/stringExpression",
"title": "Output format",
"description": "Expression to format the output.",
"examples": [
"=toUpper(this.value)",
"${toUpper(this.value)}"
]
}
}
}
Is the CustomActionComponentRegistration included in the exported bot's startup.cs?
This is commented out by default in Composer's ejected runtime:
// This is for custom action component registration.
//ComponentRegistration.Add(new CustomActionComponentRegistration());
Also, is CustomActionComponentRegistration registering a CustomInput?
public class CustomActionComponentRegistration : ComponentRegistration, IComponentDeclarativeTypes
{
public IEnumerable<DeclarativeType> GetDeclarativeTypes(ResourceExplorer resourceExplorer)
{
// Actions
yield return new DeclarativeType<MultiplyDialog>(MultiplyDialog.Kind);
yield return new DeclarativeType<CustomInput>(CustomInput.Kind);
}
public IEnumerable<JsonConverter> GetConverters(ResourceExplorer resourceExplorer, SourceContext sourceContext)
{
yield break;
}
}
@EricDahlvang Yes, I had did all the steps I can be able to add custom dialog in the composer this exception raising while running the application
Is the Initial Prompt defined in Composer?


@EricDahlvang Thank you its working fine.
Is possible we can define default initial prompt activity ?
@rvinothrajendran this can be accomplished by overriding OnRenderPromptAsync:
protected override async Task<IActivity> OnRenderPromptAsync(DialogContext dc, InputState state, CancellationToken cancellationToken = default(CancellationToken))
{
if (this.Prompt == null)
{
this.Prompt = new StaticActivityTemplate(MessageFactory.Text("missing initial prompt"));
}
return await base.OnRenderPromptAsync(dc, state, cancellationToken).ConfigureAwait(false);
}
Added a PR to throw a more meaningful exception if the .Prompt is missing: https://github.com/microsoft/botbuilder-dotnet/pull/5065