Email Automation from CMS submission

Hi,

I am trying to send an email automation to person A to alert them that person B has sent them a message and vise versa.

Person B (buyers) sends a message by submitting a form into the CMS. The “listing” field in the CMS is linked to person a’s (sellers) email address (it displays as their email address in the CMS field)

Person A then replies by submitting a message back into another field in the same CMS.

How can i notify a seller that a buyer has messaged them and a buyer that the seller has responded.


Many thanks

Hi, Aiden12345 !!

I think it would be best to automatically send an email when there is a change in the content of the collection. To detect changes in the collection, try adding a data hook (after update) to the collection. When you add the data hook, a JavaScript file called data.js will automatically be generated in the backend code. You can add the code for sending emails inside the automatically generated function, like the one below.

export function yourCollectionName_afterUpdate(item, context) {
	//TODO: write your Email code here...
}

↓Reference URL for sending emails in Wix
triggered-emails

Thanks for that!

Is there a way to pull the email address from the cms field?

Hi, Aiden

I haven’t tested it, but considering that “item” refers to the updated item within the collection, So I believe the “item” object also includes the email address you want. :wink: