Find contactId of currentUser

I’m new to Wix and want to send a triggeredEmail to the current contact (not member) using TriggeredEmails. emailContact( )

For this I need a contactId of the person who is currently on the site. I’m trying to usewixUsers.currentUser.id but it returns a very long id:

8d2c1a538d05944849f95da0574c7fef07c00bd6374f619dfdb94ad0881bfd0e69fe9e988ef328bc9fb1d1e4544967881e60994d53964e647acf431e4f798bcdf5d25541e3e1d0a198c992ae4bab57a241ce4f577cdc823fa275ef143557fbc47ce64d669e1fccac0af860f398a9ce0cdbadda5f88c4a42289a03ee78c18c24968809bbae20bbf8da72de39c808248d3

while contactId is a simple GUID like ‘8322fe9d-a9ae-4dd2-8496-b2cd6cc04736’

How can I get contactId of the current user?

The user id and contact id are different. You need to get the email of the current logged in user, then query it using wix-crm-backend queryContacts() function (This would be need to run on the backend) . When you do that, it shall return an object, which shall have the contact id.
This is a very old way

NEW WAY
You have to use the wix-members API to get the contact ID. Please find the code below

import { currentMember } from 'wix-members-frontend';

// ...

// Sample options value:
// {
//   fieldsets: [ 'FULL' ]
// }

currentMember.getMember(options)
  .then((member) => {
    const id = member._id;
    const fullName = `${member.contactDetails.firstName} ${member.contactDetails.lastName}`;
    return member;
  })
  .catch((error) => {
    console.error(error);
  });

This will return the contact id in the member object

@wixfreaks, thanks a lost for your answer.

currentMember.getMember() returns undefined for me as I technically don’t have a logged-in user. My scenario is:

  1. a new user fills and submits a form - a contact is created for them automatically in wix
  2. they go to another page of my site where I want to get contactId that was just created

I’ve seen that currentMember API is preferable now but my user is not a member but just a contact. Is it possible to get contactId of a user who is currently browsing and just became a contact?

Haven’t tried this myself but you can use the onContactCreated event handler to get and store the contactId from event.entity._id in a variable and then send a triggered email to the stored contact ID.