ConditionalEvent
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Mendaftarkan peristiwa yang terpicu sebagai hasil dari kondisi sebenarnya.
Representasi YAML |
condition: string
transitionToScene: string
handler:
object (EventHandler ) |
Kolom |
condition |
string
Wajib. Kondisi filter untuk memicu peristiwa ini. Jika kondisi dievaluasi ke benar (true), handler yang terkait akan dipicu. Referensi variabel berikut didukung: $session - Untuk mereferensikan data dalam penyimpanan sesi. $user - Untuk mereferensikan data dalam penyimpanan pengguna. Operator boolean berikut didukung (dengan contoh): && - session.params.counter > 0 && session.params.counter < 100 || - session.params.foo == "John" || session.params.counter == "Adam" ! - !(session.params.counter == 5) Perbandingan berikut didukung: == , != , < , > , <= , >= Operator daftar dan string berikut didukung (dengan contoh): in - "Semangka" dalam session.params.fruitList size - size(session.params.fruitList) > 2 substring - session.params.fullName.contains("John")
|
transitionToScene |
string
Opsional. Adegan tujuan tempat percakapan harus melompat saat kondisi terkait dievaluasi ke benar (true). Status scene saat ini dihapus pada transisi.
|
handler |
object (EventHandler )
Opsional. Pengendali peristiwa yang dipicu saat kondisi terkait dievaluasi ke true . Harus dieksekusi sebelum bertransisi ke scene tujuan. Berguna untuk membuat Prompt sebagai respons terhadap peristiwa.
|
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-26 UTC.
[null,null,["Terakhir diperbarui pada 2025-07-26 UTC."],[[["\u003cp\u003eYAML is used to represent events that are triggered based on a true condition.\u003c/p\u003e\n"],["\u003cp\u003eEvents can be triggered based on conditions using variables like \u003ccode\u003e$session\u003c/code\u003e and \u003ccode\u003e$user\u003c/code\u003e, boolean operators, and comparisons.\u003c/p\u003e\n"],["\u003cp\u003eOptionally, you can define a destination scene for the conversation to jump to when the condition is true.\u003c/p\u003e\n"],["\u003cp\u003eEvent handlers can be defined to execute before transitioning to a new scene, allowing for the generation of prompts.\u003c/p\u003e\n"]]],[],null,["# ConditionalEvent\n\n- [YAML representation](#SCHEMA_REPRESENTATION)\n\nRegisters events that trigger as the result of a true condition.\n\n| YAML representation ||\n|--------------------------------------------------------------------------------------------------------------------------------------|---|\n| ``` condition: string transitionToScene: string handler: object (/assistant/actionssdk/reference/rest/Shared.Types/EventHandler) ``` |\n\n| Fields ||\n|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `condition` | `string` Required. Filter condition for this event to trigger. If condition is evaluated to true then the associated `handler` will be triggered. The following variable references are supported: `$session` - To reference data in session storage. `$user` - To reference data in user storage. The following boolean operators are supported (with examples): `&&` - `session.params.counter \u003e 0 && session.params.counter \u003c 100` `||` - `session.params.foo == \"John\" || session.params.counter == \"Adam\"` `!` - `!(session.params.counter == 5)` The following comparisons are supported: `==`, `!=`, `\u003c`, `\u003e`, `\u003c=`, `\u003e=` The following list and string operators are supported (with examples): `in` - \"Watermelon\" in `session.params.fruitList` `size` - `size(session.params.fruitList) \u003e 2` `substring` - `session.params.fullName.contains(\"John\")` |\n| `transitionToScene` | `string` Optional. Destination scene which the conversation should jump to when the associated condition is evaluated to true. The state of the current scene is destroyed on the transition. |\n| `handler` | `object (`[EventHandler](/assistant/actionssdk/reference/rest/Shared.Types/EventHandler)`)` Optional. Event handler which is triggered when the associated condition is evaluated to `true`. Should execute before transitioning to the destination scene. Useful to generate Prompts in response to events. |"]]