I have this project where I have to connect my Django app with a Chatfuel bot.
I have my admin panel, so whenever I update a field like complete certain task, I have to notify my client through the chatbot that this field change. I read JSON API docs and I noticed that they have an specific "template" to get data from a backend.
What I did is extract all my data from the models through Django Rest Framework and convert it to a JSON. The thing is I don't know how to use this information to work with it in Chatfuel because my JSON hasn't the template that Chatfuel requires.
This is my info extracted from the models.
If someone is looking for this answer, I solve it with a Serializer:
class UserAPI(APIView):
serializer = UserSerializer
def get(self, request, format=None):
list = Caseworker.objects.all()
response = self.serializer(list, many=True)
return HttpResponse(json.dumps({'messages': {'text':
response.data}}), content_type='application/json')