How to extract one phone number from contact.FindContact search results in Bixby Capsule

89 Views Asked by At

The goal of capsule is to borrow just One contact number from the contact search result of contactInfos of type ContactInfo and output or add into a structure with other properties.

Getting ContactNameConcept input from User via Bixby Voice.

text (ContactNameConcept) {
    extends(contact.SearchTerm)
}

Using ContactNameConcept as input contactName to get search results from Contacts.

action (FindContactNumber) {
  type (Calculation)
  collect {
    input (contactName) {
      type (ContactNameConcept)
      min (Optional) max (One)
    }

    computed-input (contactInfos) {
      type (contact.ContactInfo)
      min (Optional) max (Many)

      compute {
        intent {
          goal: contact.FindContact
          value: $expr(contactName)
        }
      }
      // What should be done here?
    }
  }

Thanks

1

There are 1 best solutions below

0
BixbyDevSupport-Tokonyan On BEST ANSWER

If the idea is when contact.FindContact returns multiple results, only send one to the linked Javascript, developer can do the following

    computed-input (contactInfos) {
      type (contact.ContactInfo)
      min (Optional) max (One) // make sure change to max (One)
      default-select {
        with-rule {
          select-first
        }
      }
      compute {
        intent {
          goal: contact.FindContact
          value: $expr(contactName)
        }
      }
    }

However, I would say it is also possible to handle all results in Javascript. Consider the case when user search for "John", and there are "John Smith" and "John Doe". Depends on your capsule, it might make sense to handle both in Javascript.