Skip to main content

Implementation

Scenarios

This section details three scenarios: one with the typical workflow and two dealing with common errors during the customer journey.

Ideal Scenario

  1. A person walks in front of the coffee machine.
  2. The AiFi system internally tracks the person.
  3. An order is made by hitting a button.
  4. The coffee machine sends a payload to AiFi containing the information “PUT” (see page 2 of the appendix API docs).
  5. AiFi matches the event at time T with the person and adds it to their basket.
  6. The coffee is delivered successfully.
  7. Regardless of whether the coffee is picked up, the client has it in their cart and is charged for it upon exit.

Error Flow Scenarios

Scenario #1: Unable to Order

  1. A person walks in front of the coffee machine.
  2. The AiFi system internally tracks the person.
  3. An order is made by hitting a button.
  4. An error is displayed on the coffee machine—the coffee can't be delivered.
  5. The coffee machine doesn't send any information to AiFi.
  6. The customer can't order coffee, so no order is made.

Scenario #2: Error After Order

info

See the last image for a detailed solution.

  1. A person walks in front of the coffee machine.
  2. The AiFi system internally tracks the person.
  3. An order is made by hitting a button.
  4. The coffee machine sends information to AiFi using the PUT API (see appendix).
  5. AiFi matches the event at time T with the person and adds it to their basket.
  6. The coffee isn't delivered due to an error.
  7. The coffee machine sends cancellation information to AiFi (refer to the Pull API cancel event in the appendix).
  8. AiFi removes the product from the person’s basket.
  9. The client isn't charged upon exit.

Implementation - Overview

Communication: RESTful Protocol

All endpoints are expected to include the following header:

Authorization: Bearer <unique-auth-token-provided-by-aifi>

Event Creation

  • Method: PUT
  • Endpoint: https://aifi-server:3000/v1/events
  • Content-Type: application/json

Example Payload:

{
"Event time": "T",
"id": "UUID_ABC",
"items": "1 mocca"
}

Note: The communication protocol is RESTful (see page 3 of the appendix API docs). The timestamp must be in seconds.

Event Cancellation

  • Method: PATCH
  • Endpoint: /v1/events/cancel
  • Content-Type: application/json

Example Payload:

{
"Event id": "UUID_ABC"
}

Implementation - Recipes as Products

Product Mapping from Coffee Machine to AiFi System

  1. The coffee machine has recipes.
  2. Each recipe is assigned a unique ID (e.g., 0001230001).
  3. These recipes are added to our item database under their barcode (unique ID), with a placeholder weight and price (used for customer billing).
  4. The coffee machine sends a single recipe (in the simple case). Refer to the examples from the screenshots provided.

Example: An espresso with double milk is represented by the recipe ID 3212345.

{
"products": [
{
"id": "3212345",
"quantity": 1
}
]
}

Implementation - Summary for Coffee Machine

The coffee machine provider must:

  1. Support RESTful inbound communication over HTTP and optionally HTTPS (to receive information from AiFi).
  2. Support sending RESTful requests over HTTP and optionally HTTPS to the AiFi system (to send information to AiFi).
  3. Create exactly one event per coffee order (“hitting the button”), within 1 second (preferably 0.5 seconds) of the button press. The timestamp must be accurate within 1 second of the actual event and synchronized with local time, for example, through NTP.
  4. Provide AiFi with a list of IDs for all the ingredients that will be sent in advance, to input them into the Product Repository (AiFi internal and/or Shopify).

Example Diagram