Chatbot Takehome Assessment
python3 -m venv venv
source venv/bin/activate
make
/python manage.py runserver
The first time you run the make
command the init.sql and create.sql don't work very well. I've tried improving it for a while.
Running make
for a second time, fixes this issue.
If you now send a POST request with the following inside the body:
{
"id": 1,
"userid": "1",
"conversationid": "1",
"optionpicked": "1",
"state": "1"
}
You should get the following successfull response:
{
"status": "success",
"message": "Conversation data saved successfully"
}
If you want to see the data in the DB:
- Use
docker ps
to get the CONTAINER_ID - Run
docker exec -it <CONTAINER_ID> /bin/bash
to access the containers shell psql -U user -d chatbot
should give you access to the postgres console, having already selectedchatbot
as the database we want to useSELECT * FROM myapp_conversation;
should be empty if you haven't sent a POST request and received the successfull response as seen above.
chatbot=# SELECT * FROM myapp_conversation;
id | userid | conversationid | optionpicked | state
----+--------+----------------+--------------+-------
(0 rows)
OR
chatbot=# SELECT * FROM myapp_conversation;
id | userid | conversationid | optionpicked | state
----+--------+----------------+--------------+-------
1 | 1 | 1 | 1 | state
(1 row)