surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.2k stars 812 forks source link

is it possible to build Email template question using survey-js library? #2968

Open nagireddyg opened 3 years ago

nagireddyg commented 3 years ago

Are you requesting a feature, reporting a bug or asking a question?

question

What is the current behavior?

is it possible to create a email template question which should trigger on submit of the survey.The email template should contains, To Address, BCC and Body

Same like G-Mail or Outlook email template

the Email template should trigger on completion of survey

What is the expected behavior?

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

your_code_here

Specify your

andrewtelnov commented 3 years ago

@nagireddyg I would implement this task on your server. The correct way is to send e-mail when the survey response is submitted into your server. It is not a Survey Library task.

Thank you, Andrew

nagireddyg commented 3 years ago

@andrewtelnov The Email body will be designed while creating survey in survey design it self. The body should contains the values of few questions in the survey. if this is possible we can send email with this body content when the survey response is submitted. How can we achieve this task?

Email body:- Hello {question1} Welcome to the abcd....

Recognition on this visit:

  1. {question3}
  2. {question4}
  3. {question5}

Action Items on this visit:

  1. {question6}
  2. {question7}
  3. {question8}

Regards {question4}

andrewtelnov commented 3 years ago

@nagireddyg You can pass all needed information into your server from the client and then send e-mail.

Thank you, Andrew

nagireddyg commented 3 years ago

@andrewtelnov The email body should be like the above comment. The email body will change from survey to survey. We should provide an option to users to design email body. so that we will send this email body from client to server and then we will send email. How can we design the email body question in the ui?

nagireddyg commented 3 years ago

@andrewtelnov I could. able to design the email body using html question, but I could not get this html question response on submission of the survey.

nagireddyg commented 3 years ago

@andrewtelnov is it possible to design email body from survey design?

andrewtelnov commented 3 years ago

I do not understand, what do you mean by email body? You can use comment question type or setup a third-part text editor by using our custom-widget approach.

Thank you, Andrew

nagireddyg commented 3 years ago

@andrewtelnov the html question is solving my purpose but I could not get the html question response on submission of the survey?

andrewtelnov commented 3 years ago

html question is read-only. How could it solve your issue? I really do not understand what you are trying to achieve.

PS: You can always include into sending data any addition value, before sending it to your server. Here is the link to documentation.

Thank you, Andrew

nagireddyg commented 3 years ago

@andrewtelnov will you be able to join zoom call, so that I can explain my requirement?

nagireddyg commented 3 years ago

@andrewtelnov below is the json which I have designed

{ "title": "Email Notification", "completedHtml": "Hello
\nWelcome to the Field Assessment Email Notification

\n\nRecognition on this visit:
\n1. {to_email}
\n2. {bcc_email}
\n3. {subject_email}
\n

\nAction Items on this visit:
\n1. {to_email}
\n2. {bcc_email}
\n3. {subject_email}
\n\n

\nRegards
\n{bcc_email}", "pages": [ { "name": "page1", "elements": [ { "type": "panel", "name": "panel1", "elements": [ { "type": "text", "name": "to_email", "title": "To", "hideNumber": true }, { "type": "text", "name": "bcc_email", "title": "BCC", "hideNumber": true }, { "type": "text", "name": "subject_email", "title": "Subject", "hideNumber": true }, { "type": "html", "name": "body_email", "visibleIf": "{to_email} notempty and {bcc_email} notempty and {subject_email} notempty", "title": "Body", "hideNumber": true, "html": "Hello
\nWelcome to the Field Assessment Email Notification

\n\nRecognition on this visit:
\n1. {to_email}
\n2. {bcc_email}
\n3. {subject_email}
\n

\nAction Items on this visit:
\n1. {to_email}
\n2. {bcc_email}
\n3. {subject_email}
\n\n

\nRegards
\n{bcc_email}" } ], "title": "Send us your contact information (optionally)", "innerIndent": 1 } ] } ] }

tsv2013 commented 3 years ago

SurveyJS allows you to get answers on given questions or to construct a form to enter some data. Entered data/answers can be obtained via the survey.data property.

Here is the border of SurveyJS functionality.

After that you can do with the answers anything you need using your custom code: construct email text from the answers and send it using any 3rd party library (client or server - side)

NHSNeil commented 3 years ago

We have added a new Property on the survey using...

SurveyKo .Serializer .addProperty("survey", { name: "Template:text", default: "{}", category: "general" });

This allows the designer to add templated text into the form definition and it will pass along with the saved form data when a form is completed. We then have an API that we developed, based on scriban, that takes the saved survey data and the template from the form definitions to return a finished doc based on the template.

I would never expect a survey designer app to have all that functionality built in.