Implementation
Scenarios
This section details three scenarios: one with the typical workflow and two dealing with common errors during the customer journey.
Ideal Scenario
- A person walks in front of the coffee machine.
- The AiFi system internally tracks the person.
- An order is made by hitting a button.
- The coffee machine sends a payload to AiFi containing the information “PUT” (see page 2 of the appendix API docs).
- AiFi matches the event at time T with the person and adds it to their basket.
- The coffee is delivered successfully.
- 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
- A person walks in front of the coffee machine.
- The AiFi system internally tracks the person.
- An order is made by hitting a button.
- An error is displayed on the coffee machine—the coffee can't be delivered.
- The coffee machine doesn't send any information to AiFi.
- 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.
- A person walks in front of the coffee machine.
- The AiFi system internally tracks the person.
- An order is made by hitting a button.
- The coffee machine sends information to AiFi using the PUT API (see appendix).
- AiFi matches the event at time T with the person and adds it to their basket.
- The coffee isn't delivered due to an error.
- The coffee machine sends cancellation information to AiFi (refer to the Pull API cancel event in the appendix).
- AiFi removes the product from the person’s basket.
- 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
- The coffee machine has recipes.
- Each recipe is assigned a unique ID (e.g.,
0001230001). - These recipes are added to our item database under their barcode (unique ID), with a placeholder weight and price (used for customer billing).
- 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:
- Support RESTful inbound communication over HTTP and optionally HTTPS (to receive information from AiFi).
- Support sending RESTful requests over HTTP and optionally HTTPS to the AiFi system (to send information to AiFi).
- 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.
- 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).