0

I am trying to add a line break in between two strings in node js inside a lambda function.

I have tried using '\n' , '\r\n' and also tried importing os and then using os.EOL statement, but none of these worked.

------------------------Using '\n'-------------------------------

var msg = `The order(s) for the customer ${CustomerNumber} and its status are ${data}`
msg+='\n'
msg+= ' To know the order details of another customer enter the customer 


-------------------------- Using '\r\n' -------------------------------
var msg = `The order(s) for the customer ${CustomerNumber} and its status are ${data}`
msg+='\n'
msg+= ' To know the order details of another customer enter the customer number'

-------------------------- Using 'os.EOL' -------------------------------
var os = require("os");
var msg = `The order(s) for the customer ${CustomerNumber} and its status are ${data}`+os.EOL+' To know the order details of another customer enter the customer number'


-------------- Sending msg string to the AWS lex bot----------------------
callback(elicitSlot(sessionAttributes, deliveryStatus, slots, "CustomerNumber", {

                        'contentType': 'PlainText',
                        'content': msg

                    } ));

function elicitSlot(sessionAttributes, intentName, slots, slotToElicit, message) {
    return {
        sessionAttributes,
        dialogAction: {
            type: 'ElicitSlot',
            intentName,
            slots,
            slotToElicit,
            message,
        },
    };
}

all these had node effect, and the output i got was without a line break and as a continuous string

The output which i am expecting is: "The order(s) for the customer abcd and its status are 1234, 5678, 9876 " To know the order details of another customer enter the customer number'

Output what i am getting is: "The order(s) for the customer abcd and its status are 1234, 5678, 9876 " To know the order details of another customer enter the customer number'

I think it is because i am giving the content type as 'plain text', can anyone suggest me a solution?

Ashwin96
  • 31
  • 6

1 Answers1

0

Looks like this is a bit old but I found the answer to this in a tutorial. To use html inside of your message you need to use backticks for the message. For instance:

event.response.emailMessage = `<h1>Welcome to the App!</h1> <p>Your user name is ` + event.request.usernameParameter + `</p> <p>Your temporary password: ` + event.request.codeParameter + `</p> <p>If you need assistance, please contact the help desk at (555) 555-5555 or email <a href="mailto:help@example.org">help@example.org.</a></p>`;

Hopefully this will help someone else out.

Chris Christensen
  • 192
  • 1
  • 2
  • 18