def mail_folder(self, args): """gives the relationship between the mail and the folder to which it belongs""" print("In mail_folder") get_mailFolder_url = graph_endpoint.format('/me/mailFolders') r = make_api_call('GET', get_mailFolder_url, self.access_token) send_data = {'values': []} message = MessageClass() if r.status_code == 200: obj = r.json() data = obj["value"] for i in range(0, len(data)): obj1 = data[i] send_data['values'].append({ 'displayName': obj1["displayName"], 'id': obj1["id"], 'parentFolderId': str(obj1["parentFolderId"])[0:75] }) message.data = send_data print("returning") return message.to_json() else: print(r.status_code) print(r.text) return "{0}: {1}".format(r.status_code, r.text)
def list_user_details(self, args): if 'id' not in args: return self.generate_simple_message( "Please provide parameter 'id' in your command") else: #Check if Id is a number if args['id'].is_digit(): user_id = int(args['id']) else: return self.generate_simple_message( "Please provide an integer value for parameter 'id' in your command" ) try: #Searching for user with id user_object = SiteUsers.objects.get(id=user_id) except SiteUsers.DoesNotExist: #return error message if user does not exist return self.generate_simple_message( "User with that id does not exist") user_details_message = MessageClass() user_details_message.message_text = "User Id - %d, Fullname - %s, Date joined - %s, Subscription - %s" % ( user_id, user_object.full_name, user_object.date_joined, user_object.subscription) user_json = serializers.serialize("json", user_object) #Adding JSON data to message for use in workflows user_details_message.data = user_json return user_details_message.to_json()
def get_organization(self, args): """ This function gets the ID and the name of the organization. This is a picklist function used by all other functions """ headers = { "Content-Type": "application/json", "Authorization": "Zoho-oauthtoken" + " " + self.zohoinvoice_access_token } url = settings.ZOHO_ORGANIZATION_URL response = requests.get(url, headers=headers) # print(response.text) # print(type(response)) response_json = response.json() # print(response_json) data = response_json['organizations'] message = MessageClass() message.message_text = "Organization list:" name_list = {'org': []} for i in data: name_list['org'].append({ "id": str(i['organization_id']), "name": str(i['name']) }) message.data = name_list print(message.data) return message.to_json()
def change_user_subcription(self, args): if 'id' not in args or 'subscription' not in args: return self.generate_simple_message( "Please provide parameter 'id' and 'subscription' in your command" ) else: #Check if Id is a number if args['id'].is_digit(): user_id = int(args['id']) else: return self.generate_simple_message( "Please provide an integer value for parameter 'id' in your command" ) try: #Searching for user with id user_object = SiteUsers.objects.get(id=user_id) #changing subscription value user_object.subscription = args['subscription'] except SiteUsers.DoesNotExist: #return error message if user does not exist return self.generate_simple_message( "User with that id does not exist") user_details_message = MessageClass() user_details_message.message_text = "User subscription changed" user_json = serializers.serialize("json", user_object) #Adding JSON data to message for use in workflows user_details_message.data = user_json return user_details_message.to_json()
def webhook_delivered(request, webhook_id): print("In webhook_delivered") """ Webhook function to notify user about update in component """ urllib.parse.unquote(request.body.decode("utf-8")) params_dict = urllib.parse.parse_qsl(request.body) params = dict(params_dict) #Extracting necessary data recipient = params[b'recipient'].decode('utf-8') # Fetching yellowant object try: yellow_obj = YellowUserToken.objects.get(webhook_id=webhook_id) print(yellow_obj) access_token = yellow_obj.yellowant_token print(access_token) integration_id = yellow_obj.yellowant_integration_id service_application = str(integration_id) print(service_application) # Creating message object for webhook message webhook_message = MessageClass() webhook_message.message_text = "Mail delivered to " + str(recipient) attachment = MessageAttachmentsClass() attachment.title = "Mail Stats upto last 1 month" button_get_components = MessageButtonsClass() button_get_components.name = "1" button_get_components.value = "1" button_get_components.text = "Get all stats" button_get_components.command = { "service_application": service_application, "function_name": 'get_stats', "data": {} } attachment.attach_button(button_get_components) webhook_message.data = {"recipient_email_id": recipient} webhook_message.attach(attachment) #print(integration_id) # Creating yellowant object yellowant_user_integration_object = YellowAnt( access_token=access_token) # Sending webhook message to user send_message = yellowant_user_integration_object.create_webhook_message( requester_application=integration_id, webhook_name="notify_delivered", **webhook_message.get_dict()) return HttpResponse("OK", status=200) except YellowUserToken.DoesNotExist: return HttpResponse("Not Authorized", status=403)
def responsewebhook(request, hash_str=""): """Whenever a new response is completed the user gets notified""" try: ya_obj = YellowUserToken.objects.get(webhook_id=hash_str) except YellowUserToken.DoesNotExist: return HttpResponse("Not Authorized", status=403) try: data_obj = json.loads(request.body) print(data_obj) notification_type = data_obj['event_type'] if notification_type == "response_completed": message = MessageClass() message.message_text = "New survey response completed" message.data = data_obj yauser_integration_object = YellowAnt( access_token=ya_obj.yellowant_token) send_message = yauser_integration_object.create_webhook_message(\ requester_application=ya_obj.yellowant_intergration_id, \ webhook_name="response_completed", **message.get_dict()) return HttpResponse("webhook_receiver/webhook_receiver/") except Exception as e: print(str(e)) return HttpResponse("Empty body")
def Collectors_Available(self, args): print("In view_details") survey_id = args["SurveyId"] url = "https://api.surveymonkey.com/v3/surveys/%s/collectors"%(survey_id) message = MessageClass() result = "Collectors available are: \n" try: response = requests.get(url, headers=self.headers) response_json = response.json() data = response_json["data"] send_data = {\ "collectors":[]\ } for i in range(len(data)): obj = data[i] name = obj["name"] id = obj["id"] send_data["collectors"].append({"id":id, "name":name}) result = result + str(i+1)+": "+ name+" "+ "ID is: "+ id+"\n" message.data = send_data message.message_text = result print(send_data) # use inbuilt sdk method to_json to return message in a json format accepted by YA return message.to_json() except Exception as e: print(str(e)) traceback.print_exc()
def all_page_ids(self,args): ''' Get all page ids for the user Basic inactive function to get dynamic inputs in all other functions. ''' sot = self.statuspage_access_token_object print(sot.user_integration_id) page_objects = PageDetail.objects.filter(user_integration_id=sot) m = MessageClass() data = [] m.message_text = "Here are your pages" #:\n" if len(page_objects) > 0 else "You don't have any pages." for page_object in page_objects: url = (settings.SP_API_BASE1 + page_object.page_id + ".json") response = requests.get(url, headers=self.headers) response_json = response.json() m.message_text += "{} - {}\n".format(response_json["name"], page_object.page_id) data.append({"name": response_json["name"],"page_id":str(page_object.page_id)}) # m = MessageClass() # data = [] # data.append({"page_id":"dfdsdfvd"}) # m.message_text = "Lol" m.data = data print(m.data) return m.to_json()
def update_incident(request,webhook_id): print("In update_incident") """ Webhook function to notify user about update in incident """ # Extracting necessary data data = (request.body.decode('utf-8')) response_json = json.loads(data) page_id = response_json['page']['id'] unsubscribe = response_json['meta']['unsubscribe'] incident_id = response_json['incident']['id'] name = response_json['incident']['name'] try: # Fetching yellowant object yellow_obj = YellowUserToken.objects.get(webhook_id=webhook_id) print(yellow_obj) access_token = yellow_obj.yellowant_token print(access_token) integration_id = yellow_obj.yellowant_integration_id service_application = str(integration_id) print(service_application) # Creating message object for webhook message webhook_message = MessageClass() webhook_message.message_text = "Updates in incident with Id : " + str(incident_id) + "\nName : " + str(name) attachment = MessageAttachmentsClass() attachment.title = "Incident operations" button_get_incidents = MessageButtonsClass() button_get_incidents.name = "1" button_get_incidents.value = "1" button_get_incidents.text = "Get all incidents" button_get_incidents.command = { "service_application": service_application, "function_name": 'all_incidents', "data": { 'page_id': page_id } } attachment.attach_button(button_get_incidents) webhook_message.data = {"page_id": page_id} webhook_message.attach(attachment) #print(integration_id) # Creating yellowant object yellowant_user_integration_object = YellowAnt(access_token=access_token) # Sending webhook message to user send_message = yellowant_user_integration_object.create_webhook_message( requester_application=integration_id, webhook_name="incident_updates_webhook", **webhook_message.get_dict()) return HttpResponse("OK", status=200) except YellowUserToken.DoesNotExist: return HttpResponse("Not Authorized", status=403)
def show_impact(args, user_integration): m = MessageClass() data = {'list': []} data['list'].append({"Value": 1, "name": "High"}) data['list'].append({"Value": 2, "name": "Medium"}) data['list'].append({"Value": 3, "name": "Low"}) m.data = data return m
def states(args, user_integration): m = MessageClass() data = {'list': []} data['list'].append({"State": 1, "State-name": "New"}) data['list'].append({"State": 2, "State-name": "In Progress"}) data['list'].append({"State": 3, "State-name": "On Hold"}) m.data = data return m
def add_new_pipeline(request, webhook_id): """ Webhook function to notify user about newly added pipeline """ data = request.body data_string = data.decode('utf-8') data_json = json.loads(data_string) name = data_json["current"]['name'] add_time = data_json["current"]['add_time'] url_tile = data_json["current"]['url_title'] order = data_json["current"]['order_nr'] # Fetching yellowant object yellow_obj = YellowUserToken.objects.get(webhook_id=webhook_id) access_token = yellow_obj.yellowant_token integration_id = yellow_obj.yellowant_integration_id service_application = str(integration_id) # Creating message object for webhook message webhook_message = MessageClass() webhook_message.message_text = "New pipeline created." + "\n" + "The pipeline name : " + str( name) attachment = MessageAttachmentsClass() button_get_pipeline = MessageButtonsClass() button_get_pipeline.name = "1" button_get_pipeline.value = "1" button_get_pipeline.text = "Get all pipelines" button_get_pipeline.command = { "service_application": service_application, "function_name": 'list_pipelines', "data": { 'data': "test", } } attachment.attach_button(button_get_pipeline) webhook_message.attach(attachment) # print(integration_id) webhook_message.data = { "Add Time": add_time, "Url title": url_tile, "Name": name, "Order": order, } # Creating yellowant object yellowant_user_integration_object = YellowAnt(access_token=access_token) # Sending webhook message to user send_message = yellowant_user_integration_object.create_webhook_message( requester_application=integration_id, webhook_name="new_pipeline", **webhook_message.get_dict()) return HttpResponse("OK", status=200)
def chooseColor(args,user_integration): """ Picklist function to return colors. """ m = MessageClass() data = {'list': []} data['list'].append({"Color": "White"}) data['list'].append({"Color": "Black"}) m.data = data return m
def list_regions(args, user_integration): m = MessageClass() credentials, subscription_id = get_credentials(user_integration) client = ResourceManagementClient(credentials, subscription_id) data = {'list': []} for item in client.resource_groups.list(): print(item.name) data['list'].append({"Resource_name": item.name}) print(data) m.data = data return m
def show_priorities(args, user_integration): m = MessageClass() data = {'list': []} data['list'].append({"Value": 1, "name": "Critical"}) data['list'].append({"Value": 2, "name": "High"}) data['list'].append({"Value": 3, "name": "Moderate"}) data['list'].append({"Value": 4, "name": "Low"}) data['list'].append({"Value": 5, "name": "Planning"}) m.data = data return m
def incident_resolved(request, webhook_id): # data = request.body data_string = data.decode('utf-8') data_json = json.loads(data_string) name = data_json['display_name'] entity_id = data_json['entity_id'] incident_number = data_json['incident_number'] # Fetching yellowant object yellow_obj = YellowUserToken.objects.get(webhook_id=webhook_id) access_token = yellow_obj.yellowant_token integration_id = yellow_obj.yellowant_integration_id service_application = str(integration_id) # Creating message object for webhook message webhook_message = MessageClass() webhook_message.message_text = "Incident Resolved\n The entity ID : " + str(entity_id) \ + "\nThe Incident Number : " + str(incident_number) attachment = MessageAttachmentsClass() attachment.title = "Incident Operations" button_get_incidents = MessageButtonsClass() button_get_incidents.name = "1" button_get_incidents.value = "1" button_get_incidents.text = "Get all incidents" button_get_incidents.command = { "service_application": service_application, "function_name": 'list_incidents', "data": { 'data': "test", } } attachment.attach_button(button_get_incidents) webhook_message.attach(attachment) # print(integration_id) webhook_message.data = { "Display Name": name, "Entity ID": entity_id, "Incident Number": incident_number, } # Creating yellowant object yellowant_user_integration_object = YellowAnt(access_token=access_token) # Sending webhook message to user yellowant_user_integration_object.create_webhook_message( requester_application=integration_id, webhook_name="new_incident_resolved", **webhook_message.get_dict()) return HttpResponse("OK", status=200)
def add_new_invoice(request, id): """ Webhook function to notify user about newly created invoice """ print(request.body) invoice_id = request.POST['ID'] contact_email = request.POST['Email'] total = request.POST['Total'] # Fetching yellowant object yellow_obj = YellowUserToken.objects.get(webhook_id=id) access_token = yellow_obj.yellowant_token integration_id = yellow_obj.yellowant_integration_id # service_application = str(integration_id) # Creating message object for webhook message webhook_message = MessageClass() webhook_message.message_text = "New invoice added" attachment = MessageAttachmentsClass() field = AttachmentFieldsClass() field.title = "Invoice ID" field.value = invoice_id attachment.attach_field(field) field1 = AttachmentFieldsClass() field1.title = "Total" field1.value = total attachment.attach_field(field1) field2 = AttachmentFieldsClass() field2.title = "Contact Email" field2.value = contact_email attachment.attach_field(field2) webhook_message.attach(attachment) # print(integration_id) webhook_message.data = { "Invoice ID": invoice_id, "Total": total, "Contact Email": contact_email, } # Creating yellowant object yellowant_user_integration_object = YellowAnt(access_token=access_token) # Sending webhook message to user yellowant_user_integration_object.create_webhook_message( requester_application=integration_id, webhook_name="new_invoice", **webhook_message.get_dict()) return HttpResponse("OK", status=200)
def probability_list(self, args): """ This is a picklist function which gives two options. 1 - Enable Probability 0 - Disable Probability """ message = MessageClass() data = {'list': []} data['list'].append({"probability": 0}) data['list'].append({"probability": 1}) # print(data) message.data = data return message.to_json()
def type_picklist(self, args): """ This is a picklist function which gives two options. Goods or Service """ message = MessageClass() message.message_text = "Product Type" data = {'list': []} data['list'].append({"type": "goods"}) data['list'].append({"type": "service"}) # print(data) message.data = data return message.to_json()
def user_role_picklist(self, args): """ This is a picklist function which gives the user roles. This supports add_user function """ message = MessageClass() message.message_text = "User Role" data = {'list': []} data['list'].append({"role": "admin"}) data['list'].append({"role": "staff"}) data['list'].append({"role": "timesheetstaff"}) # data['list'].append({"role": "goods"}) message.data = data return message.to_json()
def close_code(args, user_integration): m = MessageClass() data = {'list': []} data['list'].append({"Name": "Solved (Permanently)"}) data['list'].append({"Name": "Solved (Work Around)"}) data['list'].append({"Name": "Solved Remotely (Work Around)"}) data['list'].append({"Name": "Solved Remotely (Permanently)"}) data['list'].append({"Name": "Not Solved (Not Reproducible)"}) data['list'].append({"Name": "Not Solved (Too Costly)"}) data['list'].append({"Name": "Closed/Resolved By Caller"}) m.data = data return m
def get_incidents(args, user_integration): access_token_object = Servicenow_model.objects.get( user_integration=user_integration.id) access_token = access_token_object.access_token instance = access_token_object.instance url = " https://" + instance + ".service-now.com/api/now/table/incident" headers = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + access_token } m = MessageClass() response = requests.get(url=url, headers=headers) #print(response) #print(response.text) try: response = response.json() except: m.text = "Your Instance is not ready" return m response = response["result"] data = {'list': []} for i in response: desc = None for k, v in i.items(): if k == "number": #data['list'].append({"Instance_name": v,"sys_id"}:) incident = v #print (v) if k == "sys_id": sys = v if k == "short_description": desc = v if desc == None: desc = "Short description not available" data['list'].append({ "Instance_name": incident + " - " + desc, "sys_id": sys }) m.data = data return m
def list_all_vms_in_rg(args, user_integration): message = MessageClass() GROUP_NAME = args.get("Resource-Group") credentials, subscription_id = get_credentials(user_integration) compute_client = ComputeManagementClient(credentials, subscription_id) print('\nList VMs in resource group') message.message_text = "Listing all VMs" data = {'list': []} for vm in compute_client.virtual_machines.list(GROUP_NAME): print("\tVM: {}".format(vm.name)) data['list'].append({"VM_name": vm.name}) print('inside for') message.message_text = message.message_text + "\n" + vm.name message.data = data return message
def activity_type(self, args): """ This is a picklist function which returns all the various activity types """ message = MessageClass() data = {'list': []} data['list'].append({"activity": "Call"}) data['list'].append({"activity": "Meeting"}) data['list'].append({"activity": "Task"}) data['list'].append({"activity": "Deadline"}) data['list'].append({"activity": "Email"}) data['list'].append({"activity": "Lunch"}) # print(data) message.data = data return message.to_json()
def Contact_Lists(self, args): # List all the contact lists(groups) the user has created. user_id = self.user_integration.yellowant_integration_id url = (settings.SM_API_BASE + settings.VIEW_CONTACTLISTS) try: message = MessageClass() message.message_text = "Contact list:\n" attachment = MessageAttachmentsClass() response = requests.get(url, headers=self.headers) response_json = response.json() data = response_json["data"] send_data = {\ 'list':[]\ } for i in range(len(data)): button1 = MessageButtonsClass() obj = data[i] name = obj["name"] id = obj["id"] send_data['list'].append({'id':id, 'name':name}) button1.text = name button1.value = name button1.name = name button1.command = { "service_application": user_id, "function_name": "ContactListDetails",\ "data":{\ "ContactListId":id\ } } attachment.attach_button(button1) message.attach(attachment) message.data = send_data # use inbuilt sdk method to_json to return message in a json format accepted by YA return message.to_json() except Exception as e: print("Exception occured is") print(str(e)) traceback.print_exc()
def list_all_customer_ids(self, args): ''' Picklist function to get list of customer ids ''' print("In list_all_customer_ids") # API call parameters for getting all customer ids route = "/v3/company/" + self.realmID + "/query?query=select * from Customer" bearer = getBearerTokenFromRefreshToken( self.quickbook_access_token_object.refreshToken, self.user_integration) auth_header = 'Bearer ' + bearer.accessToken headers = { 'Authorization': auth_header, 'content-type': 'application/json' } # Consuming the API r = requests.get(settings.PRODUCTION_BASE_URL + route, headers=headers) # Response check if r.status_code == requests.codes.ok: # Fetching response in JSON response = json.loads(json.dumps(xmltodict.parse(r.text))) # print(response) customer_data = response['IntuitResponse']['QueryResponse'][ 'Customer'] # Creating a message object using YA SDK functions m = MessageClass() m.message_text = "This is list all customer picklist function" ### Hardcoded ### Change It ! data = [] #customer_data[i] for i in range(0, len(customer_data)): data.append({"id": "12"}) m.data = data return m.to_json() else: m = MessageClass() d = json.loads(r.text) m.message_text = d["Fault"]["Error"][0]["Detail"] return m.to_json() #"{0}: {1}".format(r.status_code, r.text)
def pick_list_users(self, args): """ Implements the pick list to list all the users """ url = settings.VICTOROPS_ALL_USERS response = requests.get(url, headers=self.headers) response_json = response.json() message = MessageClass() message.message_text = "User List" data = response_json['users'][0] name_list = {'users': []} for i in range(len(data)): name_list['users'].append({"username": data[i]['username']}) print(name_list) message.data = name_list return message.to_json()
def employee_created(request, id): print('Inside employee created') name = request.POST['name'] contact_id = request.POST['id'] last_name = request.POST['last_name'] email = request.POST['email'] yellow_obj = UserIntegration.objects.get(webhook_id=id) access_token = yellow_obj.yellowant_integration_token integration_id = yellow_obj.yellowant_integration_id service_application = str(integration_id) # Creating message object for webhook message webhook_message = MessageClass() webhook_message.message_text = "New Employee added" attachment = MessageAttachmentsClass() field = AttachmentFieldsClass() field.title = "Name" field.value = name + " " + last_name attachment.attach_field(field) field1 = AttachmentFieldsClass() field1.title = "Email ID" field1.value = email attachment.attach_field(field1) # print(integration_id) webhook_message.data = { "Name": name, "ID": contact_id, "Email": email, "LastName": last_name } webhook_message.attach(attachment) # Creating yellowant object yellowant_user_integration_object = YellowAnt(access_token=access_token) # Sending webhook message to user send_message = yellowant_user_integration_object.create_webhook_message( requester_application=service_application, webhook_name="createemployeewebhook", **webhook_message.get_dict()) return HttpResponse("OK", status=200)
def View_Surveys(self, args): # Display the Surveys associated with the users account. print("In view surveys") user_id = self.user_integration.yellowant_intergration_id url = (settings.SM_API_BASE + settings.VIEW_SURVEY) response = requests.get(url, headers=self.headers) response_json = response.json() print(response_json) data = response_json["data"] send_data = {"surveys": []} message = MessageClass() message.message_text = "Surveys" for i in range(len(data)): attachment = MessageAttachmentsClass() send_data['surveys'].append({ 'id': data[i]["id"], 'title': data[i]["title"] }) obj = data[i] title = obj["title"] id = obj["id"] button1 = MessageButtonsClass() attachment.title = title field1 = AttachmentFieldsClass() field1.title = "ID" field1.value = id attachment.attach_field(field1) button1.text = "Know more" button1.value = id button1.name = id button1.command = { "service_application": user_id, "function_name": "ViewSurveyDetails", "data":{\ "SurveyId":id\ } } attachment.attach_button(button1) message.attach(attachment) message.data = send_data print(message) # use inbuilt sdk method to_json to return message in a json format accepted by YA return message.to_json()
def list_all_vms(args, user_integration): message = MessageClass() credentials, subscription_id = get_credentials(user_integration) compute_client = ComputeManagementClient(credentials, subscription_id) print('Integration ID is', user_integration.yellowant_integration_token) print('ID is ', user_integration.id) obj = azure.objects.get(user_integration_id=user_integration.id) print(obj.AZURE_tenant_id) print('\nList VMs in subscription') data = {'list': []} message.message_text = "Listing all VMs" for vm in compute_client.virtual_machines.list_all(): print("\tVM: {}".format(vm.name)) message.message_text = message.message_text + "\n" + vm.name data['list'].append({"VM_name": vm.name}) message.data = data return message
def webhook(request, hash_str=""): '''Respond to the webhook verification (GET request) by echoing back the challenge parameter.''' print("Inside webhook") if request.method == "GET": print("Inside webhook validation") challenge = request.GET.get('challenge',None) if challenge != None: return HttpResponse(challenge,status=200) else: return HttpResponse(status=400) else: print("In notifications") webhook_id = hash_str data = (request.body.decode('utf-8')) response_json = json.loads(data) print(response_json) data = { "users": [], "accounts": [] } try: yellow_obj = YellowUserToken.objects.get(webhook_id=webhook_id) print(yellow_obj) access_token = yellow_obj.yellowant_token print(access_token) integration_id = yellow_obj.yellowant_integration_id service_application = str(integration_id) print(service_application) # Creating message object for webhook message webhook_message = MessageClass() webhook_message.message_text = "File/Folder updated !" attachment = MessageAttachmentsClass() attachment.title = "Updated file/folder details :" for i in range(0,len(response_json['list_folder']['accounts'])): field1 = AttachmentFieldsClass() field1.title = "Id : " field1.value = response_json['list_folder']['accounts'][i] data["accounts"].append(response_json['list_folder']['accounts'][i]) attachment.attach_field(field1) attachment2 = MessageAttachmentsClass() attachment2.title = "User update details :" for i in range(0, len(response_json['delta']['users'])): field2 = AttachmentFieldsClass() field2.title = "Id : " field2.value = response_json['delta']['users'][i] data["users"].append(response_json['delta']['users'][i]) attachment2.attach_field(field2) button = MessageButtonsClass() button.name = "1" button.value = "1" button.text = "Get all files and folders " button.command = { "service_application": service_application, "function_name": 'get_all_folders', "data" : {"path": "", "recursive": True, "include_media_info": False, "include_deleted": False, "include_has_explicit_shared_members": False, "include_mounted_folders": True} } attachment.attach_button(button) webhook_message.attach(attachment) webhook_message.attach(attachment2) #print(integration_id) print("-----------") print(data) print("------------") webhook_message.data = data # Creating yellowant object yellowant_user_integration_object = YellowAnt(access_token=access_token) # Sending webhook message to user send_message = yellowant_user_integration_object.create_webhook_message( requester_application=integration_id, webhook_name="files_folders_update", **webhook_message.get_dict()) return HttpResponse("OK", status=200) except YellowUserToken.DoesNotExist: return HttpResponse("Not Authorized", status=403)