Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions simple_chatwoot/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,25 @@ def list_inboxes(self)->Dict:
json_response_dict = check_response(response, 200, "Message Creation Failed")

return json_response_dict

def toggle_conversation_status(self, conversation_id: str, status: str)->str:
"""
Toggles the status of the conversation between open and resolved
"""
headers = {'api_access_token': self.api_access_token, 'Content-type': 'application/json'}
url = "{domain}/api/v1/accounts/{account_id}/conversations/{conversation_id}/toggle_status".format(
domain=self.domain,
account_id=self.account_id,
conversation_id=conversation_id
)

payload = {
'status' : status
}

response = requests.post(url, data=json.dumps(payload), headers=headers)

json_response_dict = check_response(response, 200, "Toggle Status Failed")
status = str(json_response_dict['payload']['current_status'])

return status