Send Formyoula Email via JavaScript

The Formyoula email connection can be triggered using the following email send API.

Please provide the form template ID and the form email connection ID in your POST request.

"api/templates/:form_template_id/connections/:form_connection_id/email"

Sending email with an existing form entry Id.

// Set necessary Ids
var email_template_id = '';
var email_connection_id = '';
var email_form_entry_id = '';

// Call Email API
$.ajax({
  method: 'post',
  url: 'https://api.formyoula.com/api/templates/' + email_template_id + '/connections/' + email_connection_id + '/email',
  dataType: 'json',
  data: {
    form_entry_id: email_form_entry_id
  }
})
// Call When Done
.done(function (response) {
  console.log('Callout Response:', response);
})
// Call When Request Failed
.fail(function (error) {
  console.log('Callout Error:', error);
});// END AJAX Call

Sending email with a form entry in progress, i.e. unsubmitted.

// Call Email API
$.ajax({
  method: 'post',
  url: 'https://api.formyoula.com/api/templates/5fad0dd5f0f248001e90be22/connections/60278d9863163c002fd118ac/email',
  dataType: 'json',
  data: {
    form_entry: window.formyoula.form_entry.toJSON()
  }
})
// Call When Done
.done(function (response) {
  console.log('Callout Response:', response);
})
// Call When Request Failed
.fail(function (error) {
  console.log('Callout Error:', error);
});// END AJAX Call

The Email Connection Id will be the last Id in the URL:

image