SUSI iOS, web and Android clients allow the user to rate the SUSI Skills in a 5-star rating system. Users can write about how much particular skill is helpful for them or if improvements are needed. Users can rate skills from one to five star as well. Here we will see how to submit feedback for SUSI skills and how it is implemented on SUSI iOS.
How to submit feedback –
- Go to Skill Listing Screen < Skill Detail Screen
- Scroll to the feedback section
- Write feedback about SUSI skill
- Click on POST button to post the skill feedback
An anonymous user can not submit skill feedback. You must have to logged-in in order to post skill feedback. If you are not logged-in and click POST button to post skill feedback, an alert is presented with Login option, by clicking Login, the user is directed to Login screen where the user can log in and later can post skill feedback.
Implementation of posting skill feedback –
Google’s Material textfield is used for skill feedback text field. We have assigned TextField class from Material target to skill feedback text field to make it very interactive and give better user experience.
Skill feedback text field in the normal state –
Skill feedback text field in the active state –
When the user clicks POST after writing skill feedback, we check if the user is logged-in or not.
if let delegate = UIApplication.shared.delegate as? AppDelegate, let user = delegate.currentUser { ... }
We have saved the logged-in user globally using AppDelegate shared method during login and using it here. The AppDelegate is sort of like the entry point for the application. It implements UIApplicationDelegate and contains methods that are called when application launches, when is going to the background (i.e. when the user hit the home key), when it’s opened back up, and more. The AppDelegate object is stored as a property on the UIApplication class and is accessible from anywhere in swift classes.
Case 1: If the user is not logged-in, we show a popup to the user with the login option
By clicking Login, the user is directed to Login screen where the user can log in and later can post skill feedback.
Case 2: If the user is already logged-in, we use the endpoint below for posting skill feedback –
http://api.susi.ai/cms/feedbackSkill.json
ModelWith following parameters –
- Group
- Skill
- Feedback
- Access token
Client.sharedInstance.postSkillFeedback(postFeedbackParam) { (feedback, success, responseMessage) in DispatchQueue.main.async { if success { self.skillFeedbackTextField.text = "" self.skillFeedbackTextField.resignFirstResponder() self.view.makeToast(responseMessage) } else { self.view.makeToast(responseMessage) } } }
In return response, we get feedback posted by the user –
{ feedback: "Helpful", session: { ... }, accepted: true, message: "Skill feedback updated" }
Resources –
You must log in to post a comment.