Botframework - C # - Responsive Map - Submit Action - Exception

SubmitAction in Adaptive Cards (botframework, C #, emulator, localhost) I am getting this exception

Exception: Value cannot be null. Parameter name: stringToEscape
[File of type 'text/plain']

      

Can you help me point out what I am doing wrong?

card.Actions.Add(
    new SubmitAction()
    {
        Title = "Submit"
        Data = Newtonsoft.Json.Linq.JObject.FromObject(new { button = "Submit", ServerUrl = "idServerURL" })
    }
);

      

From RootDialog - LUIS Intent is called

[LuisIntent("ServerAuth")]
public async Task ServerAuthIntentActionResultHandlerAsync(IDialogContext 
context, IAwaitable<IMessageActivity> activity, LuisResult result)
{
    var message = await activity;
    await context.PostAsync($"Am working on it...'{message.Text}' ");

    var serverAuthAction = new ServerAuthAction();

    // Action to execute if no form is required - Based on LUIS result, call fulfillment methods From/To ERP Data and proceed to next stage of dialog
    await serverAuthAction.ResumeActionServerAuthFormDialog(context, result);

    //context.Wait(this.MessageReceived);

}

public async Task ResumeActionServerAuthFormDialog(IDialogContext context, LuisResult result)
{
    try
    {
        //Based on the LUIS Result, fetch data from AppServer
        //var searchQuery =  result;

        //Data - Assign value to this Model from AppServer fetched data
        ServerAuthModel serverAuthData = new ServerAuthModel();
        serverAuthData = default(ServerAuthModel);

        //For testing populate values by hardcoding - /May/2017
        ServerAuthAdaptiveCardView serverAuthView = new ServerAuthAdaptiveCardView();

        //Pass Data to Channel Adaptive Card View 
        var resultData = serverAuthView.GetServerAuthAdaptiveCard();

        var resultMessage = context.MakeMessage();

        resultMessage.Attachments.Add(resultData);

        await context.PostAsync(resultMessage);
    }
    catch (Exception ex)
    {
        ...
    }
    finally
    {
        ....
    }
}

      

GetServerAuthAdaptiveCard () has a submit action code.

public Attachment GetServerAuthAdaptiveCard()
{
    AdaptiveCard card = new AdaptiveCard();
    card.FallbackText = "App Server Authentication";
    card.Body.Add(
        new TextInput()
        {
            Id = "idServerURL",
            IsRequired = true,
            Placeholder = "App Server URL",
            MaxLength = 100,
            IsMultiline = false,
            Style = TextInputStyle.Url,
            Speak = "App Server URL",
        });

    card.Body.Add(
        new ChoiceSet()
        {
            Id = "idAuthCompany",
            IsRequired = true,
            IsMultiSelect = false,
            Style = ChoiceInputStyle.Compact,
            Speak = "Company to Authenticate for",
            Value = "DocM5",
            Choices = new List<Choice>() {
                new Choice()
                {
                    Title = "P2PDemo",
                    Value = "P2PDemo",
                    IsSelected = true,
                    Speak = "P2PDemo"
                },
                new Choice()
                {
                    Title = "SalesDemo",
                    Value = "SalesDemo",
                    IsSelected = false,
                    Speak = "SalesDemo"
                }
            }
        });
    card.Body.Add(
        new TextInput()
        {
            Id = "idBranchName",
            IsRequired = true,
            Placeholder = "App Branch",
            MaxLength = 100,
            IsMultiline = false,
            Style = TextInputStyle.Text,
            // Value = ""
        });

    var submitActionData = JObject.Parse("{ \"Type\": \"idServerURL\" }");


    card.Actions.Add(
        /*  new SubmitAction()
        {
            Title = "Submit",
            // Speak = "Submit",
            Data = Newtonsoft.Json.Linq.JObject.FromObject(new { button = "Submit", ServerUrl = "idServerURL" })
        }
        */
        new SubmitAction()
        {
            DataJson = submitActionData.ToString()
        });

    var attachment = new Attachment() { ContentType = AdaptiveCard.ContentType, Content = card };
    return attachment;
}

      

Exception from emulator:

"contentType": "text/plain",
"content": "   at System.Uri.EscapeDataString(String stringToEscape)
    at Microsoft.Bot.Builder.Luis.LuisRequest.BuildUri(ILuisModel model)
    at Microsoft.Bot.Builder.Luis.LuisService.Microsoft.Bot.Builder.Luis.ILuisService.BuildUri(LuisRequest luisRequest)
    at Microsoft.Bot.Builder.Luis.Extensions.<QueryAsync>d__4.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.LuisDialog`1.<MessageReceived>d__8.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.ThunkResume`1.<Rest>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Internals.Fibers.Wait`2.<Microsoft-Bot-Builder-Internals-Fibers-IWait<C>-PollAsync>d__19.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Internals.Fibers.Frame`1.<Microsoft-Bot-Builder-Internals-Fibers-IFrameLoop<C>-PollAsync>d__9.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Internals.Fibers.Fiber`1.<Microsoft-Bot-Builder-Internals-Fibers-IFiberLoop<C>-PollAsync>d__16.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at Microsoft.Bot.Builder.Internals.Fibers.Wait`2.Microsoft.Bot.Builder.Internals.Fibers.IAwaiter<T>.GetResult()
    at Microsoft.Bot.Builder.Dialogs.Chain.LoopDialog`1.<ResumeAsync>d__3.MoveNext()
    -- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.ThunkResume`1.<Rest>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown --
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Internals.Fibers.Wait`2.<Microsoft-Bot-Builder-Internals-Fibers-IWait<C>-PollAsync>d__19.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Internals.Fibers.Frame`1.<Microsoft-Bot-Builder-Internals-Fibers-IFrameLoop<C>-PollAsync>d__9.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Internals.Fibers.Fiber`1.<Microsoft-Bot-Builder-Internals-Fibers-IFiberLoop<C>-PollAsync>d__16.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.<Microsoft-Bot-Builder-Base-IEventLoop-PollAsync>d__23.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.ReactiveDialogTask.<Microsoft-Bot-Builder-Base-IEventLoop-PollAsync>d__3.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.ScoringEventLoop`1.<Microsoft-Bot-Builder-Base-IEventLoop-PollAsync>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.EventLoopDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__3.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.SetAmbientThreadCulture.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__3.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.QueueDrainingDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__4.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.PersistentDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__3.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at Microsoft.Bot.Builder.Dialogs.Internals.PersistentDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__3.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.ExceptionTranslationDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__2.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.SerializeByConversation.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__4.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Bot.Builder.Dialogs.Internals.PostUnhandledExceptionToUser.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__5.MoveNext()"

      

+3


source to share


2 answers


Try filling in the property DataJson

instead Data

.

var submitActionData = JObject.Parse("{ \"Type\": \"HotelSelection\" }");

var action = new SubmitAction()
{
    DataJson = submitActionData.ToString()
}

      

Update based on new details added to the question.

Except for the complete exception, the problem is with LUIS, not adaptive card. In particular, the problem occurs in the BuildUri method of the LuisService (which is being called LuisDialog

). The exception also tells us that the problem occurs when the EscapeDataString method is called .



If you look closely at the method BuildUri

, you will see that there are 10 method calls EscapeDataString

. Some of these calls conflict with the values ​​of the service itself, which I don't think you are changing; however, others have values ​​from LuisModel

, such as SubscriptionKey

and ModelId

, as well as one over Query

to send to LUIS

.

That being said, my recommendation is to view the values ​​set in the attribute LuisModel

that decorates your class LuisDialog

.

If you don't know how LUIS + Bot Framework works, I would suggest you take a look at the intelligence-LUIS sample .

+2


source


You are getting this error because when you click the submit button on the adaptive card it calls the POST method of your BOT Framework. At this time the field Activity.Text

NULL

. You should check the POST method if the field is Activity.Text

NULL

; if so, then you shouldn't call LUIS to check intent.



0


source







All Articles