1. Help Center
  2. Webhooks & Integrations
  3. Introduction to Webhook Templates

Integrate your Certainly bot with Centra

You can use our Webhook Templates to interact with Centra right from a Certainly chat. Doing so enables you to grab real-time data about customers, orders, and returns in order to add value to your bot conversations.

Below, we'll explain how to obtain your Centra API key and your endpoint <base>, which are essential in order to connect to your application. Then we'll explore the different API requests you can make to the Centra API using our Webhook Templates. 

Please note that you will require your own Centra account to follow the instructions in this article.

Obtain your Centra API key and endpoint <base>

Finding your Centra API key and endpoint <base> is the first step in connecting your Webhook Template to your Centra account, as every API call requires the use of an API endpoint that is specific to your account.

Please log in to the Centra platform, then navigate to System > Stores using the left-hand side menu.

GoToStore.png

This will take you to the Stores view of your dashboard where you'll see a list of all the currently active stores within your Centra platform.

Next, click on the store you want to use for the integration.

SelectStore.png

This will open a second panel on the right-hand side of your screen that contains general information for that store, store settings, as well as a list of all installed plugins. In this case, we are interested in the last section.

SelectPlugin.png

You'll need to select the plugin that you want to use. The Webhook Templates we've created on the Certainly Platform require the use of Centra's "Order API". Therefore, you'll want to choose a plugin that allows you to connect to the Order API. If you don't have a plugin set up, you can add a new plugin by selecting "+ Add plugin method".

Once you've selected the plugin, a new window will display the plugin settings, including the "Base URL" and "Secret API key".

ObtainingBaseAndSecret.png

With these two parameters collected, you can now configure the Webhook Templates and incorporate them into your bot conversation flow.

Check order status through Centra

This connection allows us to retrieve information regarding a user's order from the Centra Order API to inform about the order status. There are two different methods available to obtain this information, through the use of either the Order ID or the user's email address, both of which we'll explain below.

A basic example of this flow can be seen here:

mceclip6.png

Check order status (Order ID)

This first method is the simpler of the two to set up. It requires a simple flow that asks the user for the Order ID. Once the Order ID is obtained, you can use it to search for the order information.

  1. This example flow starts in the md>Start order status flow Module, directly asking the user if they have an Order ID to check the order status.

  2. If the user replies that they do have an Order ID, the flow proceeds to the next Module, <md>User has orderId. Here, we ask the user to provide the ID for their order. The answer is collected in a variable called order_id.
    mceclip2.png

  3. Next, we create an instance of the wh_iconCentra - Get Order (OrderId) Webhook Template, following the configuration outlined in the Webhook Template description. This Webhook uses the Centra Order API as well as the collected Order ID to retrieve information about a specific order.

  4. By default, the Webhook is configured to return the following variables that can be used in a conversation:
    ordered_products: Provides a list of all the products, including product name, variant, color, and size.
    order_status: Current status of the order.
    order_address: Includes the delivery address, city, state, ZIP code, and country.
    order_date: Date on which the order was created.
    order_shipment_date: Date on which the order was shipped.
    order_delivery_date: Expected delivery date for the order.

    You can choose what information you want to show to the customer. In the <md>Show order Module of our example flow, we've chosen to display the information in the following way:
    mceclip3.png

Check order status (User email)

This method is slightly more complex, as Centra's Order API does not allow for finding the order status for a specific user based on the user email. However, it's possible to establish a workaround to obtain order status information.

  1. In this example, we ask the user if they have access to the Order ID. In the case that they don't, we can ask for their email address and collect the user's reply in a variable called user_email, as shown in the <md>User has email address Module here:
    mceclip7.jpg

  2. For use in this Module, we also create an instance of the wh_iconCentra - Get CustomerId Webhook Template. Once we've collected the email address, we can launch the Webhook to collect the user's Centra ID.

  3. This ID can then be used in the Webhook fired in the next Module, <md>Check all orders. Here, we create an instance of the wh_iconCentra - Get All Orders for a Single Customer (CustomerId) Webhook Template, which will provide some basic information (Order ID and products contained in the order) for the last 3 orders made by this user.

    We can choose to show fewer, or configure the template so that it provides more orders. In this example flow, we are showing the user only their last order:
    mceclip8.png

    Please consider that this endpoint provides less information on the order status than when you search for the order using the specific Order ID. As such, it's a good idea to ask the user if they'd like additional information on that order.
    mceclip10.png

  4. If the user indicates that they want additional information, we can store the Order ID value for the order they require under the variable order_id. Then, we launch an instance of the wh_iconCentra - Get Order (OrderId) Webhook Template. This Webhook uses the Centra Order API as well as the collected Order ID to retrieve information about a specific order.
    mceclip11.png

  5. We can now provide all the details for this order in the next Module, <md> Show extra order details:mceclip12.png

Check return status through Centra

The Centra application also allows for the use of the Order API to get information on the status of a customer's return request. For this, you can set up a very simple flow that uses the Order ID of an order that has been returned to check its status.

A sample of the flow could look something like this:

mceclip13.png

  1. For this flow, the first step is to collect the Order ID of the product in the <md>Start return status flow Module. Here, we ask the user for their Order ID and collect the user's reply in a variable called order_id.

  2. Once we've collected the Order ID, we then create an instance of the wh_iconCentra - Get Returns (OrderId) Webhook Template and launch it in the next Module, <md>Check return status.
    mceclip14.png

    This Webhook returns two variables: return_completed, which is a boolean, and returned_products, which is a list of all the products included in that return process.

  3. We then use the return_completed variable to set up a connection in the <md>Return completed? Module, in which we send the flow to different Modules depending on whether the return has been completed or not.
    mceclip15.png

In each of these Modules, we then send a custom message to the user, indicating whether the return has been processed or not, as well as showing the products included in that return.

Send Centra discount vouchers through a chat conversation

The last flow we'll explore allows you to save a discount code inside of the bot, check if the customer has used this code before in any previous orders, and offer the code only to customers who've not yet used this code in any previous orders.

A simplified version of the flow could look something like this:

mceclip16.png

Now, let's dive deeper into the configuration of this flow:

  1. First, we need a variable that collects the user email before the "Check for discount codes" flow has started.

    This can be done either by collecting the email inside the conversation through the use of Collector Modules, or by passing the variable containing the user email directly from the website through the use of Custom Variables.

    The second method noted here would be especially interesting if the customer who is having the conversation with the bot has already logged in to your website as a registered user, as it will avoid the user having to input this data again.

  2. Next, we need to store the name of the Centra discount voucher we want to offer to the user during the conversation.

    This can be done through the use of a variable at any point of the conversation, although it is recommended that you do so in the starting Module, or whenever the "Offer discount voucher" flow begins. In this particular example, we set the variable in the <md>Inform cart status Module.

    It is important to note that this variable must be called voucher_used in order for the Webhook to function correctly.

    If the user confirms that they'd like to check out in this Module, we can set the variable and proceed to the next Module.
    mceclip17.png

  3. In the <md>Cart status Module, we show the user the products currently in their cart, then proceed to the next Module.

  4. This Module, <md>Check for vouchers, contains the necessary Webhooks.

    First, we need to create an instance of the wh_iconCentra - Get CustomerId Webhook Template so we can get the user ID of the user. After we have this, we can then create an instance of the wh_iconCentra - Check if a Discount Voucher Has Been Used Webhook Template.
    mceclip18.jpg

    This last Webhook will return "true" if the discount voucher we saved in our bot under the variable discount_used has been used before by the user in at least one of his previous orders.

    Knowing this, we establish a simple if condition to evaluate if the voucher was used before. If it has been used before, we proceed to the checkout flow. If it has not been used, we redirect the conversation to a new Module, <md>Offer discount voucher, where the bot informs the user that a discount is available, then takes them to checkout.
  5. >