Create webhook JSON responses directly using this library

dialogflow, actions-on-google, messenger, webhook, json, dialogflow-fulfillment, python
pip install dialogflow-webhook-json==1.0.1


Dialogflow Fulfillment Webhook Response Library in Python

This library simplifies the JSON response building in Python for Dialogflow fulfillment.

Using this libray you can build the JSON objects with few line.

Supported Platforms - Actions on Google, Facebook Messenger and Telegram

Update - We have published a tutorial to create a basic webhook in Python + Django Dialogflow Tutorial: Create Fulfillment Webhook Using Python + Django which will be useful to setup this library in Python + Django. We have also published a new repo to showcase examples of creating different responses using this library.

How to use

To get started just import all the functions from the library using the following statement

from df_response_lib import *

Supported Responses

Actions on Google

  • Simple Response
  • Basic Card
  • Suggestion Chips
  • Link out suggestion
  • List Response
  • More will be added soon

Facebook and Telegram

  • Text Response
  • Card Response
  • Image Response
  • Quick replies

Dialogflow Fulfillment Responses

  • Fulfillment Text
  • Fullfillment Messages
  • Followup Event Input
  • Output Contexts

Actions on Google

Simple Response


responses - list of simple responses

["Text to be displayed", "Text to be spoken", ssml=True|False]


aog_sr = aog.simple_response([
	["Hello", "Hi", False],
	["Hey!!", "<speak>Hey</speak>", True]

Basic Card

basic_card(title, subtitle="", formattedText="", image=None, buttons=None)

title is the title of card - string
subtitle is the subtitle of the card - string
formattedText is the description of the card - limited markdown
image display image in the card - list

image = [imageUri, accessibilityText]

buttons add buttons to thr card

buttons = [
	[button_title, url]


image = ['https://imagepath.com/path.png', 'sample image']

buttons = [
	['button_1', 'https://www.google.com/'],
	['button 2', 'https://www.facebook.com/']

aog_card = aog.basic_card("card title", "card subtitle", "card *description*", image, buttons)

Suggestion Chips


suggestions - list of suggestions upto 8 items (one item length upto 25)

suggestions = ['chip1', 'chip2', 'chip3', 'chip4']


aog_suggestions = aog.suggestion_chips(suggestions)

Link out Suggestion

link_out_suggestion(title, url)

title - Text to be shown in suggestion
url - Link URL


title = "Link to google"
url = "https://www.google.com/"
aog_los = aog.link_out_suggestion(title, url)

List Select Response

list_select(list_title, list_elements)

list_title - title of the list
list_elements - list of items of the list select

	['item_title', 'item_description', item_info=['item_key', item_synonyms=['synonym1', 'synonym2'], ['imageURL', 'imageDescription']],
	['item2_title', 'item2_description', item_info=['item_key', item_synonyms=['synonym1', 'synonym2'], ['imageURL', 'imageDescription']]


list_elements = [
	['item_title', 'item_description', ['item_key', ['synonym1', 'synonym2'], ['imageURL', 'imageDescription']],
	['item2_title', 'item2_description', ['item2_key',['synonym1', 'synonym2'], ['imageURL', 'imageDescription']]

aog_list = aog.list_select("this is a list', list_elements)

Facebook and Telegram

Text response


texts - list of text

['text1', 'text2', 'text3']


texts = ['text1', 'text2', 'text3']
text_res = fb.text_response(texts)

Quick Replies

quick_replies(title, quick_replies_list)

quick_replies_list - list of quick replies text

['reply1', 'reply2', 'reply3']


title = "Choose something"
replies= ['reply1', 'reply2', 'reply3']
fb_quick_replies = fb.quick_replies(title, replies)

Image Response


url - image URL


url = "https://www.xyz.com/image.png"
fb_image = fb.image_response(url)

Card Response

card_response(title, buttons)

card title - title of the card
buttons - list of buttons

	['button1', 'hello'],
	['button2', 'hello again']


title = "this is a card"
buttons = [
	['button1', 'hello'],
	['button2', 'hello again']

fb_card = fb.card_response(title, buttons)

Dialogflow Fulfillment Responses

Fulfillment Text


fulfillmentText - defult response text ex.

text = "This is a fulfillment text"
df_fft = main_response.fulfillment_text(text)

Fulfillment Messages

fulfillment_messages(self, response_objects)

response_objects - list of supported response (any of the above)

[aog_sr, aog_list, aog_suggestions, fb_text, fb_card]


res_objects = [aog_sr, aog_list, aog_suggestions]
ff_msgs = main_response.fulfillment_messages(res_objects)

Output Contexts

output_contexts(session, contexts)

session - session Id of the request
contexts - list of contexts

	['context_name', 'lifespanCount', 
			'paramter_name': 'value'

Followup Event Input

followup_event_input(name, parameters)

name - event name
paramters - event parameters

	'parameter_name': 'values',
	'another_parameter_name': 'values',

Main Response

main_response(fulfillment_text, fulfillment_messages=None, output_contexts=None, followup_event_input=None):

fulfillment_text - Fulfillment text object
fulfillment_messages - Fulfillment messages object
output_contextstext - Output contexts object
followup_event_input - Followup event input object

Return this as your main fulfillment response.

We are working to add more responses in the future. Please give your feedback and do contribute if you like.

Developed by Pragnakalp Techlabs - Artificial Intelligence, Machine Learning, Deep Learning, Chatbots Development