I have a web app deployed in azure that opens in Messenger Webview. I made a empty text prompt for user to click for the user to be able to continue when they close the Webview. However, users sometimes forget to click the button. I read this doc but i can't manage to do it as i learn best seeing actual examples and codes. How can the dialog automatically continue when the user closes or press a button in the Webview? Thank you.
The web view is a set of questions and the answer of the users are save in Cosmos DB and when they close the web view the bot access their scores in Cosmos DB and calculate their scores.
This is my current code.
private static async Task<DialogTurnResult> ThirdStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken = default(CancellationToken))
{
Activity reply = stepContext.Context.Activity.CreateReply();
reply.ChannelData = JObject.FromObject(
new
{
attachment = new
{
type = "template",
payload = new
{
template_type = "generic",
elements = new[]
{
new
{
title = "<title>",
buttons = new object[]
{
new
{
type = "web_url",
title = "<title>",
url = webAppUrl,
messenger_extensions="true",
webview_height_ratio = "tall",
},
new
{
type = "postback",
title = "Done ✔️",
payload = "Done ✔️",
},
},
},
},
},
},
});
await stepContext.Context.SendActivityAsync(reply);
return await stepContext.PromptAsync(
nameof(TextPrompt),
new PromptOptions
{
Prompt = MessageFactory.Text(string.Empty),
RetryPrompt = MessageFactory.Text("Click Done to proceed."),
});
}
private static async Task<DialogTurnResult> FourthStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
var result = stepContext.Result.ToString().ToLower();
if (result == "done ✔️" || result == "done")
{
return await stepContext.NextAsync();
}
await stepContext.Context.SendActivityAsync(
MessageFactory.Text(
$"Please press done to proceed, thank you!"));
return await stepContext.ReplaceDialogAsync(nameof(CalendarIncomeExpensesDialogV2));
}
Since you don't even know what kind of web app you're trying to create or what language you're writing the web app in or how you plan on hosting the web app, your first step is to figure all that out. If you need help with any part of that process then you'll need to ask a new very specific question about it and include what you've tried so far along with all the relevant code.
When you open the web app in your Facebook webview, you'll need to make sure the web app has all the information it needs to send an activity to the bot (I've been calling it a proactive message but those normally refer to bot-to-user messages). The needed credentials should already be built into the web app, so the only thing you'll need to send to the web app's endpoint is the user ID so that the web app can pass it along in the activity and the bot can identify which conversation the activity pertains to. The conventional way to send an activity to the bot is using Direct Line, though you may figure out a way to do it by just sending an HTTP request to the bot's endpoint or even using your Facebook app's callback URL.
There is absolutely no need to involve LUIS in this. LUIS should only be used to interpret messages from the user when you don't know what the user will say. Any time you're in control of the message that's getting sent to the bot, it doesn't make any sense to use LUIS. Keep in mind that there are 15+ activity types and your activity doesn't need to be a "message" activity. There are many ways you can identify the activity and respond accordingly in your bot. I recommend using an event activity.
Based on my understanding of your proficiency level, you will likely need to do a lot of research to accomplish what you're trying to accomplish. The documentation is a great place to start: https://learn.microsoft.com/en-us/azure/bot-service/