Update record
Learn how to use the update record operation on your table by using a gym bot example.
Last updated
Learn how to use the update record operation on your table by using a gym bot example.
Last updated
Updating a record from your table means that an already-existing record is updated on one of several of its cells.
To exemplify this, we will use a gym booking bot that uses a Table to store who is booked in a yoga class. By updating record, we will add the user as enrolled to the class.
This means that you'll go from this:
className | classTeacher | isBooked |
---|---|---|
Zumba | Monday | None |
To this:
className | classTeacher | isBooked |
---|---|---|
Zumba | Monday | Agatha |
Make sure that you have a well-defined table. For this example, we'll use gym booking table with those fields:
ClassName: Name of the fitness class.
ClassDay: Date of the class, in a consistent format (e.g., YYYY-MM-DD).
ClassTime: Start time of the class, using a clear format (e.g., HH:MM AM/PM).
ClassTeacher: Name of the instructor leading the class.
IsBooked: Status field indicating whether the class is booked ('None' or 'Available' by default, updated to customer's name upon booking).
In your bot flow, identify the point in the conversation where the customer chose a class and confirmed their booking.
Add a Table operation to your flow.
Choose Update record from the list of operations.
Select the table that you want to update. For this example, we'll select Gym class booking.
Under Operation Config, under the isBooked column, add the variable holding the customer's name. In our example, this variable is called {userName}
. This means that the isBooked column will be updated with {userName}
as a new value.
Under Define a selection criteria for the records to update, click on + Add filter to set the conditions to identify which record (or row on your table) should be updated. In our example, the conditions should match the class that the customer is booking. Therefore, we're going to check that {className}
, {classDay}
, {classTeacher}
, and {classTime}
are already specified.
Optionally, you can set up limits for the number of records to update, in the case where you would like to update more than 1.
Click Save.
It's crucial to check the functionality of your Update record operation to ensure data is captured and stored correctly. Utilize the emulator to test the flow that you just build.
After completing the booking process in the test, navigate to the updated table (in this example, it's called Gym class booking) to verify the update. Ensure the isBooked field is filled with the customers booking the selected class are updated as expected.
Looking for a quick and easy bot template to play with Tables? The Gym bot is a representative use case.