Voice Skills Account Linking UI BizBundle

Last Updated on : 2024-06-24 08:18:28download

Voice Skills Account Linking UI BizBundle provides the custom skills of Amazon Alexa and Google Assistant. This allows users to quickly bind voice skills to your app and accelerates the process for you to get WWA certification.

Preparation

  1. The UI BizBundle relies on Smart Life App SDK. Before the following procedure, you must first finish the steps in Preparation, Fast Integration with Smart Life App SDK for Android, and Integrate with Framework.

  2. To enable quick binding of voice skills, contact Tuya’s staff who deal with value-added services to subscribe to Amazon Alexa Skill Account Linking and Google Assistant Action Account Linking.

Integrate with the UI BizBundle

Add the following dependency to the file build.gradle of module:

dependencies {
	implementation 'com.tuya.smart:tuyasmart-bizbundle-amazon_google_bind:4.2.0-33'
        implementation 'org.jetbrains.kotlin:kotlin-reflect:1.3.72'
}

The Voice Skills Account Linking UI BizBundle uses the content of the H5 mall. Therefore, the UI BizBundle must depend on the Mall UI BizBundle of the same version. For more information about how to configure build.gradle to implement the app mall with H5 pages, see Mall UI BizBundle. In this case, you only need to add the dependencies and do not need to subscribe to the mall value-added service.

Configure app_scheme

  1. Customize app_scheme in the root directory local.properties to identify your app. This value is the App Schema field value specified by you to create the app based on the SDK on the Tuya Developer Platform.

    app_scheme=testdemo
    
  2. Set the following parameters required by AndroidManifest.xml in build.gradle of module:

    defaultConfig {
    	...
    		Properties properties = new Properties()
    		properties.load(project.rootProject.file('local.properties').newDataInputStream())
    	manifestPlaceholders = [
    				   INTERNAL_HOST: "${properties.getProperty("app_scheme")}".concat('.app.tuya.com'),
                    ALEXA_AUTH_INTERNAL_HOST: "${properties.getProperty("app_scheme")}".concat('.applink.smart321.com'),
                    ALEXA_AUTH_INTERNAL_HOST_NEW: "${properties.getProperty("app_scheme")}".toLowerCase(Locale.ENGLISH).concat('.applink.smart321.com'),
    
    	]
    }
    

Configure Amazon Alexa

Add the following configurations to the resource file res:

// `true` means that navigation from the Amazon Alexa authorization page to your app is supported. `false` means that navigation from the Amazon Alexa authorization page to your app is not supported.
<bool name="is_show_alexa_oem_account"></bool>
// `true` means that Amazon Alexa is allowed to pull up the app authorization page. `false` means that Amazon Alexa is not allowed to pull up the app authorization page.
<bool name="is_alexa_to_tuyapp_support">Whether Amazon Alexa is allowed to pull up the app authorization page</bool>

Configure Google Assistant

Add the following configurations to the resource file res:

<string name="google_flip_client_id">Replaced with `Client-ID` provided by Tuya</string>

You must provide the following information to Tuya’s staff who deal with value-added services. Accordingly, Tuya will provide you with the Google Action Client-ID:

  • App package for Android.
  • SHA256 hash value.
  • Custom setting of app_scheme. This value is the App Schema field value specified by you to create the app based on the SDK on the Tuya Developer Platform.

Bind Amazon Alexa skills

API description

fun alexaBind(mActivity: Activity, homeId: String, callback: ITuyaResultCallback<Boolean>)

Parameters

Parameter Type Description
homeId String The home ID.
callback ITuyaResultCallback The callback.

Example

TuyaSocialLoginBindManager.Companion.getInstance().alexaBind(mActivity, homeId, new ITuyaResultCallback<Boolean>() {
	@Override
	public void onSuccess(Boolean result) {}

	@Override
	public void onError(String errorCode, String errorMessage) {}
});

Bind Google Assistant skills

API description

fun googleBind(mActivity: Activity, homeId: String, callback: ITuyaResultCallback<Boolean>)

Parameters

Parameter Type Description
homeId String The home ID.
callback ITuyaResultCallback The callback.

Example

TuyaSocialLoginBindManager.Companion.getInstance().googleBind(mActivity, homeId, new ITuyaResultCallback<Boolean>() {
	@Override
	public void onSuccess(Boolean result) {}

	@Override
	public void onError(String errorCode, String errorMessage) {}
});

Unbind voice skills

To unbind the voice skills of Amazon Alexa and Google Assistant, you only need to get a list of skills and process the events of tapping the list.

Get the list of bound skills

API description

fun getAuthorityPlatforms(cb: ResultCallback<ArrayList<AuthorityBean?>>?)

Data model of AuthorityBean

Field Type Description
time Number The time when a voice skill was bound.
icon String The URL address of the icon.
clientType String The platform type.
status Int
  • 1: bound
  • 0: unbound
platformName String The name of the platform. Example:
  • Alexa
  • Google

Example

SocialAuthManagerClient.INSTANCE.getInstance(MicroContext.getApplication())
			.getAuthorityPlatforms(new ResultCallback<ArrayList<AuthorityBean>>() {
				@Override
				public void onSuccess(ArrayList<AuthorityBean> authorityBeans) {
					//get bound list success
				}

				@Override
				public void onFailure(@Nullable String s, @Nullable String s1) {
					//get bound list onFailure
				}
			});

Unbind skills

API description

//request code
private static final int REQUEST_REFRESH_MANAGER_AUTHORIZATION = 151;

private void gotoDeAuthorize(Context context, AuthorityBean authorityBean) {
        UrlBuilder mBuilder = UrlRouter.makeBuilder(context, "SocialAuthManagerAppAction");
        Bundle newBundle = new Bundle();
        newBundle.putString("action", "gotoDeAuthorize");
        newBundle.putParcelable("authority_bean", authorityBean);
        mBuilder.setRequestCode(REQUEST_REFRESH_MANAGER_AUTHORIZATION);
        mBuilder.putExtras(newBundle);
        UrlRouter.execute(mBuilder);
    }

Parameters

Parameter Type Description
context Context Context
authorityBean AuthorityBean Data model of AuthorityBean

Update bound skill list

Updates the list of voice skills that have been bound with your app.

API description

   @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data){
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case REQUEST_REFRESH_MANAGER_AUTHORIZATION:
                if (RESULT_OK == resultCode) {
                  // Call the `getAuthorityPlatforms` method to refresh the list of skills.
                   
                }
                break;
            default:
                break;
        }
    }
  • We recommend that you use the Release version to debug the skill binding feature.

  • Smart Life App SDK will provide you with Google Action Client-ID after you provide Tuya with the following information:

    • App package for Android.
    • SHA256 hash value.
    • Custom setting of app_scheme. This value is the App Schema field value specified by you to create the app based on the SDK on the Tuya Developer Platform.