问题
I'm trying to print a series of objects in a List using the C# version of AWS Lambda. Its linked to my AWS RDS and my Lex bot. Currently, when I test the bot using the LEX test console, the output that is printed isn't formatted with line breaks even though I'm using the \n line break for C#.
Example Code:
var result = string.Empty;
result = $"Events for {User}:";
foreach (var evt in events)
{
result += $"\n\n{evt.ID} - {evt.FeedbackType} - {evt.Status} - {evt.OpenedDate.ToString()}";
}
return result;
Below is the output I am getting on Lex:
Can anyone please explain how to fix this or if its an issue with the LEX Console? Thanks!
回答1:
I believe it is simply a limitation of the lex console. You are at the mercy of the program rendering the chat to handle formatting. Try integrating to Slack - you'll see it work there. The lex console is pretty basic.
BTW if it is of any use, I've got a little app to let you chat with your bot in the commandline. As long as you are logging into the AWS CLI: https://github.com/dwmkerr/lex-chat.
来源:https://stackoverflow.com/questions/47804682/formatting-string-output-in-amazon-lex