Requesting code recommendations for building a multi-layered, conversation bot [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
My company wants an Azure bot to respond to a series of “yes” and “no” answers along a conversational path with three layers. I'm using Visual Studio Community 2019 to edit code and Bot Framework Emulator (V4) to test the bot.
Here's a link to an image of the questions and answers and how the conversational flow should look:
https://cdn1.imggmi.com/uploads/2019/5/21/738797c22a7756a01fdf6786f26eb39b-full.png.
I'm not sure know how to link multiple layers of dialogue together. I've only been able to construct a bot with one layer of dialogue as shown at the URL below:
https://cdn1.imggmi.com/uploads/2019/5/21/99019e8e881d62f56ce449397ca9f191-full.png
I tried using the "SuggestedActionsBot" template, but it seems to need a major rework to make our deliverable possible.
https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/08.suggested-actions
Just for reference, here's an example of how the code for the first layer of dialogue looks:
private static string ProcessInput(string text)
{
const string FirstSequenceResponseYes = "Sure, can you explain the issue? " +
"Do you see error message such as 'Power BI Access Tokens Not Allocated?'";
const string FirstSequenceResponseNo = "Thanks, user. " +
"It's good to interact with you. Have a great day!";
switch (text)
{
case "yes":
{
return $"{FirstSequenceResponseYes}";
}
case "no":
{
return $"{FirstSequenceResponseNo}";
}
default:
{
return "Please select one of the suggested action choices.";
}
}
}
What is the best way to go about writing the code to make this deliverable possible? Are there URLs and resources someone could provide that are directly pertinent to what we're trying to achieve?

I'm not sure I understood your question exactly, as the comment say.
But for navigating layers in the bot, I would encourage you to read this documentation.
With the bot-community solution, you can create a complex dialog with several levels.
Finally, in order to create a dialog that receives only yes and no answers, I would suggest using ConfirmPrompt.

Related

Generate skipable list based on chars [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am very sure that there is a technical term for this problem, but unfortunately I do not know it.
I have an alphabetical charset and the requirement is to create the combination of all the chars with a maximum length
The idea is (sample):
Generate a collection of A, AA, AAA, AAAA, AAAAA, AAAAAA
Next: A, AB, ABA, ABAA, ABAAA
Next A, AB, ABB, ABBA, ABBAA
The reason:
We have to query an API that delivers search results.
But if I don't get search hits from the API on AAA, I don't need to search for AAAA anymore, because it can't get search hits either. I can then move on to AAB.
The question:
My problem is that I'm not sure how the code has to be built to achieve this goal. I lack the structural approach.
I've already tried nested loops, but unfortunately I don't get the result.
I also used Combination Libraries, but they focus on other problems.
Many thanks for hints!
What you're looking for is a particular data structure called a Tree, but probably more specifically in your case, a Trie.
Trie data structures are commonly used in things like Autocomplete. With the image below, if someone typed "te", I can traverse the Trie and see what options would come after that (tea, ted, ten).
It looks like this would also fit your use case from what I can tell.

String to decimal [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
The application that I've made I've got a text box called service cost. This allows the user to enter the cost of the service they have provided and this is decimal. I'm trying to get this service cost displayed in a DGV, I've got everything else working apart from this.
currentComputer.ServiceCost = Convert.ToDecimal(txtServiceCost);
The above is the code that I currently have, is there something wrong that I've done here?
From the question it is clear that txtServiceCost is the TextBox, and Convert.ToDecimal() expects a string as input so you should use txtServiceCost.Text instead for txtServiceCost. Since txtServiceCost is a control where as txtServiceCost.Text is a string
currentComputer.ServiceCost = Convert.ToDecimal(txtServiceCost.Text);
But i would like to suggest you to use decimal.TryParse
decimal userInput;
if (!decimal.TryParse(txtServiceCost.Text, out userInput))
{
// Throw some warning here that invalid input
}
currentComputer.ServiceCost = userInput;

Saving Program Data in C# [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
So I'm working on a quick program for my mom. It has a textbox user input, a combobox for category selection, and multiple textbox for representing each category. The idea is that she can input a number value into the textbox and select a category. Then that value is stored in its respective category's textbox. I am absolutely certain I did not write this code well, but I don't know C# very well. Long story short, I need a way to be able to save the data stored in the textbox categories so she can close the program. I've never worked with something like this before, even in other languages, so this is foreign to me.
EDIT:
Here is the code illustrating what I am currently doing (this code is under a button click action, private void button1_Click(object sender, EventArgs e):
string userInput;
userInput = textBox1.Text;
if(comboBox1.SelectedIndex == 0)
{
category1Box.AppendText(userInput +"\n");
}
I did not specify how I wanted to save the data , as I'm not even sure how I want to do it. Like I said, I'm not experienced in this area at all, so I don't even know what the different options I had were. Hopefully this edit helps.
Serialization is a fairly simple way to save and load data on a single machine. You mention a single user so I think this will fit your requirements, but without more information I can't be sure.
Your question is very ambiguous in terms of how you want to save data, so I'll go with a very simple solution. You can utilize a few methods in the File class in System.IO.
File.WriteAllBytes(string path, byte[] data)
File.WriteAllLines(string path, string[] data)
File.WriteAllText(string path, string data)
These methods are very useful, and I suggest you learn to use them!

Customizing Menu Items Shortcut keys at Run Time [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I need to provide a feature of assigning shortcut keys to any file menu item or buttons at runtime by a user. I am using Visual Studio 2012. Please suggest the standard method to achieve this.
UPDATE
Storing shortcuts in config file is an option. I am searching for the best regarding
Showing shortcut keys along with menu items
Some other commands too will be included which may or may not be
shown in menu
I am lookiing for standard way to proceed not the code. Is storing in config file the best way, what should I consider if any key is changed by user at runtime other than updating config file. This will be some sort of user specific preferences.
private void AssignKey(ToolStripMenuItem item, string keyName)
{
try
{
Keys key = (Keys)Enum.Parse(typeof(Keys), keyName);
item.ShortcutKeys = key;
}
catch (ArgumentException)
{
MessageBox.Show("Unknown key " + keyName);
}
}
EDIT
Missed the update.
Anywho, just store the shortkeys in a "config" class, that has a Save method and save the it every time the software is closed.

How to poll anonymously? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm looking for an idea to develop a little poll system that voters be able to vote anonymously. No registration, no e-mail ..., Of course, everyone must vote only ONE time.
I do not want to use cookies, because I think it's possible that a few users vote from one machine, or one user votes with several browsers on a machine. Also I think working with IP addresses is not a good idea too, because it is possible users use proxy. So, do you have any idea for this?
(I use ASP.NET 4 with C# & SQL Server 2008)
Thanks.
There is absolutely no way to guarantee that each person will only vote once, without registration. Even if you get the IP, you will fail to prevent this person from voting a second time from another location and you will prevent multiple persons from voting using the same connection.
Without registration your best bet is to use IP adress to identify votes. Store polls in a database and refuse to update if the voter is trying to vote more than once.
A way to get IP address:
public static string getIPAddress(HttpRequestBase request)
{
string szRemoteAddr = request.UserHostAddress;
string szXForwardedFor = request.ServerVariables["X_FORWARDED_FOR"];
string szIP = "";
if (szXForwardedFor == null)
{
szIP = szRemoteAddr;
}
else
{
szIP = szXForwardedFor;
if (szIP.IndexOf(",") > 0)
{
string [] arIPs = szIP.Split(',');
foreach (string item in arIPs)
{
if (!isPrivateIP(item))
{
return item;
}
}
}
}
return szIP;
}

Categories

Resources