Hi to all
I need help in setting up the code to make a notification by mail
to a Lead form I build - I 'm not strong on code and learning on the way -
I have the example code for the process IF SOMEONE CAN HELP ME WITH SETTING UP
THE CODE ONE TIME PLEASE
Thanks in advance
Hi Mia,
Can you show us here what you’re trying to do exactly. For example, a page screenshot and the code you’re trying to integrate into it?
btw - make sure you’re not pasting any secret API keys in case they’re a part of your code.
Ah, I just saw your other thread with Yoav.
Unfortunately, we can’t actually write your code for you. To get started you could try reading up on the “coding” section in our documentation .
This example ventures fairly deep into the JavaScript side of the system. You might want to find a developer for an hour or two of work which should be sufficient to get this running.
Hi Mia,
Following a suggestion by Yoav on a different post - Using a service like ifttt.com to automate this is something you might be able to get working fairly easily and with two or three lines of code.
The general idea:
Setup
- Set up an account on ifttt.com
- Configure the ifttt maker webhook to accept http calls for you
- Configure ifttt gmail channel so that it has access to send email on your behalf
- Write a ‘recipe’ where IF: webhook THEN: gmail. Give the webhook a name like ‘sendLeadNotification’. and have the ‘then’ part send you an email with the notification.
The Code:
Your site makes an http call to ifttt using JavaScript and wix-fetch.
import {fetch} from "wix-fetch";
const secretIFTTTKey = '************'; //replace these ****** with the key you get from IFTTT maker service
const eventName = 'sendLeadNotification'; //make sure this matches what you set up in the IFTTT maker service trigger
export function leadButton_onClick() { //make sure you wire the button to an onClick event using its properties panel (right click -> properties)
fetch('https://maker.ifttt.com/trigger/' + eventName + '/with/key/' + secretIFTTTKey);
}
that’s it, you’re done.
One big Caveat - it’s a bad practice to use secret keys in the page code since a malicious visitor can snag it using the browser inspection tools. It can be secured using WixCode backend code, but I don’t want to make you delve any deeper into JavaScript land than you have to, and if this is all you’re doing with the key, the risk is small (I believe the worst case scenario is that someone spams you with notifications and you turn it off). Anyway - give it a thought before you publish this live.
hope that at least points you in the right direction.
good luck!
Uval
We’ve just added a new article on this subject:
https://support.wix.com/en/article/sending-an-email-on-form-submission