Reply From User Not On Message - javascript

I'm building an app that will display mail conversations and allow users to reply. In some cases a user (userB) who was not previously included in the conversation wants to join in. I would like for this newcomer to be able to reply or somehow add to the conversation (with them as the from address).
I've tried this:
client.post('/users/userA#example.com/messages/<message ID>/reply', {
message:{
from: {
emailAddress: {
address: "userB#example.com",
}
}
},
comment: `userB has something important to add.`
})
But get ErrorSendAsDenied.
How can I get permission for this? Is it even possible?
One alternative I have considered is forwarding the message to userB and then reply to that. Any better ideas?

I see no other way. You will just have to forward the message first because POST /users/UPN/messages/msg-id/reply requires the message being replied and the sender to be associated with the one milbox.

Related

The letter gets into the spam folder in google mail

When users register, some emails get into the spam folder.
I have two functions:
The first will make a configuration for nodemailer.
function sendingLetter() {
return nodemailer.createTransport({
service: config.transport.service,
secure: config.transport.ssl,
auth: {
user: config.transport.user,
pass: config.transport.password
}
});
}
The second is making a template for sending by mail with a link
function statusCheck(file, replacements) {
let html_file = fs.readFileSync(file, { encoding: 'utf-8' });
let template = handlebars.compile(html_file);
let htmlToSend = template(replacements);
return htmlToSend;
}
The function of sending letters to the user's mail
const smtpTransport = sendingLetter();
const confirm_email = path.join(__dirname, '../views/email_templates/users/confirm_email.html');
...
let rand_hash = Date.now();
let link = 'https://' + config.kHostName + '/api/users/verify/' + rand_hash;
let replacements = {
target_link: link,
};
let htmlToSend = statusCheck(confirm_email, replacements);
let mailOptions = {
from: config.transport.user,
to: user_email,
subject: Constants.users.messages.subjectConfimEmail,
html: htmlToSend,
};
smtpTransport.sendMail(mailOptions);
The template in which the link will be inserted to be sent to the user by mail
<p>
We're ready to activate your account. All we need to do is make sure this is your email address.
</p>
<a href="{{target_link}}"
<div class="butten">
Confirm Email
</div>
</a>
In some cases, Google sends my email to a spam folder. Why it happens? What are some tips to avoid this?
There is an algorithm within Google to categorize the messages according to your interest and have probably been categorized as undesirable.
The classification of messages sent from any website as spam is one of the most important things that a webmaster should pay attention to. I will discuss in this article what things a webmaster should pay attention to to ensure that messages sent by him Its website as spam (spam) ends up in a non-spam folder or spam folder.
How do service providers classify messages as spam?
The e-mail service providers use many methods and tools to filter the incoming e-mails of the system and accordingly decide whether or not the message should be classified as an annoying message.
Content-based filtering "Content Filters"
Filter based on the letterhead of the email "Email Header Filters"
Filter based on blacklists "Blacklist Filters"
Filter based on user decision "User Rule-based filters"
Methods of Solution
First: Filter based on Content Content Filters
Through which the content of the message and the method of writing it to find out whether the message is disturbing or not, by comparing the content to a database containing a set of words used in the spam and certainly every service provider has his own words in this area called " Spam Trigger Words, "and there are many lists of English words that can be found using the previous search term in the Google search engine.
Also, the service providers, through this mechanism, search the way in which the message was written, especially if the HTML code was used to write the message, then the service provider makes sure that the code written is a clean code.
The following are some tips that can be provided to avoid placing your message as spam based on the filtering mechanism based on the content:
Make sure that the title of the subject is not too long and not so short that it is just one word.
Make sure that the title or text of the message is not fully capitalized when writing in English.
Make sure that the message title does not contain Re: unless the message is actually in response to a message sent by the recipient.
Do not use a question mark in the message title.
You can use the $ $ sign in a sequential address or message content, for example, $$$.
When you write a message in HTML, do not use video, JavaScript or JavaScript in the message, and make sure that the HTML code is clean, standard and written correctly according to HTML standards.
Second: Liquidation Based on the letterhead "Email Header Filters":
Through this mechanism the server receives the message of the search for any false data can be found in the letterhead and accordingly classified as an annoying message or not.
Third: Liquidation based on blacklists "Blacklist Filters":
Blacklists are constantly updated databases that contain a list of IP addresses for servers that are based on or send spam messages.
Fourth: Liquidation based on the user's decision "User Rule-based filters":
Although this mechanism is not of great importance because it depends on the decision of the recipient of the message itself, but it must be mentioned, and in this mechanism the recipient of the message itself to indicate the message received as an annoying message and therefore in the following times to be written by the same address The message will go to the spam folder directly.
In the end I apologize for my relatively weak English.

Why is my code sending the prompts to my phone, but not to anyone else who attempts to send a message to the bot?

When I send a message to the Twilio phone number from my phone, it displays the questions that I want the user to see. However, if someone else sends a message no prompts are shown to the user. This is stored in a database. At first, I thought it was because the number sending a message was not getting stored as phoneNumber, but after checking in the database it is stored as phoneNumber.
I already tried adding a Status Callback function to the code but it doesn't say anything about the status of the message.
if(body === 'x'){ //checks body to have a key phrase, it it does it creates the message
let newMessage = new Message();
newMessage.phoneNumber = from;
newMessage.save(() => {
client.messages.create({ //sends message to the patient
to: `${from}`,
from: `${to}`,
body: 'What is your full name?'
})
.then(message => console.log(message.sid));
res.end();
})
}
The expected output would be the prompt of full name if someone sends a message to the Twilio number. However, it doesn't display anything.
Twilio developer evangelist here.
I can think of a couple of reasons that might be affecting you here.
First up, if you are still using a trial account then you can only send SMS messages to numbers that you have verified with your account. There are instructions for how to verify numbers with your Twilio account here. You can remove this restriction by upgrading your account.
Secondly, depending on the platform you are using, there may be a race condition between sending the message and the response ending. You call client.messages.create and handle the promise when it resolves, but your code goes straight on to end the response synchronously. It is the case with Twilio Functions and it may be on other platforms, that ending the response ends all processing and that might result in the request to send a message getting cancelled. You say you are getting messages when you try from your phone, so this may not be the issue, I just thought I'd share in case.
Let me know if that helps at all.

Have a Microsoft Azure web app chatbot proactively contact a user using e-mail or Twilio from a table/list of preset users

I have a simple web app chatbot made with Azure. It is very simple, it will ask a user 3 questions, record the answers to a storage table and repeat the answers back to the user.
I have connected it to Twilio and e-mail using the Channels tab in azure portal. I wonder, is it possible to have a table or database with e-mail addresses or phonenumbers that the bot will contact, preferably if perhaps a variable for a certain address switched from false to true that address would be contacted.
This is the closest example I have found however it uses Skype. Not e-mail or Twilio. https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/core-CreateNewConversation
I would like something like this part
// Every 5 seconds, check for new registered users and start a new dialog
setInterval(function() {
var newAddresses = userStore.splice(0);
newAddresses.forEach(function(address) {
console.log('Starting survey for address:', address);
// new conversation address, copy without conversationId
var newConversationAddress = Object.assign({}, address);
delete newConversationAddress.conversation;
// start survey dialog
bot.beginDialog(newConversationAddress, 'survey', null, function(err) {
if (err) {
// error ocurred while starting new conversation. Channel not supported?
bot.send(new builder.Message()
.text('This channel does not support this operation: ' + err.message)
.address(address));
}
});
});
to scan a table and if a variable switches it will extract the address from the table and set it as a address variable.
I believe I can figure that out myself however I require help to learn how to make the bot contact a user without the user contacting the bot first, instead using a list of preset users.
If there is any documentation regarding the e-mail channel for a web app bot I have not been able to find it, I would like to know how to have the bot send a e-mail to a user and if there are any JavaScript classes I could use to use the e-mail channel in my bots app.js code.
I hope I made myself understandable, many thanks for any help
With regard to contacting a user without them having first contacted the bot on the Email and Twilio channels you can do the following.
Set up the addresses for each like so:
Email
var emailAddress =
{
channelId: 'email',
user: { id: <userEmail> },
bot: { id: <botEmail>, name: <botName> },
serviceUrl: 'https://email.botframework.com/'
};
SMS
var sms =
{
user: { id: '<userphone>' },
bot: { id: '<botphone>' },
conversation: {id: '<userphone>'},
channelId: 'sms',
serviceUrl: 'https://sms.botframework.com'
};
Note that SMS will not work with a trial twilio number, but will work fine with a purchased number.
After you have your addresses set up, you can route each of them through something like the following code.
var message = new builder.Message()
.address(address)
.text(<messageText>);
try {
console.log(message);
bot.send(message);
} catch (error) {
console.log(error);
}
Will edit this to include loading the user list later if needed.

Docusign API - Views/Recipient with In Person Signing

I have everything working for the views/sender, and I have envelopeId/recipients working - so I know every piece of data that I think I need.
In my envelope I have 2 inPersonSigners. The first is a "client" always, and the second is an employee, always.
I have the UserId, RecipientGuid, RecipientId, UserName, etc. Since these are In Person AND Embedded signers, they do not have email addresses.
I have been unable to get the recipient view to return the URL because the "UNKNOWN_ENVELOPE_RECIPIENT" OR "INVALID_ENVELOPE_RECIPIENT" errors I am receiving with every combination of data I have tried.
In the documentation it states you only need the clientUserId or a userName and Email combination. I have tried a variety of these, and still cant get the in person, embedded signing recipient view to return the correct response. 100% of the time it is an envelope recipient invalid error. I have tested every combination I can think of in postman and code;
inPersonSigners
[0]
clientUserId:"SomeoneHelpfulsomeonehelpful#stackexchange.com"
hostEmail:"someonehelpful#stackexchange.com"
hostName:"StackExchange User"
note:""
recipientId:"1"
recipientIdGuid:"xxxxxxxx-xxxx-xxxx-b65d-3bb23fbf8860"
requireIdLookup:"false"
roleName:"1"
routingOrder:"1"
signerEmail:""
signerName:"Test Testeroni"
status:"sent"
userId:"xxxxxx-xxxx-xxxx-913e-c347a9f2dafd"
I just need to be able to take the data above, post to /views/recipient and get the response url.
I think the problem is that when this document template is being created, via Drawloop ->Docusign, there is no Email being passed, but there is a Name and clientUserId. Hopefully its something simple that I have missed after looking at the same thing for hours.
The below sample invocation/POST would work. I did notice that your clientUserID resembles an email# - typically this value is in a GUID format. Something to keep in mind.
POST
https://demo.docusign.net/restapi/v2/accounts/459963/envelopes//views/recipient
{
"authenticationMethod":"email",
"username": "StackExchange User",
"email": "someonehelpful#stackexchange.com",
"returnUrl":"http://www.something_you_provide.com",
"clientUserId":"SomeoneHelpfulsomeonehelpful#stackexchange.com"
}

How to sent a website url as link to multiple Facebook Friends?

I am setting up a website. I want users to invite Facebook friends to look at the page the users can make on my website. So i'm trying to get it done. But i think the FB Api is not set up to do what i want to do. I think it is to prevent from spamming, but i really like to know if it can be done or not.
This is what i have so far. Users can login with FB and i present a decent list of FB friends.
Each friend has a checkbox. When a user submits the form, i collect all the checked friends id's:
var sendUIDs = '';
var mfsForm = document.getElementById('mfsForm');
for (var i = 0; i < mfsForm.friends.length; i++) {
if (mfsForm.friends[i].checked) {
sendUIDs += mfsForm.friends[i].value + ',';
}
}
While i was trying, i came up with this "sollution" for sending all the friends the same invite:
FB.ui({
method: 'apprequests',
to: sendUIDs,
message: "Hey come on look at my site",
data: "mywebsite.com/userlink"
});
Looking great I thought. Exactly what i wanted... i thought.
Unfortunately this is only used for games? First of all i could not find the invite. It was there, but it seems to disappear. Then i found out it was in the App/Games/Activity tab.
I managed to get the notification in the "notification" tab by adding a Canvas to my FB App. Almost there i thought. Well, not exactly... I want the friends to visit my page by the given data link and not some weird ?number.
So i gave up this path and tried the other way and came up with this:
for (var i = 0; i < mfsForm.friends.length; i++) {
if (mfsForm.friends[i].checked) {
var uid = mfsForm.friends[i].value;
FB.ui({
to : uid,
method: 'send',
name: 'Visit my page',
link: 'mywebsite.com/userlink'
});
}
}
This works more or less, but produces a popup for every friend with an empty message box. Not very friendly and, well... stupid :)
I also tried the former setup, but instead of "apprequests" i used this:
FB.ui({
method: 'send',
to: sendUIDs,
message: "Hey come on look at my site",
data: "mywebsite.com/userlink"
});
where i tried this for the sendUIDs: [1, 2, ...] and just 1, 2, ...
No luck, because FB only processed one name.
I would think there must be a way to get the job done, but for now i am very confused how to proceed. I would think FB could make things a bit more easy?
The Send and Share Dialogs are built for this (sharing a Website URL on a wall or send it to friends in a PM), just let him choose the friends in the popup. That way, you don´t even need to authorize the user, and you can´t get ALL friends anyway (only those who authorized the app too).
About the message parameter: You are not allowed to prefill the message, it has to be 100% user generated. See the Platform Policy: https://developers.facebook.com/policy
2.3 Ensure that all content in the user message parameter is entered by the user. Don’t pre-fill. This includes posts, messages, comments,
and captions.
The FB.ui Dialogs ignore the message parameter anyway.

Categories