Create a dictionary
This is a part of the tutorial on creating a button-based bot that can order pizza.
- Selecting a delivery city
- Creating a dictionary (you are here)
- Selecting a pizza
- Making an order
- Testing the bot script
At the previous step, we’ve created the chatbot.yaml
and main.sc
files. In the main script, the bot welcomes the client and offers them to order pizza. The client selects a delivery city.
Now, before we provide the client with information about available types of pizza we need to create a dictionary that lists pizza names for the selected city, available sizes, type of dough and prices.
Pizza dictionary
Create a pizza.csv
file in the src
folder and paste the following:
1;Margarita;{"title": "Margarita", "region": ["New York", "Washington"], "variations": [{"id": 1, "name": "Large thin-crust pizza", "price": 22}, {"id": 2, "name": "Large thick-crust pizza", "price": 29}, {"id": 3, "name": "Small thin-crust pizza", "price": 21}, {"id": 4, "name": "Small thick-crust pizza", "price": 24}]}
2;Pepperoni;{"title": "Pepperoni", "region": ["New York", "Washington"], "variations": [{"id": 5, "name": "Large thin-crust pizza", "price": 31}, {"id": 6, "name": "Large thick-crust pizza", "price": 35}, {"id": 7, "name": "Small thin-crust pizza", "price": 24}, {"id": 8, "name": "Small thick-crust pizza", "price": 27}]}
3;With mushrooms;{"title": "With mushrooms", "region": ["New York"], "variations": [{"id": 9, "name": "Large thin-crust pizza", "price": 249}, {"id": 10, "name": "Large thick-crust pizza", "price": 31}, {"id": 11, "name": "Small thin-crust pizza", "price": 17}, {"id": 12, "name": "Small thick-crust pizza", "price": 19}]}
4;Four cheeses;{"title": "Four cheeses", "region": ["Washington"], "variations": [{"id": 13, "name": "Large thin-crust pizza", "price": 29}, {"id": 14, "name": "Large thick-crust pizza", "price": 35}, {"id": 15, "name": "Small thin-crust pizza", "price": 31}, {"id": 16, "name": "Small thick-crust pizza", "price": 35}]}
Here:
id
— unique product identifier.title
— pizza name.region
— available delivery cities.variations
— available pizza sizes, type of dough and price.
Next, move on to creating a script to select pizza.