Mobile Development 10 min read

HarmonyOS NEXT Intent Framework: Overview, Use Cases, and Integration Guide

This article introduces HarmonyOS NEXT's Intent Framework, explains its distribution capabilities such as habit and event recommendations, skill invocation, and local search, showcases practical scenarios including movie ticket reminders and JD Finance services, and provides step‑by‑step integration instructions with code examples.

JD Tech Talk
JD Tech Talk
JD Tech Talk
HarmonyOS NEXT Intent Framework: Overview, Use Cases, and Integration Guide

HarmonyOS NEXT introduces an Intent Framework that intelligently distributes business functions of applications to various system entry points such as XiaoYi Dialogue, XiaoYi Search, and XiaoYi Suggestions, enhancing user experience and creating new traffic growth opportunities.

Distribution capabilities include:

Habit recommendation – XiaoYi Suggestions: the system learns user habits and recommends relevant app content at appropriate times.

Event recommendation – XiaoYi Suggestions: based on time, location, etc., the system pushes reminder services (e.g., movie ticket reminders).

Skill invocation – XiaoYi Dialogue: AI large‑model understands natural language input and triggers app or meta‑service functions.

Local search – XiaoYi Search: a local index is built for registered intents, allowing keyword search of in‑app content.

These intelligent services significantly improve user experience, drive traffic growth, and increase user stickiness.

Typical usage scenarios :

Movie ticket order data sharing for timely viewing reminders.

Flight price queries via XiaoYi Dialogue (e.g., "How much does a flight from Shenzhen to Beijing cost?").

JD Finance scenarios such as querying consumption details, JD White Card bills, repayment, product recommendation, and new stock information.

Through these scenarios, JD Finance can provide more convenient, personalized financial services, enhancing user satisfaction and dependence.

Intent runtime logic shows how applications or meta‑services share intents with HarmonyOS, enabling local content indexing and proactive suggestions.

Basic integration process :

Select the desired feature and define the intent interface with Huawei.

Register the intent on the device side by creating insight_intent.json under

PROJECT_HOME/entry/src/main/resources/base/profile/insight_intent.json

:

{
  "insightIntents":[
    {
      "intentName":"xxxx",
      "domain":"BankingDomain",
      "intentVersion":"1.0.1",
      "srcEntry":"./ets/insightintents/IntentExecutorImpl.ets",
      "uiAbility":{
        "ability":"MainUIAbility",
        "executeMode":["foreground"]
      }
    }
  ]
}

Implement the intent executor class IntentExecutorImpl.ets (path:

PROJECT_HOME/entry/src/main/ets/insightintents/IntentExecutorImpl.ets

) with methods to handle UIAbility foreground execution and business logic:

export default class IntentExecutor extends InsightIntentExecutor {
  /**
   * Execute intent in UIAbility foreground mode
   */
  async onExecuteInUIAbilityForegroundMode(intentName: string, intentParam: Record<string, Object>,
    pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> {
    switch (intentName) {
      case DispatchTools.xxxx:
        return this.viewAccountChange(intentParam, pageLoader);
      case DispatchTools.xxxx1:
        return this.viewAccountChange(intentParam, pageLoader);
      default:
        console.error('invalid intent name', intentName);
        let result: insightIntent.ExecuteResult = {
          code: -1,
          result: {
            "error": "invalid intent name",
            "intentName": intentName
          }
        };
        return result;
    }
  }

  private viewAccountChange(param: Record<string, Object>, pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> {
    return new Promise((resolve, reject) => {
      resolve({
        code: 0,
        result: { message: 'Intent execute succeed' }
      });
    });
  }
}

Handle intent dispatching, e.g., in dispatchAI:

dispatchAI(want: Want | undefined) {
  try {
    if (want && want.parameters) {
      let url: string | undefined = undefined;
      let bid: string | undefined = undefined;
      let name = want?.parameters['ohos.insightIntent.executeParam.name'] as string;
      let param = want.parameters['ohos.insightIntent.executeParam.param'] as Record<string, Object>;
      switch (name) {
        case DispatchTools.PAY_REPAYMENT:
          url = DispatchTools.xxxx;
          bid = DispatchTools.xxxx;
          break;
        // ... other cases
      }
      if (url && !PageMatchUtil.matchPath(url, false)) {
        jrouter.navigation(url);
      }
    }
  } catch (e) {
    // handle error
  }
}

Validate integration using the testing tool (pre‑beta) by submitting a JSON payload such as:

{
  "bundleName":"com.jd.xxx",
  "executeMode":"foreground",
  "intentName":"xxx",
  "intentParam":{
    "entityId":"C10194368",
    "cardTailNumber":"1234",
    "cardType":"CreditCard",
    "timeInterval":[163739320000,163739320000]
  }
}

After the app is fully released (not in gray‑scale or test release), register the intent via AppGallery → Management Center → Ecosystem Services → Smart Services → XiaoYi Open Platform; the draft will be created automatically.

Future outlook aims to further integrate core functions of the HarmonyOS Intent Framework (XiaoYi Search and Suggestions) to continuously improve mobile financial service experiences, making JD Finance a trusted partner.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Mobile DevelopmentHarmonyOSCode ExampleAI integrationIntent Framework
JD Tech Talk
Written by

JD Tech Talk

Official JD Tech public account delivering best practices and technology innovation.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.