Host a Zendesk form for all our products#175
Conversation
|
For testing, one will need to have the following We currently don't have a Zendesk Sandbox account so beware that creating tickets through this form while running this locally, actually creates tickets that the support team sees. Please label them accordingly. Also, the credentials needed for the |
MelissaAutumn
left a comment
There was a problem hiding this comment.
Can we dynamically retrieve the product and type fields on the backend and provide them to the frontend?
And thanks for getting this up. Lots of good work, just some feedback.
.env.example
Outdated
|
|
||
| # Zendesk (contact support form) custom fields | ||
| ZENDESK_PRODUCT_FIELD_ID= | ||
| ZENDESK_TYPE_OF_REQUEST_FIELD_ID= |
There was a problem hiding this comment.
Could we dynamically pull these on the backend and add them to window._site on page render?
There was a problem hiding this comment.
Potentially, there's an endpoint for it in Zendesk API but the API key that we have at the moment doesn't have permissions to make the request.
I can see the "pro" of getting them dynamically by allowing the changes in the Zendesk dashboard to be applied automagically in the form without code intervention but the "con" of it is always having an extra request when loading. I wonder if those fields are going to be changed a lot or not 🤔
There was a problem hiding this comment.
Can you follow up with @malini tomorrow if you haven't already gotten a new token with read permissions.
There was a problem hiding this comment.
Now getting the fields dynamically! Currently, there is only a specific user that have access to that endpoint so I will DM you the credentials to be used for testing this. Thanks! 🙇
| { label: 'Thunderbird Assist', value: 'thunderbird_assist' }, | ||
| { label: 'Thunderbird Appointment', value: 'thunderbird_appointment' }, | ||
| { label: 'Thunderbird Send', value: 'thunderbird_send' } | ||
| ]; |
There was a problem hiding this comment.
I think these will need to just be the product names, we might need to drop Assist for now (I'm not sure if we're launching with that) and add Thundermail.
There was a problem hiding this comment.
Hmm I thought these need to be the exact values as expected from the Zendesk form configs so I got those from here: #173 (comment) (happy to change them here and sync with someone who has Zendesk access to change there too, of course!)
| { label: 'Provide Feedback or Request Features', value: 'provide_feedback_or_request_features' }, | ||
| { label: 'Payments & Billing', value: 'payments___billing' }, | ||
| { label: 'Not listed', value: 'not_listed' } | ||
| ]; |
There was a problem hiding this comment.
I believe I chose provide_feedback_or_request_features
| { | ||
| "id": settings.ZENDESK_TYPE_OF_REQUEST_FIELD_ID, | ||
| "value": ticket_fields.get("ticket_type") | ||
| } |
There was a problem hiding this comment.
Might need to double check this as it's not being passed through.
8d6f6da to
7545d8e
Compare
8c04919 to
5f584f0
Compare
5f584f0 to
e1c9a9c
Compare
MelissaAutumn
left a comment
There was a problem hiding this comment.
Some minor things, looking good!
| return JsonResponse({ | ||
| 'success': True, | ||
| 'ticket_fields': fields_with_options | ||
| }) |
There was a problem hiding this comment.
Since we control the returb structure here, we should return the data in a way that the frontend can just use without any post processing.
I think making field_with_options a dict keyed by title would work
There was a problem hiding this comment.
Ah that makes sense, much better indeed! Changed in this commit.
|
|
||
| const data = await response.json(); | ||
|
|
||
| if (data.success && data.ticket_fields) { |
There was a problem hiding this comment.
We should be able to just pick the field type out of the return value and set it without any looping.
There was a problem hiding this comment.
Yep, that makes sense! Thanks! Changed in this commit.
| const data = await response.json(); | ||
|
|
||
| if (!data.success) { | ||
| errorText.value = 'Failed to submit contact form'; |
There was a problem hiding this comment.
Do we get an error from the server? if so please show the error on the frontend
There was a problem hiding this comment.
We do indeed, changed here, thanks!
| if not result['success']: | ||
| return JsonResponse({ | ||
| 'success': False, | ||
| 'error': result.get('error', 'Failed to fetch ticket fields') |
There was a problem hiding this comment.
On the backend can you wrap text with _( ... ). Eventually we'll have localization, and _() is just an easy way to extract and replace strings.
There was a problem hiding this comment.
TIL! Thanks, changed here and will keep that in mind for the next tasks on accounts 🙇
| zendesk_api_response = zendesk_client.upload_file(uploaded_file) | ||
|
|
||
| if not zendesk_api_response['success']: | ||
| return JsonResponse( |
There was a problem hiding this comment.
missing l10n _( ... ). For strings with variables you'll want to switch to .format iirc.
| except Exception as e: | ||
| return JsonResponse({ | ||
| 'success': False, | ||
| 'error': f'Failed to upload file {uploaded_file.name}: {str(e)}' |
MelissaAutumn
left a comment
There was a problem hiding this comment.
LGTM, I'll add the secrets post merge.
|
|
||
| // Set Product field options and ID | ||
| if (fields['Product']) { | ||
| const productField = fields['Product']; |
There was a problem hiding this comment.
We should probably constify these titles. But it's a non-blocking issue.
There was a problem hiding this comment.
Good point, thanks! Added the constants to the same file for now but can move it to a move designated space in the future


Description of the Change
[Backend changes]
POST /contactroute for accounts that hosts a contact form (the form itself is a Vue component) that uses the Zendesk Requests API to replace the current Zendesk form.POST /contact/attach_fileroute to upload a file to Zendesk and generate a token to be later attached to the ticket creation. [Zendesk Docs for Attaching Files][Frontend changes]
ContactSupportVuethat uses theservices-uiform components for visual consistency (see image below). Please note that the UI itself will probably evolve / change very soon so please focus on the functionality itself for the time being.Important
The original Zendesk form is configured with
custom_fieldsthat require specific field IDs to work. The Vue form values (the select values) and the Python env vars related to those need to be in sync with whatever is configured in Zendesk. In other words, changing Zendesk'scustom_fieldswill break the form if they don't get updated in the code. More info here.Benefits
Applicable Issues
#173