[go: up one dir, main page]

Skip to content

Serialize apiai webhook request and response to a proper python object

License

Notifications You must be signed in to change notification settings

dusterherz/apiai-python-webhook-serializer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apiai Python Webhook Serializer

PyPI version Build Status

Convert Api.ai webhook requests and responses to a python object with a proper Serializer.

What is APWS ? And Why ?

Apiai Python Webhook Serializer (APWS) is a little Serializer / Deserializer to translate the JSON recieved and sended from Api.ai. This allows to have proper python objects instead of dictionaries from parsed json and to transform an object into a proper json for Api.ai.

How does this work ?

APWS is constitued of two classes : Request and Response.

Request

Request is here to parse recieved JSON from Api.ai and Response to answer the request. Request take the body from the request at its creation. Then you can access objects like the sessionId writing request.sessionId. You can find all the fields that you can use here.

Response

Reponse is here to create a python object that can be return like that for example with flask. Response take multiples informations for its creation. Three are mandatory : speech, displayText and source. Three others are optional : data, contextOut and followupEvent. You can find more details on this here With Response you can also format it into a dictionary with the method format() if you are not using Flask. This class integrate also an error formater method for Api.ai (error). This method takes two parameters : httpErrorCode (the http error code corresponding to the error), and errorMsg (the message of the error). error is static so you can use it without initializing a Response object.

Examples ?

WIP.

Installation

You can install APWS via pip : pip install apiaiWebhookSerializer

License

MIT. Read LICENSE file for more information.

About

Serialize apiai webhook request and response to a proper python object

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages