Skip to main content

Python Wrapper for JSON API Chatfuel

Project description


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


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


  • Send Text:
def sendText(text):
    chatfuel = Chatfuel()
    return chatfuel.get_response()


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


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


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


  • Send Button to Block:
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:
def ButtonToURL():
    chatfuel = Chatfuel()
    ButtonToURL = chatfuel.createButtonToURL(
        'Button To URL',
    chatfuel.sendTextCard('Clicking the button below!', [ButtonToURL])
    return chatfuel.get_response()

Button To URL

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

PostBack Button

  • Send Button Call:
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:
def sendGallery():
    chatfuel = Chatfuel()
    elements = []
    #maximum 3 button
    button_access_url = chatfuel.createButtonToURL('Access Website', '')
    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]))
    return chatfuel.get_response()


  • Send List:
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', '')
    title = 'Send List'
    image_url = ''
    subTitle = 'subTitle Item'
    for i in range(2):
        elements.append(chatfuel.createElement(title, image_url, subTitle, [button_access_url]))
    return chatfuel.get_response()


  • Send Quick Reply:
def sendQuickReply():
    chatfuel = Chatfuel()
    button_quick_replies_attributes = chatfuel.createButtonToBlock(
        'Send Quick Reply',
        {'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()


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

Redirect Block


Author: @Peter Dinh

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_chatfuel_class-2.1.3.tar.gz (4.8 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page