Adding to a collection responses from email

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