Automating trial creation

Last updated on

Written by Eoin Hinchy

We automate the entire trial creation process through a Tines Story. In this post, we explore what happens after you request a trial instance.

Storyboard 

When a user submits a request for a trial instance, the details are sent via Webhook to the “Receive trial request from wp” Action (“wp” here stands for WordPress). An HTTP Request Action, “Create new tenant” is then used to begin provisioning a trial instance. At Tines, we use Digital Ocean for hosting. The “Create new tenant” Action sends a request to the Create A new Droplet API endpoint. The Action configuration here looks like the below:

Based on the details submitted by the user during the trial request, a custom provisioning script is generated and submitted via the Digital Ocean user_data field. This script performs a number of functions, including ensuring that each tenant has the latest version of the product. When the script is complete, it sends details of the new instance to the “Receive tenant deployed webhook” Action.

An HTTP Request Action (“Rename tenant in DO”) is then used to update the tenant name from the temporary placeholder we set when the droplet was originally created. The Action config for this is below:

{
  "url": "https://api.digitalocean.com/v2/droplets/{{.receive_tenant_deployed_webhook.id}}/actions",
  "content_type": "json",
  "method": "post",
  "payload": {
    "type": "rename",
    "name": "{{.receive_tenant_deployed_webhook.tenant}}"
  },
  "headers": {
    "Authorization": "Bearer {% credential Digitalocean %}"
  }
}

We now get the IP address that has been assigned to the trial instance (“Get tenant IP”) and use it to create a new DNS record for the trial (“Create DNS entry”). The DNS entry allows the tenant to be accessed from https://trial-name.tines.io.

Two trigger Actions are then used to check whether everything worked as expected.

“Trigger if ok”: all the below logic rules must match for an event to be emitted.

{
  "rules": [
    {
      "type": "field==value",
      "value": "201",
      "path": "{{.rename_tenant_in_do.status}}"
    },
    {
      "type": "field==value",
      "value": "200",
      "path": "{{.get_tenant_ip.status}}"
    },
    {
      "type": "field==value",
      "value": "201",
      "path": "{{.create_dns_entry.status}}"
    }
  ]
}

“Trigger if not ok”: if any of the below logic rules match, an event will be emitted and an email will be sent to Tines Support (“Email support”) for manual follow-up.‍

  {
  "rules": [
    {
      "type": "field!=value",
      "value": "201",
      "path": "{{.rename_tenant_in_do.status}}"
    },
    {
      "type": "field!=value",
      "value": "200",
      "path": "{{.get_tenant_ip.status}}"
    },
    {
      "type": "field!=value",
      "value": "201",
      "path": "{{.create_dns_entry.status}}"
    }
  ]
  "must_match": "1"
}

If everything worked as expected, a welcome email will be sent to the requesting user with information on how they can access their trial (“Send welcome email”).

Additionally, when the trial was created as expected, information on the requesting user is added to our CRM (Hubspot) so we can better track trial requests and their statuses.

This is an early walkthrough of how we manage Tines trials as part of our DevSecOps program. The updated version is available here.

Built by you, powered by Tines

Talk to one of our experts to learn the unique ways your business can leverage Tines.