Adding to a collection responses from email

Hi,
After my user performs an action, he is sent an email through wix.
In this email he should answer a question, when pressing on Yes or No, he should be directed to a page (link).
Is there any way I can know any information about this user, his email for example so i can enter it into the wix collection?

1 Like

Hi Anatarad,

One thing you can do is to add variables to your triggered email , for examaple ${linkNo} and ${linkYes}.
In your code, first get the user’s email, and then use it in the variables in the emailUser function:

import wixUsers from 'wix-users';

$w.onReady(function () {
 let user = wixUsers.currentUser;
 let userId = user.id;
 user.getEmail()
 .then((email) => {
   let userEmail = email;
   wixUsers.emailUser("emailAplic", userId, {
     "variables": {
       "linkNo": "https://example.wixsite.com/mysite/answerPage?answer=no&email=" + email,
       "linkYes": "https://example.wixsite.com/mysite/answerPage?answer=yes&email=" + email
                }
            });
        })
})

And in the answer page, use the wixLocation.query property to get an object with the answer and the email that was sent in the variable.
Note that when setting up the triggered email, you need to insert a Text element with the value of the variable name, ${linkYes}. for more information about that subject you can check out this thread.

  • Lior

This is great! Thank you very much! I will try it and let you know

1 Like

Hi Lior, It worked great but i got stuck on the “inserting a text element with the value of the variable name” - I checked the thread that you mentioned, but it seems they were able to implement it only with sendGrid… Can you please elaborate on “inserting a text element with the value of the variable name” ?

@anatarad
Like this, where you edit your triggered email

-Lior

@liorwi Yes, this is exactly what I did but then my whole link is displayed in the email and not just a shortcut saying “press here” or “Yes” / “No”. The link includes many parameters so it is very long and definitely not displayable… How can i display a text such as “Yes” and “No” that when the user presses on them, he is redirected to the link

@anatarad Presently, this cannot be done, you could write something along the lines of ‘press here for yes’ and underneath it the long link.

@liorwi do you mean it will look like this:
… If you are interested please press here - LONG LINK that looks like this https://www.xxxx.org/w2yes?request=2950af16-6fdd-4604-9d2d-300b4e4fd4c
if you are not interested please press here
https://www.xxxx.org/w2no?request=2950af16-6fdd-4604-9d2d-300b4e4fd4c

is this what you mean? no workaround this?

@liorwi I’ve added long URLs to the email. It will be great to have the possibility to format the parameters in the email to buttons or at least links.

@anatarad You can suggest this feature in the Community Features Request! :slight_smile: