Skip to main content

python-chatfuel-class

Descrpition: Python Wrapper for JSON API Chatfuel

This project was inspired by php-chatfuel-class

Functions List:

  • Send Text:
def sendText(self, messages = None)
  • Send Image
def sendImage(self, url_image)
  • Send Audio
def sendAudio(self, url):
  • Send Video
def sendVideo(self, url)
  • Send Text Card
def sendTextCard(self, text, buttons)
  • Send Gallery
def sendGallery(self, elements)
  • Send List
def sendList(self, elements)
  • Send Quick Reply
def sendQuickReply(self, text, quickReplies)
  • Create Element
def createElement(self, title, image, subTitle, buttons)
  • Create Button To Block
def createButtonToBlock(self, title, block, setAttributes = None)
  • Create Button To URL
def createButtonToURL(self, title, url)
  • Create PostBack Button
def createPostBackButton(self, title, url_plugin)
  • Create Call Button
def createCallButton(self, title, phoneNumber)
  • Create Share Button
def _createShareButton(self)
  • Create Attachment
def createAttachment(self, _type, payload)

You can see the code at here class_chatfuel.py

Installation

For python 2x
pip install python_chatfuel_class
For python 3x
pip3 install python_chatfuel_class

Usage

  • Send Text:
@app.route('/sendText/<text>')
def sendText(text):
    chatfuel = Chatfuel()
    chatfuel.sendText(text)
    return chatfuel.get_response()

send-text

  • Send Image:
@app.route('/sendImage/')
def sendImage():
    chatfuel = Chatfuel()
    url_image = ''
    chatfuel.sendImage(url_image)
    return chatfuel.get_response()

send-Image

  • Send Audio:
@app.route('/sendAudio/')
def sendAudio():
    chatfuel = Chatfuel()
    url_audio = ''
    chatfuel.sendAudio(url_audio)
    return chatfuel.get_response()

send-Audio

  • Send Video:
@app.route('/sendVideo/')
def sendVideo():
    chatfuel = Chatfuel()
    url_video = ''
    chatfuel.sendVideo(url_video)
    return chatfuel.get_response()

send-Video

  • Send Button to Block:
@app.route('/sendTextCard/ButtonToBlock')
def createButtonToBlock():
    chatfuel = Chatfuel()
    ButtonToBlock = chatfuel.createButtonToBlock(
        'Button To Block',
        ['#block_1', '#block_2'],
        {'setAttribute_1': 'value_1'}
    )
    chatfuel.sendTextCard('Clicking the button below!', [ButtonToBlock])
    return chatfuel.get_response()

Button to Block

  • Send Button to URL:
@app.route('/sendTextCard/ButtonToURL')
def ButtonToURL():
    chatfuel = Chatfuel()
    ButtonToURL = chatfuel.createButtonToURL(
        'Button To URL',
        'url_website',
    )
    chatfuel.sendTextCard('Clicking the button below!', [ButtonToURL])
    return chatfuel.get_response()

Button To URL

  • Send Button Post Back:
@app.route('/sendTextCard/PostBackButton')
def PostBackButton():
    chatfuel = Chatfuel()
    PostBackButton = chatfuel.createPostBackButton(
        'Post Back Button',
        'url_plugin',
    )
    chatfuel.sendTextCard('Clicking the button below!', [PostBackButton])
    return chatfuel.get_response()

PostBack Button

  • Send Button Call:
@app.route('/sendTextCard/CallButton')
def CallButton():
    chatfuel = Chatfuel()
    CallButton = chatfuel.createCallButton(
        'Call Button',
        'Phone_number', #example; +84919666666
    )
    chatfuel.sendTextCard('Clicking the button below!', [CallButton])
    return chatfuel.get_response()

Call Button

  • Send Gallery:
@app.route('/sendGallery/')
def sendGallery():
    chatfuel = Chatfuel()
    elements = []
    #maximum 3 button
    button_access_url = chatfuel.createButtonToURL('Access Website', 'https://www.google.com.vn')
    button_call = chatfuel.createCallButton('+84919666666')
    button_share = chatfuel.createShareButton()
    title = 'Send Gallery'
    image_url = ''
    subTitle = 'subTitle Item'
    for i in range(5):
        elements.append(chatfuel.createElement(title, image_url, subTitle, [button_access_url, button_call, button_share]))
    chatfuel.sendGallery(elements)
    return chatfuel.get_response()

send-Gallery

  • Send List:
@app.route('/sendList/')
def sendList():
    #minimum 2 items in one List (Elements)
    #maximum 4 items in one List (Elements)
    chatfuel = Chatfuel()
    elements = []
    button_access_url = chatfuel.createButtonToURL('Access Website', 'https://www.google.com.vn')
    title = 'Send List'
    image_url = ''
    subTitle = 'subTitle Item'
    for i in range(2):
        elements.append(chatfuel.createElement(title, image_url, subTitle, [button_access_url]))
    chatfuel.sendList(elements)
    return chatfuel.get_response()

send-List

  • Send Quick Reply:
@app.route('/sendQuickReply/')
def sendQuickReply():
    chatfuel = Chatfuel()
    button_quick_replies_attributes = chatfuel.createButtonToBlock(
        'Send Quick Reply',
        ['#block_1'],
        {'setAttributes_1': 'value_1'},
    )
    button_quick_replies = chatfuel.createButtonToBlock('Title', ['#block_1'])
    chatfuel.sendQuickReply('Text', [button_quick_replies_attributes, button_quick_replies])
    return chatfuel.get_response()

send-Quick-Reply

  • Redirect Block
@app.route('/redirectBlock/')
def redirectBlock():
    return json.dumps({"redirect_to_blocks": ["Welcome message", "Default answer"]})

Redirect Block

Demo:

Author: @Peter Dinh

Metadata

Release files for python-chatfuel-class 2.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-chatfuel-class 2.1.3
File Size Uploaded Provenance Actions
python_chatfuel_class-2.1.3.tar.gz 4.8 kB Without provenance Details for python_chatfuel_class-2.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-chatfuel-class 2.1.3
File Interpreter ABI Platform Actions
python_chatfuel_class-2.1.3-py3-none-any.whl Python 3 none any Details for python_chatfuel_class-2.1.3-py3-none-any.whl

Total release size: 9.7 kB

Release files / python_chatfuel_class-2.1.3.tar.gz

Download URL python_chatfuel_class-2.1.3.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e19678ae7d1cbac333e4ec8f7bd2664a5863168d2193b8fe744b8f5f23a33c81
BLAKE2b-256 checksum
How to use checksums
3741630970fc26adb50c9f1220de106e0321f64536d30c62a4002cdbe2ae81c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / python_chatfuel_class-2.1.3-py3-none-any.whl

Download URL python_chatfuel_class-2.1.3-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
246e1c7d0c39897d6752ccbeeb14f835a86b1711e765358df1af4bb797bae121
BLAKE2b-256 checksum
How to use checksums
3d36f3bd577bd581b1f1137aa388a06fec6343829bde308c7ff5bf410f4b40de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for python-chatfuel-class 2.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.1.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page