https://github.com/chemsseddine/botv
Python library for constructing dict for botv.io
https://github.com/chemsseddine/botv
facebook flask
Last synced: 6 months ago
JSON representation
Python library for constructing dict for botv.io
- Host: GitHub
- URL: https://github.com/chemsseddine/botv
- Owner: chemsseddine
- License: mit
- Created: 2018-12-07T16:34:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-04T11:15:18.000Z (over 7 years ago)
- Last Synced: 2026-01-04T01:53:28.529Z (6 months ago)
- Topics: facebook, flask
- Language: Python
- Homepage:
- Size: 32.2 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Installation
```
pip install botv
```
# Usage
```
from botv.output import Output
message = Output()
message.as_dict
```
```
> {'output': {}}
```
### Entities
```
message.add_entity(entity1="value1", entity2="value2")
```
```
> {'entities': {'entity1':'value1', 'entity2':'value2'}, 'output': {}}
```
### Response
```
message.add_response('some response')
```
```
> {'entities': {'entity1':'value1', 'entity2':'value2'}, 'output': {'response': 'some response'}
```
```
# Or when instantiating the object message
new_message = Output("Hello World !")
```
### Facebook quick Replies
```
quick_replies = [{
"targetIntent":"intentName",
"type":"text",
"title":"someTitle",
"text":"some text"
}]
message.add_qr(quick_replies)
```
### Facebook Templates
```
templates = [{
"action_url":"https://go.to.this.url",
"image_url":"https://image.png",
"title":"someTitle",
"subtitle":"some sub title"
}]
message.add_template(templates)
```
## Flask
```
from flask import Flask, jsonify
from botv.output import Output
app = Flask(__name__)
@app.route('/')
def home():
message = Output()
message.add_entity(ent1="val1")
message.add_response("Hello from Flask")
return jsonify(message.as_dict)
```
## Flask Restful
```
from flask_restful import Resource, Api
from flask import Flask
from botv.output import Output
app = Flask(__name__)
api = Api(app)
class Home(Resource):
def get(self):
message = Output("Hello")
message.add_entity(solde="5544")
return message.as_dict
api.add_resource(Home, '/')
```