1

I'm working on a Flutter app and I'm trying to integrate Zendesk for customer support. I'm struggling to find any resources or examples for how to do this in Flutter, so I thought I'd reach out to the community for some help.

Has anyone successfully implemented Zendesk in a Flutter app before? If so, could you please share your approach and any resources you used? Specifically, I'm looking to:

- Add a help center to the app
- Allow users to submit tickets from within the app
- Display ticket status and history

Any advice, code snippets, or examples would be greatly appreciated! Thanks in advance.

1 Answer 1

1

You can implement your own FloatingButton that opens a dialog with a form.

That's my provider to send zendesk ticket

class ZendeskProvider {
  const ZendeskProvider({
    required HttpProvider httpProvider,
    required Environment environment,
  })  : _environment = environment,
        _httpProvider = httpProvider;

  final HttpProvider _httpProvider;
  final Environment _environment;

  String get _token => _environment.zendeskToken; // your zendesk token here
  String get _host => 'https://[YOUR_ACCOUNT].zendesk.com/api/v2/requests.json'; // Your account zendesk host

  Future<void> report({
    required ReportInfos reportInfos,
  }) async {
    final response = await _httpProvider.doRequest(HttpRequest.post(
      _host,
      '',
      httpParams: HttpParams(
        body: {
          'request': {
            'comment': {'body': reportInfos.body, 'uploads': []},
            'fields': {
              '360024868852': reportInfos.reason,
              '360048922472': reportInfos.name,
            },
            'requester': {
              'email': reportInfos.email,
              'locale_id': 19,
              'name': reportInfos.email.split('@')[0],
            },
            'subject': reportInfos.reason,
            'tags': ['${reportInfos.device}_widget'],
            'ticket_form_id': null,
            'via_id': 48,
          },
        },
      ),
    )..addHeader({'Authorization': 'Basic $reportInfos.email/token:$_token'}));

    if (response.status != HttpStatus.success) {
      throw Error();
    }
  }
}

You can send this request when form submitted.

These are the args I need to send to Zendesk, some of then I get through the form, others, like device, I set with web or mobile.

class ReportInfos {
  final String name;
  final String email;
  final String reason;
  final String device;
  final String body;

  ReportInfos({
    required this.name,
    required this.email,
    required this.reason,
    required this.device,
    required this.body,
  });
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.