Appuntamento dal dentista

Immagina di chattare con un bot che gestisce le prenotazioni del tuo dentista. Vuoi richiedere un appuntamento e il bot ti risponde con un messaggio che contiene due opzioni: programmare un appuntamento nel prossimo orario disponibile, oppure scegliere una data e un’ora specifica.

<message to="user@wfp" id="51c9b72c-f2f1-4e8d-927b-33401065cf0f-211610484933107" type="chat">
    <thread>9e036646-48a9-477d-a165-6feaea487c76</thread>
    <body>{
       "arguments": {
            "content": [
              {
                "type": "chat_text",
                "text": "Sure, we can schedule an appointment!"
              },
              {
                "type": "chat_text",
                "text": "Would you like to choose a date and time, or use the next available slot?"
              }
            ],
            "layout": {
              "location": "in",
              "selectionMode": "button",
              "orientation": "vertical"
            },
            "inputData": {
              "choice": {
                "visibilityAfterSubmit": "block",
                "list": [
                  {
                    "command": "next_slot",
                    "content": [
                      {
                        "type": "chat_text",
                        "text": "Next available slot"
                      }
                    ],
                    "interaction": {
                      "type": "send_message",
                      "content": [
                        {
                          "type": "chat_text",
                          "text": "I'd like to schedule an appointment as soon as possible",
                        }
                      ]
                    }
                  },
                  {
                    "command": "choose_datetime",
                    "content": [
                      {
                        "type": "chat_text",
                        "text": "Choose date/time"
                      }
                    ],
                    "interaction": {
                      "type": "input_date",
                      "options": {
                        "dateType": "datetime",
                        "minStartDate": "2019-03-12",
                        "maxStartDate": "2019-03-12",
                        "minEndDate": "2019-04-12",
                        "maxEndDate": "2019-04-12",
                        "minStartTime": "09:00:00",
                        "maxStartTime": "09:00:00",
                        "minEndTime": "18:00:00",
                        "maxEndTime": "18:00:00"
                      },
                    }
                  }
                ]
              }
            },
           "data": {
             "apiVersion": 3,
             "appVersion": "0.0.1",
             "os": "android",
             "token": "token",
             "useChatDynamic": true
           }
         },
         "chat_type": "chat",
         "creation_date": "2024-10-14T17:54:40.8070000Z",
         "domain": "chat",
         "identifier": "0b6685ba-7118-4a1d-84ba-138f328ec54e-211610540337024",
         "language": "eng",
         "type": "chat_dynamic",
         "version": "1.0"
       }
    </body>
 </message>

Se premi il pulsante con l’etichetta “Scegli data/ora”, il client ti mostrerà un selettore di data/ora. Una volta effettuata la selezione, ad esempio se hai scelto il 15 marzo alle 15:00, il client invierà il seguente messaggio:

<message to="bob@wfp" id="51c9b72c-f2f1-4e8d-927b-33401065cf0f-211610484933107" type="chat">
    <thread>9e036646-48a9-477d-a165-6feaea487c76</thread>
    <body>{
       "arguments": {
            "selectedChoices": ["choose_datetime"],
            "content": [
                {
                  "type": "chat_date",
                  "dateType": "datetime",
                  "minStartDate": "2019-03-15",
                  "maxStartDate": "2019-03-15",
                  "minEndDate": "2019-03-15",
                  "maxEndDate": "2019-03-15",
                  "minStartTime": "15:00:00",
                  "maxStartTime": "15:00:00",
                  "minEndTime": "15:00:00",
                  "maxEndTime": "15:00:00"
                }
              ]
            },
           "data": {
             "apiVersion": 3,
             "appVersion": "0.0.1",
             "os": "android",
             "token": "token",
             "useChatDynamic": true
           }
         },
         "chat_type": "chat",
         "creation_date": "2024-10-14T17:54:40.8070000Z",
         "domain": "chat",
         "identifier": "0b6685ba-7118-4a1d-84ba-138f328ec54e-211610540337024",
         "language": "eng",
         "type": "chat_dynamic",
         "version": "1.0"
       }
    </body>
 </message>