How Can We Help?

Create a user by email

 
Email integration is a powerful feature of Deepser. It allows to insert into the system any kind of entity with a simple and fast configuration.
Usually, email integration is used to create Service Operations that represents the requests made by the customers via email.
It is possibile, using a dedicated mailbox, also to create users in the system.
Think about an automatic system implemented on an external application that sends formatted emails every time a user registers to the company site (or e-commerce).
By creating users that way we can provide automatically an account to the support portal Deepser.
To configure a mailbox select the grid IN from the menu System > Tools > Email > Mailbox.

 

Follow the settings of the screenshot above, changing host, user and password with the data of your mailbox.
The most important configuration to create users is then the System Data Tab.
Using this setting we can tell the system that every email read by that mailbox will generate an entity inside Deepser and we can also tell the data to fill the fields of that record.

 

Note: the field Outgoing Mailbox is not relevant for this guide, it is usually set to define the mailbox used to answer by the Service module.

 
The following data are the entry point to link an email to an entity of Deepser.
The field “Model” is the entity (the table of the database) of Deepser.
The Model Field and the Prefix will be used together to parse the email subject.
In few words, the field Prefix is a string used to tell Deepser: “Hey, after this string you will find a unique field of the record”. That unique field is the Model Field.
Deepser uses an internal algorithm and knows that has to read that specific field and if the value is inside the DB that record will be updated. If not, a new record will be created.
To better understand, let’s give an example.

 
In the system we have a user with username user.name.
We configure the IN email integration with: Model = DeepAdmin – User; Model Field = Username and Prefix: USR#, like in the example showed on the screenshot.
Now, an email is read from the mailbox. The subject of the email is New User: USR#user.name . Deepser understands that has to search the user entity and find a user with: username = user.name. This user exists, so Deepser will not create a new user but will update the existing user.
Then, an email with subject New User: USR#alva.edison . Deepser understands that has to search a user with: username = alva.edison. This user is not in the system, so Deepser will create a new user through an insert event.
 

Where can we define update or insert events?
In the tab System/Data we can see a filed called Insert and a field called Update.
This fields contain the code run after every email has been read by email integration.
To create a new user write in the field “Insert” this PHP code:
[php]
$mailSubject = $this->getMessage()->getSubject();
$mailBody = $this->getMessage()->getBodyText();

$row_data = explode(‘^’, $mailBody);

$userName = $row_data[0];
$firstaname = $row_data[1];
$lastname = $row_data[2];

$this->getModel()
->setUsername($userName)
->setFirstname($firstaname)
->setLastname($lastname)
->save();
[/php]

We are telling Deepser there is an email with a specific format that contains the data of a new user (we have to decide the format prior to implement the integration).
Now let’s schedule the job to read the mailbox.
In the tab Advanced set the value of the field Cron Expression

 

Now, we are telling Deepser to create a job, schduled every minute to read the mailbox.
Send a new email to the mailbox and let’s see what happens.

 

If everything is set the right way, a new user will be created in Deepser.

 

Previous Reset User Password
Table of Contents