การอัปเดตคำสั่งซื้อแบบไม่พร้อมกัน

หลังจากลูกค้าส่งคำสั่งซื้ออาหารแล้ว คุณสามารถส่งข้อความอัปเดตคำสั่งซื้อไปยังบริการสั่งอาหารจากต้นทางถึงปลายทางเพื่อแจ้งให้เราทราบถึงการเปลี่ยนแปลง

สาเหตุที่พบบ่อยในการส่งการอัปเดตคำสั่งซื้อมีดังนี้

  • เวลาที่จะได้รับสินค้าโดยประมาณสำหรับคำสั่งซื้อจะพร้อมใช้งานหรือมีการเปลี่ยนแปลง
  • สถานะของคำสั่งซื้อมีการเปลี่ยนแปลง
  • ระบบไม่สามารถดำเนินการตามคำสั่งซื้อได้อีกต่อไป
  • ราคาของรายการในเมนูที่รวมอยู่ในคำสั่งซื้อมีการเปลี่ยนแปลง
  • ลูกค้ามีวิธีใหม่ในการจัดการคำสั่งซื้อ เช่น หมายเลขโทรศัพท์ของฝ่ายสนับสนุนลูกค้าหรือร้านอาหาร
  • ใบเสร็จสำหรับคำสั่งซื้อจะพร้อมใช้งาน

ส่วนถัดไปจะแสดงรายละเอียดเกี่ยวกับวิธีจัดการสถานการณ์ต่างๆ เหล่านี้โดยใช้การอัปเดตคำสั่งซื้อ

สถานะการสั่งซื้อที่เปลี่ยนแปลง

คำสั่งซื้อมีสถานะได้ 6 สถานะ สถานะเหล่านี้และการเปลี่ยนสถานะที่เป็นไปได้จะแสดงอยู่ในแผนภาพต่อไปนี้

การเปลี่ยนสถานะการสั่งซื้อ

เมื่อลูกค้าส่งคำสั่งซื้อเป็นครั้งแรก คำสั่งซื้อจะเริ่มมีสถานะเป็น CREATED, CONFIRMED หรือ REJECTED คุณส่งข้อความอัปเดตคำสั่งซื้อเพื่ออัปเดตสถานะของคำสั่งซื้อได้ ตราบใดที่การเปลี่ยนสถานะนั้นถูกต้อง CREATED state จะใช้เมื่อแพลตฟอร์มของพาร์ทเนอร์ไม่สามารถยืนยันหรือปฏิเสธคำสั่งซื้อได้ทันที ตัวอย่าง Use Case คือเมื่อลูกค้าสั่งซื้อผ่านผู้รวบรวมข้อมูลการนำส่ง ผู้รวบรวมข้อมูลการนำส่งจะรับการนำส่งจาก Google แล้วส่งข้อมูลไปยังร้านอาหาร เมื่อร้านอาหารได้รับและยืนยันความพร้อมจำหน่ายสินค้าแล้ว สถานะจะเป็น CONFIRMED มิเช่นนั้นจะเป็น REJECTED

คำสั่งซื้อที่อยู่ในสถานะ CONFIRMED จะเปลี่ยนเป็นสถานะ IN_PREPARATION ต่อไป ให้ใช้สถานะ READY_FOR_PICKUP หรือ IN_TRANSIT โดยขึ้นอยู่กับว่าคำสั่งซื้อเป็นแบบไปรับที่ร้านหรือจัดส่งถึงที่ เมื่อนำส่งหรือรับอาหารแล้ว ระบบจะตั้งค่าคำสั่งซื้อเป็นสถานะ FULFILLED

หากอนุญาตให้ลูกค้ายกเลิกคำสั่งซื้อได้ คุณจะใช้สถานะ CANCELLED ได้ คุณยกเลิกคำสั่งซื้อได้ขณะที่อยู่ในสถานะ CREATED, CONFIRMED, IN_PREPARATION, READY_FOR_PICKUP หรือ IN_TRANSIT บริการการสั่งซื้อจากต้นทางถึงปลายทางควรคืนเงินให้คุณโดยขึ้นอยู่กับนโยบายการยกเลิกและสถานะการชำระเงิน ณ เวลาที่ยกเลิก

บริการการสั่งซื้อจากต้นทางถึงปลายทางไม่จำเป็นต้องรองรับสถานะและการเปลี่ยนสถานะที่มีอยู่ทั้งหมด อย่างไรก็ตาม สถานะสุดท้ายของคำสั่งซื้อต้องเป็น FULFILLED, REJECTED หรือ CANCELLED

ระบุเวลาที่จะได้รับสินค้าโดยประมาณ

คุณสามารถแจ้งช่วงเวลาโดยประมาณที่คำสั่งซื้อของผู้ใช้จะพร้อมให้มารับ (หรือนำส่ง) ใช้ช่อง estimatedFulfillmentTimeIso8601 ของ FoodOrderUpdateExtension เพื่อระบุช่วงเวลาโดยประมาณที่คำสั่งซื้อของลูกค้าจะพร้อมให้มารับหรือนำส่ง

ส่ง estimatedFulfillmentTimeIso8601 ในเวลาต่อไปนี้

  • เมื่อระบบแสดงเวลาโดยประมาณแล้ว สถานะที่เหมาะสมคือสถานะคำสั่งซื้อ CREATED หรือ CONFIRMED
  • เมื่อเวลาโดยประมาณมีการเปลี่ยนแปลง เช่น การอัปเดตเวลาโดยประมาณให้แม่นยำยิ่งขึ้นเมื่อคำสั่งซื้อมีสถานะเป็นIN_TRANSIT

โปรดประมาณเวลาให้น้อยที่สุดและระบุช่วงวันที่และเวลาแทนวันที่และเวลาแบบตายตัว เพื่อจัดการความคาดหวังของผู้ใช้อย่างมีประสิทธิภาพ คุณควรคำนึงถึงปัจจัยต่างๆ เช่น สภาพการจราจร ทุกครั้งที่เป็นไปได้ ตัวอย่างเช่น คุณส่งเวลาโดยประมาณเป็น 12:45 น. (ขอบเขตล่าง) ถึง 13:15 น. (ขอบเขตบน) สำหรับคำสั่งซื้อที่เวลานำส่งโดยประมาณคือ 13:00 น. ได้

การดำเนินการจัดการคำสั่งซื้อ

เมื่อส่งการอัปเดตคำสั่งซื้อ คุณสามารถให้แหล่งข้อมูลแก่ลูกค้าซึ่งจะช่วยจัดการคำสั่งซื้อในรูปแบบของOrderManagementAction หลังจากสั่งซื้อแล้ว ลูกค้าอาจต้องติดต่อคุณหรือร้านอาหารที่ดำเนินการตามคำสั่งซื้อเพื่อติดตามความคืบหน้า ทำการเปลี่ยนแปลง หรือยกเลิกคำสั่งซื้อ

OrderManagementAction ช่วยให้ลูกค้าส่งอีเมล โทร หรือลิงก์ไปยัง URL ได้โดยตรงจากอุปกรณ์ ใช้ข้อมูลเดียวกันใน OrderManagementAction กับในอีเมลยืนยันคำสั่งซื้อที่คุณส่งให้ผู้ใช้

การดำเนินการจัดการคำสั่งซื้อมีประเภทต่อไปนี้

  • CUSTOMER_SERVICE: แจ้งให้ลูกค้าดำเนินการเพื่อติดต่อฝ่ายบริการลูกค้า ประเภทการดำเนินการจัดการนี้จำเป็นสำหรับการอัปเดตคำสั่งซื้อ
  • EMAIL: ให้ลูกค้าดำเนินการเพื่อส่งอีเมลไปยังอีเมลที่ระบุ
  • CALL: แจ้งให้ลูกค้าดำเนินการโทรหาหมายเลขโทรศัพท์ที่ระบุ
  • VIEW_DETAIL: ระบุการดำเนินการให้ลูกค้าดูรายละเอียดของคำสั่งซื้อ

การอัปเดตคำสั่งซื้อแต่ละรายการต้องมีการดำเนินการจัดการคำสั่งซื้ออย่างน้อย 1 รายการ อย่างไรก็ตาม การดำเนินการจัดการคำสั่งซื้อที่ระบุอาจแตกต่างกันไปตามสถานะของคำสั่งซื้อ เช่น เมื่อคำสั่งซื้ออยู่ในสถานะ CONFIRMED การดําเนินการ CUSTOMER_SERVICE อาจชี้ไปยังหมายเลขโทรศัพท์ของฝ่ายบริการลูกค้า เมื่อสถานะการสั่งซื้ออัปเดตเป็น IN_TRANSIT การดำเนินการ CUSTOMER_SERVICE จะชี้ไปยังหมายเลขโทรศัพท์ของร้านอาหารที่ดำเนินการตามคำสั่งซื้อได้

การส่งข้อมูลอัปเดตคำสั่งซื้อ

คุณใช้ประเภทข้อความ AsyncOrderUpdateRequestMessage เพื่อส่งการอัปเดตคำสั่งซื้อไปยังบริการการสั่งซื้อแบบครบวงจร Google จะตอบกลับด้วย AsyncOrderUpdateResponseMessage ตัวอย่างเช่น หากต้องการแจ้งให้ลูกค้าทราบว่าคำสั่งซื้อถูกต้องและได้รับการยอมรับแล้ว คุณสามารถส่งAsyncOrderUpdateRequestMessageเพื่อเปลี่ยนสถานะคำสั่งซื้อเป็นCONFIRMEDพร้อมป้ายกำกับ Accepted by restaurant

แผนภาพการอัปเดตคำสั่งซื้อ

การตั้งค่าข้อความอัปเดตคำสั่งซื้อ

เมื่อส่ง AsyncOrderUpdateRequestMessage ไปยัง Google คุณต้องระบุข้อมูลเกี่ยวกับสถานะของคำสั่งซื้อโดยใช้ช่อง OrderUpdate

ตัวอย่างต่อไปนี้แสดงAsyncOrderUpdateRequestMessage ตัวอย่างสำหรับสถานะคำสั่งซื้อแต่ละสถานะ

ยืนยันแล้ว

ตัวอย่างนี้แสดงคำขออัปเดตคำสั่งซื้อซึ่งแจ้งให้ผู้ใช้ทราบว่าคำสั่งซื้อได้รับการยืนยันพร้อมใบเสร็จและเวลานำส่งโดยประมาณ

{
  "isInSandbox": true,
  "customPushMessage": {
    "orderUpdate": {
      "actionOrderId": "sample_action_order_id",
      "orderState": {
        "state": "CONFIRMED",
        "label": "Provider confirmed"
      },
      "receipt": {
        "userVisibleOrderId": "userVisibleId1234"
      },
      "updateTime": "2017-07-17T12:00:00Z",
      "orderManagementActions": [
        {
          "type": "CUSTOMER_SERVICE",
          "button": {
            "title": "Contact customer service",
            "openUrlAction": {
              "url": "mailto:support@example.com"
            }
          }
        },
        {
          "type": "EMAIL",
          "button": {
            "title": "Email restaurant",
            "openUrlAction": {
              "url": "mailto:person@example.com"
            }
          }
        },
        {
          "type": "CALL_RESTAURANT",
          "button": {
            "title": "Call restaurant",
            "openUrlAction": {
              "url": "tel:+16505554679"
            }
          }
        },
        {
          "type": "CALL_DRIVER",
          "button": {
            "title": "Call driver",
            "openUrlAction": {
              "url": "tel:+16505554681"
            }
          }
        }
      ],
      "infoExtension": {
        "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension",
        "estimatedFulfillmentTimeIso8601": "2017-07-17T13:00:00Z/2017-07-17T13:30:00Z"
      }
    }
  }
}
    

ถูกปฏิเสธ

ตัวอย่างนี้แสดงคำขออัปเดตคำสั่งซื้อซึ่งแจ้งให้ผู้ใช้ทราบว่าคำสั่งซื้อถูกปฏิเสธพร้อมเหตุผลการปฏิเสธ

{
  "isInSandbox": true,
  "customPushMessage": {
    "orderUpdate": {
      "actionOrderId": "sample_action_order_id",
      "orderState": {
        "state": "REJECTED",
        "label": "Order rejected"
      },
      "updateTime": "2017-05-10T02:30:00.000Z",
      "rejectionInfo": {
        "type": "UNKNOWN",
        "reason": "Sorry, the restaurant cannot take your order right now."
      },
      "orderManagementActions": [
        {
          "type": "CUSTOMER_SERVICE",
          "button": {
            "title": "Contact customer service",
            "openUrlAction": {
              "url": "mailto:support@example.com"
            }
          }
        },
        {
          "type": "EMAIL",
          "button": {
            "title": "Email restaurant",
            "openUrlAction": {
              "url": "mailto:person@example.com"
            }
          }
        },
        {
          "type": "CALL_RESTAURANT",
          "button": {
            "title": "Call restaurant",
            "openUrlAction": {
              "url": "tel:+16505554679"
            }
          }
        },
        {
          "type": "CALL_DRIVER",
          "button": {
            "title": "Call driver",
            "openUrlAction": {
              "url": "tel:+16505554681"
            }
          }
        }
      ],
      "infoExtension": {
      "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension",
      "foodOrderErrors": [
        {
        "error": "NO_CAPACITY",
        "description": "Sorry, the restaurant cannot take your order right now."
        }
      ]
      }
    }
  }
}
    

ยกเลิกแล้ว

ตัวอย่างนี้แสดงคำขออัปเดตคำสั่งซื้อซึ่งจะแจ้งให้ผู้ใช้ทราบว่าคำสั่งซื้อถูกยกเลิกพร้อมเหตุผลในการยกเลิก

{
  "isInSandbox": true,
  "customPushMessage": {
    "orderUpdate": {
      "actionOrderId": "sample_action_order_id",
      "orderState": {
        "state": "CANCELLED",
        "label": "Order cancelled"
      },
      "updateTime": "2017-05-10T02:30:00.000Z",
      "cancellationInfo": {
        "reason": "Customer requested"
      },
      "orderManagementActions": [
        {
          "type": "CUSTOMER_SERVICE",
          "button": {
            "title": "Contact customer service",
            "openUrlAction": {
              "url": "mailto:support@example.com"
            }
          }
        },
        {
          "type": "EMAIL",
          "button": {
            "title": "Email restaurant",
            "openUrlAction": {
              "url": "mailto:person@example.com"
            }
          }
        },
        {
          "type": "CALL_RESTAURANT",
          "button": {
            "title": "Call restaurant",
            "openUrlAction": {
              "url": "tel:+16505554679"
            }
          }
        },
        {
          "type": "CALL_DRIVER",
          "button": {
            "title": "Call driver",
            "openUrlAction": {
              "url": "tel:+16505554681"
            }
          }
        }
      ]
    }
  }
}
    

IN_PREPARATION

ตัวอย่างนี้แสดงคำขออัปเดตคำสั่งซื้อซึ่งแจ้งให้ผู้ใช้ทราบว่ากำลังเตรียมอาหาร

{
  "isInSandbox":true,
  "customPushMessage":{
    "orderUpdate":{
      "actionOrderId":"sample_action_order_id",
      "orderState":{
        "state":"IN_PREPARATION",
        "label":"Order is being prepared"
      },
      "receipt": {
        "userVisibleOrderId": "userVisibleId1234"
      },
      "updateTime":"2018-04-15T11:30:00Z",
      "orderManagementActions": [
        {
          "type": "CUSTOMER_SERVICE",
          "button": {
            "title": "Contact customer service",
            "openUrlAction": {
              "url": "mailto:support@example.com"
            }
          }
        },
        {
          "type": "EMAIL",
          "button": {
            "title": "Email restaurant",
            "openUrlAction": {
              "url": "mailto:person@example.com"
            }
          }
        },
        {
          "type": "CALL_RESTAURANT",
          "button": {
            "title": "Call restaurant",
            "openUrlAction": {
              "url": "tel:+16505554679"
            }
          }
        },
        {
          "type": "CALL_DRIVER",
          "button": {
            "title": "Call driver",
            "openUrlAction": {
              "url": "tel:+16505554681"
            }
          }
        }
      ],
      "infoExtension":{
        "@type":"type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension",
        "estimatedFulfillmentTimeIso8601":"PT20M"
      }
    }
  }
}
    

READY_FOR_PICKUP

ตัวอย่างนี้แสดงคำขออัปเดตคำสั่งซื้อซึ่งจะแจ้งให้ผู้ใช้ทราบว่าอาหารพร้อมให้รับแล้ว

{
  "isInSandbox": true,
  "customPushMessage": {
    "orderUpdate": {
      "actionOrderId": "sample_action_order_id",
      "orderState": {
        "state": "READY_FOR_PICKUP",
        "label": "Order is ready for pickup"
      },
      "receipt": {
        "userVisibleOrderId": "userVisibleId1234"
      },
      "updateTime": "2018-04-15T12:00:00Z",
      "orderManagementActions": [
        {
          "type": "CUSTOMER_SERVICE",
          "button": {
            "title": "Contact customer service",
            "openUrlAction": {
              "url": "mailto:support@example.com"
            }
          }
        },
        {
          "type": "EMAIL",
          "button": {
            "title": "Email restaurant",
            "openUrlAction": {
              "url": "mailto:person@example.com"
            }
          }
        },
        {
          "type": "CALL_RESTAURANT",
          "button": {
            "title": "Call restaurant",
            "openUrlAction": {
              "url": "tel:+16505554679"
            }
          }
        },
        {
          "type": "CALL_DRIVER",
          "button": {
            "title": "Call driver",
            "openUrlAction": {
              "url": "tel:+16505554681"
            }
          }
        }
      ],
      "infoExtension": {
        "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension",
        "estimatedFulfillmentTimeIso8601": "PT20M"
      }
    }
  }
}
    

IN_TRANSIT

ตัวอย่างนี้แสดงคำขออัปเดตคำสั่งซื้อซึ่งแจ้งให้ผู้ใช้ทราบว่าคำสั่งซื้ออยู่ระหว่างการขนส่งพร้อมเวลานำส่งโดยประมาณ

{
  "isInSandbox": true,
  "customPushMessage": {
    "orderUpdate": {
      "actionOrderId": "sample_action_order_id",
      "orderState": {
        "state": "IN_TRANSIT",
        "label": "Order is on the way"
      },
      "inTransitInfo": {
        "updatedTime": "2017-07-17T12:00:00Z"
      },
      "updateTime": "2017-07-17T12:00:00Z",
      "orderManagementActions": [
        {
          "type": "CUSTOMER_SERVICE",
          "button": {
            "title": "Contact customer service",
            "openUrlAction": {
              "url": "mailto:support@example.com"
            }
          }
        },
        {
          "type": "EMAIL",
          "button": {
            "title": "Email restaurant",
            "openUrlAction": {
              "url": "mailto:person@example.com"
            }
          }
        },
        {
          "type": "CALL_RESTAURANT",
          "button": {
            "title": "Call restaurant",
            "openUrlAction": {
              "url": "tel:+16505554679"
            }
          }
        },
        {
          "type": "CALL_DRIVER",
          "button": {
            "title": "Call driver",
            "openUrlAction": {
              "url": "tel:+16505554681"
            }
          }
        }
      ],
      "infoExtension": {
        "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension",
        "estimatedFulfillmentTimeIso8601": "PT20M"
      }
    }
  }
}
  

FULFILLED

ตัวอย่างนี้แสดงคำขออัปเดตคำสั่งซื้อซึ่งจะแจ้งให้ผู้ใช้ทราบว่ามีการนำส่งหรือนำส่งคำสั่งซื้อแล้ว

{
  "isInSandbox": true,
  "customPushMessage": {
    "orderUpdate": {
      "actionOrderId": "sample_action_order_id",
      "orderState": {
      "state": "FULFILLED",
      "label": "Order delivered"
      },
      "updateTime": "2017-05-10T02:30:00.000Z",
      "fulfillmentInfo": {
        "deliveryTime": "2017-05-10T02:30:00.000Z"
      },
      "orderManagementActions": [
        {
          "type": "CUSTOMER_SERVICE",
          "button": {
            "title": "Contact customer service",
            "openUrlAction": {
              "url": "mailto:support@example.com"
            }
          }
        },
        {
          "type": "EMAIL",
          "button": {
            "title": "Email restaurant",
            "openUrlAction": {
              "url": "mailto:person@example.com"
            }
          }
        },
        {
          "type": "CALL_RESTAURANT",
          "button": {
            "title": "Call restaurant",
            "openUrlAction": {
              "url": "tel:+16505554679"
            }
          }
        },
        {
          "type": "CALL_DRIVER",
          "button": {
            "title": "Call driver",
            "openUrlAction": {
              "url": "tel:+16505554681"
            }
          }
        }
      ]
    }
  }
}
    

ดูตัวอย่างคำขออัปเดตคำสั่งซื้อเพิ่มเติมใน Use Case ต่างๆ ได้ที่หัวข้อใช้การอัปเดตคำสั่งซื้อขั้นสูง

สร้างโทเค็นการให้สิทธิ์และส่งข้อความ

การอัปเดตคำสั่งซื้อต้องใช้โทเค็นการให้สิทธิ์เพื่อให้บริการการสั่งซื้อแบบครบวงจรยืนยันได้ว่าข้อความนั้นมาจากเว็บบริการการสั่งซื้อแบบครบวงจรของคุณ

หากต้องการใช้การอัปเดตคำสั่งซื้อสำหรับโปรเจ็กต์ ให้ทำตามขั้นตอนต่อไปนี้

  1. สร้างโทเค็นการให้สิทธิ์โดยทําตามขั้นตอนต่อไปนี้
    1. ใช้ไลบรารี Google Auth เพื่ออ่านข้อมูลเข้าสู่ระบบจากไฟล์บัญชีบริการ
    2. ขอโทเค็นโดยใช้ขอบเขต API ต่อไปนี้ https://www.googleapis.com/auth/actions.fulfillment.conversation
  2. ใช้โทเค็นนี้เพื่อส่งคำขอ HTTP POST ที่มีการตรวจสอบสิทธิ์ไปยังปลายทางต่อไปนี้ https://actions.googleapis.com/v2/conversations:send
  3. ตั้งค่าส่วนหัว Content-Type เป็น application/json เป็นส่วนหนึ่งของคำขอ

ตัวอย่างต่อไปนี้แสดงวิธีใช้การอัปเดตคำสั่งซื้อ

Node.js

โค้ดนี้ใช้ไลบรารีการให้สิทธิ์ของ Google สําหรับ Node.js

const {auth} = require('google-auth-library')
const request = require('request');
// The service account client secret file downloaded from the Google Cloud Console
const serviceAccountJson = require('./service-account.json')
// order-update.json is a file that contains the payload
const jsonBody = require('./order-update.json')

/**
 * Get the authorization token using a service account.
 */
async function getAuthToken() {
  let client = auth.fromJSON(serviceAccountJson)
  client.scopes = ['https://www.googleapis.com/auth/actions.fulfillment.conversation']
  const tokens = await client.authorize()
  return tokens.access_token;
}

/**
 * Send an order update request
 */
async function sendOrderUpdate() {
  const token = await getAuthToken()
  request.post({
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${token}`
    },
    url: 'https://actions.googleapis.com/v2/conversations:send',
    body: jsonBody,
    json: true
  },
  (err, res, body) => {
    if (err) { return console.log(err); }
    console.log(`Response: ${JSON.stringify(res)}`)
  })
}
    

Python

โค้ดนี้ใช้ไลบรารีการให้สิทธิ์ของ Google สําหรับ Python

from google.oauth2 import service_account
from google.auth.transport.requests import AuthorizedSession
import json

# service-account.json is the service account client secret file downloaded from the
# Google Cloud Console
credentials = service_account.Credentials.from_service_account_file(
    'service-account.json')

scoped_credentials = credentials.with_scopes(
    ['https://www.googleapis.com/auth/actions.fulfillment.conversation'])

authed_session = AuthorizedSession(scoped_credentials)

# order-update.json is a file that contains the payload
json_payload=json.load(open('order-update.json'))

response = authed_session.post(
    'https://actions.googleapis.com/v2/conversations:send',
    json=json_payload)
    

Java

โค้ดนี้ใช้ไลบรารีการให้สิทธิ์ของ Google สําหรับ Java

/**
 * Get the authorization token using a service account.
 */
private static String getAuthToken() {
  InputStream serviceAccountFile = Example.class.getClassLoader().getResourceAsStream("service-account.json");
  ServiceAccountCredentials.Builder credentialsSimpleBuilder =
      ServiceAccountCredentials.fromStream(serviceAccountFile).toBuilder();
  credentialsSimpleBuilder.setScopes(ImmutableList.of("https://www.googleapis.com/auth/actions.fulfillment.conversation"));
  AccessToken accessToken = credentialsSimpleBuilder.build().refreshAccessToken();
  return accessToken.getTokenValue();
}

/**
 * Send an order update request
 */
public void sendOrderUpdate() {
  String authToken = getAuthToken();
  // Execute POST request
  executePostRequest("https://actions.googleapis.com/v2/conversations:send",
      authToken, "update_order_example.json",);
}
    

สำหรับการอัปเดตคำสั่งซื้อที่สำเร็จและไม่มีข้อผิดพลาด Google จะแสดงการตอบกลับ HTTP 200 พร้อมเพย์โหลดว่าง หากเกิดปัญหา เช่น การอัปเดตมีรูปแบบไม่ถูกต้อง Google จะแสดงข้อผิดพลาด