How to, Workflow designer

Advanced Vtiger mailscanner with workflow designer: an improved way to manage tickets from email

Workflow designer module includes a powerful mailscanner that allow you to substitute standard vtiger mailscanner to achieve better results!

Thanks to this module you can for example manage the complete flow of ticket with emails. Customers can create / update their ticket through email, and conversation is stored in comments.

Basically to achieve this result:

  1. you need Workflow designer module for vtiger open source
  2. you have to set an imap provider in workflow designer provider manager
  3. You have to set a mailscanner in workflow designer that take email from provider manager and execute a workflow
  4. you have to create a workflow that will be executed by mailscanner

The flow: manage ticket throught email

Use customer portal it’s a good solution to manage our relation with customers, but lot of them don’t like to login inside a portal to create / update their ticket. To improve customer experience you can use your vtiger as a complete ticketing system managed with email as main channel to communicate with your customers.

So customer should:

  • create a ticket sending an email to a specific email address like
  • get update from email
  • give answer and update ticket throught email

Now we will explain to you how you can do that thanks to mailscanner of workflow designer module.

Setting provider

First of all you have to set your IMAP provider in provider manager:

How to set mailscanner

In order to get and read email you have to set your mailscanner as following:


To get access to Mail meta information, you should add environment variables on the right side. For our example, please choose the following:

Subject -> $env[“subject”]
Email of sender -> $env[“sender”]
Body of email -> $env[“body”]
Name of sender -> $env[“sendername”]
Attachment -> attachment_*

Mailscanner will store this values every time the Workflow is executed.

A basic workflow to manage ticket with vtiger workflow designer mailscanner

To manage a complete cycle of ticket with email we can create a workflow that:

  1. check if email received is a new ticket or is an answer to existing ticket (if subject contain TT then is an answer to existing ticket)
  2. if it’s a new ticket:
    1. check in VtigerCRM Contacts if there is a contact with same email, otherwise create this contact.
    2. create a ticket and fill fields with values taken from mailscanner and previous blocks.
    3. Store email to contact
    4. attach all mail attachments to the ticket as documents
  3. if it’s an existing ticket than get ticket id and add a comment with body of email

Note: notification email to contact should contain in subject Ticket number: TTxxx, and this part of subject should not be change to recognize that it’s an answer to ticket, like in other Ticket systems.

Note 2: to answer to customer, you can use comment and create a Workflow that start with new comment or create a workflow that use block “Request value from user” to get text and then send it by email


Here the complete workflow:



You can download workflow, unzip file and load it in your workflow designer:

Download workflow



Other example of things you can do with mailscanner

UsingĀ  workflow designer vtiger mailscanner allow you to achieve lot of possible results, in example:

  • create lead scanning email received from a websiteform
  • scan email from external software and yo use content of email for your needs
  • get file via email and attach to records
  • and so on…

If you have question about this topic please add a comment, we will give you all information you need!

  • Ian says:

    All set properly but getting following error:

    Database Error in Query SELECT module_name FROM vtiger_wf_settings WHERE =

    You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ” at line 1O:12:”PearDatabase”:17:{s:8:”database”;O:12:”ADODB_mysqli”:91:{s:12:”databaseType”;s:6:”mysqli”;s:12:”dataProvider”;s:5:”mysql”;s:11:”hasInsertID”;b:1;s:15:”hasAffectedRows”;b:1;s:13:”metaTablesSQL”;s:131:”SELECT TABLE_NAME, CASE WHEN TABLE_TYPE = ‘VIEW’ THEN ‘V’ ELSE ‘T’ END FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=”;s:14:”metaColumnsSQL”;s:22:”SHOW COLUMNS FROM `%s`”;s:12:”fmtTimeStamp”;s:13:”‘Y-m-d

    April 19, 2018 at 3:02 pm
    • Simone Travaglini says:

      Hi Ian, where do you get this error?

      April 19, 2018 at 4:14 pm
  • Garry B. says:

    How to relate attachment to new comment?

    April 26, 2018 at 5:06 am
    • Simone Travaglini says:

      as you can see in following image you can also add an attachment:
      vtiger add comment
      And you can choose from different type of attachment:
      add-attachment-to comment vtiger
      Of course file taken from email as attachment are in filestore, so you can use it as attachment of comment, using ATTACH FILE FROM TEMPORALY FIRESTORE.

      April 26, 2018 at 7:19 am
  • Garry B. says:

    In version for 6.5 comment task has no the same fields as for v.7….. it lack of fields:
    – Define Authortype of comment
    – Attach file to comment

    April 26, 2018 at 1:32 pm
    • Simone Travaglini says:

      Hi GArry,
      in Vtiger 6.5 attachment in comments are not supported. If you need this feature we suggest you to switch to Vtiger 7.1.
      About define author in comment it’s not supported in workflow designer for vtger 6.x, but only for vtiger 7.x. New functions normally are released only for vtiger 7 version. If some new feature is absolutely need from a customer also in Vtiger 6 (that is an old version of vtiger) we can discuss a fair price to backport also to this old version.

      April 27, 2018 at 8:46 am
  • Garry B. says:

    Wind of change coming than… thank you for clarification.

    April 27, 2018 at 10:08 am
    • Simone Travaglini says:

      Hi garry,
      Yes, it’s time to move to version 7 of vtiger becouse now a stable version.

      April 27, 2018 at 10:13 am
  • Somsak Art says:

    A bit tricky to get update ticket with the name of author of ticket and the same tie attachment sent by email.
    Also tried to attach file to comment from crm and email sent automatically to contact dont get this attachment.
    I followed env variable in mailscanner (sendername) and still workflow dont set name of author. Maybe you can recreate all necessary create/update in sample workflow?

    May 9, 2018 at 2:32 pm
    • Simone Travaglini says:

      Hi and thanks for your question.
      First of all you have to do a global search between all your vtiger contacts and find the one with email address matching with email sender:

      Now global search bloch store results in an array, where id of contact is $env[“contact”][“ids”][0]

      So you can set comment creation as following

      May 9, 2018 at 3:37 pm
  • GBrightonx says:

    $env[“contact”][“ids”][0] should not be with return statement? Can you recreate such workflow as a example?
    Here is also issue with adapting mailscanner


    May 9, 2018 at 4:04 pm
    • Simone Travaglini says:

      It’s not necessary use return.

      Please check this updated version:
      Download workflow

      If any issue please let us know, we will help!

      May 10, 2018 at 7:59 am
      • Simone Travaglini says:

        Hi I’ve updated version becouse found an error in regex block that’s why update ticket was not working. The new version is tested and works. Can you update with new version? Just re-download!

        May 14, 2018 at 8:07 am
  • Dessi says:

    Yes, fully functional workflow template would be convenient

    May 10, 2018 at 3:51 am
    • Simone Travaglini says:

      Ok just created an updated version, please check:
      Download workflow

      May 10, 2018 at 7:56 am
      • Simone Travaglini says:

        Hi I’ve updated version becouse found an error in regex block that’s why update ticket was not working. The new version is tested and works. Can you update with new version? Just re-download!

        May 14, 2018 at 8:06 am
  • Dessi says:

    Error during Import
    Exported with Workflow Designer Version 7.02.01. You need at least this version to import!

    Latest available version is 7.01.10

    May 10, 2018 at 8:22 am
    • Simone Travaglini says:

      Try now, please. Download again and should works!

      May 10, 2018 at 8:36 am
  • Dessi says:

    By entering filestore ID three times: attachment_1, attachment_1, attachment_1, you limiting setting attachment to three files? What is behind multiplying filestore ID?

    May 10, 2018 at 9:15 am
    • Simone Travaglini says:

      Hi I added
      so if there are 3 attachment all will be add
      If you need you can add also other attchment_4, 5, … n
      in this case we need to do in this way becouse not possible use loop like we did for document attachemnt in ticket. An alternative solution is to add attachment as document connected directly with ticket, like in creation of ticket. In this second case you can use loop!

      May 10, 2018 at 10:09 am
  • Piter says:

    If i send email it converting to ticket correctly, but if email have attachment it not c9nverting. I checked carefully all conditions, env entries in mailscanner are exactly as recommended here…. any advise?

    May 11, 2018 at 4:49 am
    • Simone Travaglini says:

      Hi piter,
      very hard to say. Can you open a ticket with credential of you instance so we can check?

      May 11, 2018 at 8:35 am
    • Simone Travaglini says:

      Hi peter, in other customer seems that issue was related to file permission on server… please check!

      May 16, 2018 at 7:12 am
  • Ian says:

    Simone, latest version of workflow is in line with presented above mailscanner screenshot? If not, can you please quote precisely environment values used in mailscanner related to latest workflow?

    May 12, 2018 at 7:17 am
    • Simone Travaglini says:

      Hi environmental variable are the same. But I’ve just update and tested a new version becouse found an issue in regex block that can cause problem with update ticket. Please download new version:

      May 14, 2018 at 8:10 am
  • Ian says:

    The point is i can confirm that configuration of latest tickets workflow is not working. Actually, I think that at least all core vtiger workflows should be reproduced as a default start set of Workflow Designer basic/professional… that would make life easier for newcomers and good starting point for self education.

    May 12, 2018 at 7:39 am
    • Simone Travaglini says:

      Thanks for suggestion, could be a good idea

      May 14, 2018 at 8:07 am
  • Ian says:

    I checked second block and function ending with: ======= return “no;” ============
    Even I correct error workflow still not attaching files. I guess it wasnt tested?

    May 13, 2018 at 9:02 am
    • Simone Travaglini says:

      Hi I’ve updated version becouse found an error in regex block that’s why update ticket was not working. The new version is tested and works. Can you update with new version? Just re-download!
      If any issue please create a ticket we will check.

      May 14, 2018 at 8:11 am
  • Ludwejik Diret says:

    Not sure it is workflow design issue or internal Workflow Designer error, but in my customer instance it not work too

    May 14, 2018 at 4:36 am
    • Simone Travaglini says:

      Hi can you download again and test?
      If issue can you give more info about error you get?

      May 14, 2018 at 8:35 am
  • Ludwejik Diret says:

    Thank you Simone, but it still invalid. When you send email without attachment it creating ticket. If you attach for instance txt file it will basically not create ticket…. and again, if customer respond on the email with ticket number in subject and attach file, it will not update comment. But if response is without attachment, it will add new comment to ticket…. wondering where is glitch…

    May 14, 2018 at 9:40 am
    • Simone Travaglini says:

      I’ve tested and at my side is working… can you check if env variable are ok? If you can’t solve please create a ticket and give access to your instance, we will check.

      May 14, 2018 at 9:51 am
    • Simone Travaglini says:

      Are you sure you are using last version?

      May 14, 2018 at 9:52 am
    • Simone Travaglini says:

      Hi another customer resolved changing permission on file on server… could be same problem? Standard upload of file works?

      May 15, 2018 at 10:20 am
  • Ludwejik Diret says:

    yp…. I fixed attaching file to initial email (when ticket is created) by changing name of env. in “Search sender” right before “create comment” block to be contactid1 (it was duplicate env id)
    But if I respond to this ticket notification and I attach another file, comment will not be created.

    May 14, 2018 at 10:22 am
    • Simone Travaglini says:

      changing env variable should be not necessary…
      If you change env variable in a block you should change also in other block where is used…
      In ticket notification you send in subject number of ticket in form TT123 ? Becouse to update WF check if in subject there is number of ticket in this form and use it to find the ticket to update… Did you try to click on statistic to see what route take the workflow and where stops?

      May 14, 2018 at 11:14 am
  • GBrightonx says:

    I agree, if email have attachment workflow don’t create nor update ticket

    May 14, 2018 at 10:38 pm
    • Simone Travaglini says:

      Hi did you check latest version, becouse is tested and works.

      May 15, 2018 at 7:15 am
  • GBrightonx says:

    Is this correct?:

    if($env[“ticket”] == “”) {
    return “yes”;

    return “no;”

    May 14, 2018 at 10:43 pm
    • Simone Travaglini says:

      This block value if env variable “ticket” is empty or not, if not means that it’s a ticket update.

      May 15, 2018 at 7:16 am
  • tonysandman999 says:

    semicolon inside quotation mark?

    May 15, 2018 at 3:07 am
  • tonysandman999 says:

    Simone, can you get us screenshot of your mailscanner Workflow Assignement env. variables?

    May 15, 2018 at 7:29 am
    • Simone Travaglini says:

      IT’s solved, correct?

      May 15, 2018 at 10:20 am
  • tonysandman999 says:

    Yes, fixed. Files privileges change fixed it. This is common cause of issues especially when server is under development/testing and admins messing around with limited attention.
    Simone, thanks for support. Stuff is really good.

    May 15, 2018 at 11:23 pm
  • GBrightonx says:

    O.o you are right…. the only one I noticed is that when user commenting ticket and attaching file, this file is not sent to contact. How to do it?

    May 17, 2018 at 7:12 am
    • Simone Travaglini says:

      this is not possible… That’s why we use WFD also to solve this topic. How? We use request values form users block, inside a WFD triggered manually with a button. In this WF we ask for message, file, and then we can manage as variable and use to compile email.

      May 21, 2018 at 9:35 am
  • GBrightonx says:

    Any chance to get this in above workflow?

    May 21, 2018 at 12:14 pm
    • Simone Travaglini says:

      We will consider for next release.

      May 22, 2018 at 2:16 pm
Leave A Comment

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.