Resultant Response in Messenger. But I need to bold username, phone-number, etc.
I am new in web development.
I also tried \x3Cb>I am Bold\x3C/b>" but didn't work for me.
How can I add HTML tags in this case?
let response = {
text: `| --- <b>${username} Appointment Details</b> --- |
\n| ------------------------------------------------------------ |
\n| 1. Username: <b>${username}</b> |
\n| 2. Phone Number: <b>${user.phoneNumber}</b> |
\n| 3. Appointment Time: <b>${user.appointmentTime}</b> |
\n| 4. Appointment Created At: <b>${user.createdAt}</b> |
\n| ------------------------------------------------------------ |`,
};
callSendAPI(sender_psid, response);
//this is callSendAPI function
let callSendAPI = (sender_psid, response) => {
return new Promise(async (resolve, reject) => {
try {
let request_body = {
recipient: {
id: sender_psid,
},
message: response,
};
request(
{
uri: "https://graph.facebook.com/v11.0/me/messages",
qs: { access_token: process.env.PAGE_ACCESS_TOKEN },
method: "POST",
json: request_body,
},
(err, res, body) => {
if (!err) {
resolve("message sent!");
} else {
reject("Unable to send message:" + err);
}
}
);
} catch (e) {
reject(e);
}
});
};
Without knowing what 'callSendAPI' function does, its hard to say what might be happening..
With that said, the template literal should have no problem putting any HTML. So you do not need to add the \n, as \n really does not apply for HTML so if you want to have it formatted you should be returning it all as html, so new lines you may want to use
or in your case, the pre tag may be more appropriate