2

How can get the user name is Bixby providing any information about the user like his name?

I tried to add bixby-user-id-access and user-profile-access to use $vivContext to get some information but there is name for user. Also i tried to pass self.GetSelf but the result returned was empty and there is no user information.

computed-input (self) { 
      type (self.Self)
      min (Optional) max (One)
      compute {
        intent {
          goal: self.Self
          route: self.GetSelf
        }
      }
}
property (self) {
    type (self.Self)
    min (Required) max (One)
}

The value of self property

Medo
  • 35
  • 1
  • 6

1 Answers1

1

$vivContext does not contain such information. Please check here to see what $vivContext contains and how to access it in JS.

It is the correct approach to use viv.self library. To access you need user-profile-access permission. Read more about viv.self library here.

Please follow this example, developer needs setup their profile first on a Samsung phone. For developers not yet have a Samsung phone, one can try to get familiar with the structure by using viv.self.GetImaginarySelf. The name will be "Hi Bixby" when using viv.self.GetImaginarySelf.

You can also download and try the sample capsule provide in this KB article

action (GetAllNames) {
  description (__DESCRIPTION__)
  type (Search)
  collect {
    computed-input (self) {
      type (self.Self)
      min (Optional) max (One)
      compute {
        intent {
          goal: self.Self
          route: self.GetImaginarySelf // for developers has NO Samsung device
          // route: self.GetSelf // for release
        }
      }
    }
  }
  output (TextName)
}

And in linked JS in endpoints file, do this.

module.exports.function = function getAllNames (self) {
  var rslt = []
  rslt.push ("John")
  rslt.push ("Jane")
  if (self == null) {
    rslt.push ("NULL")
  }
  else {
    rslt.push(self.nameInfo.structuredName)
  }
  return rslt;
}

You should be able to see the name in result view. enter image description here

You should also be able to check other field of returned viv.self.Self structure in debugger window. enter image description here

  • Can you see this result it's almost empty? https://i.stack.imgur.com/G5IGC.png – Medo Jan 22 '20 at 14:38
  • because that is your own self property, not the computed from viv.self.Self. Copy the action, copy the JS, link them in endpoints. you should be able to see similar result. – BixbyDevSupport-Tokonyan Jan 22 '20 at 17:41
  • Should i add any property in the action concept if yes what the type of that property? In your case the Concept is **TextName**. if you can share it with me – Medo Jan 27 '20 at 14:07
  • can you share your capsule because i tried to copy action and JS file but still i'm having a empty Self This is result: Generic Error TypeError: Cannot read property "structuredName" from undefined – Medo Jan 27 '20 at 14:28
  • bixby.pdss.ProfileResult resultCode: PP_0002 resultMessage: No Contents – Medo Jan 27 '20 at 14:46
  • 1
    Please let me know if you ever setup the account on a Bixby enabled mobile device. You can also down and try the sample capsule provide in https://bixbydevelopers.zendesk.com/knowledge/articles/360042116834/ – BixbyDevSupport-Tokonyan Jan 28 '20 at 02:24
  • Thanks self.GetImaginarySelf solved my problem. Please edit you answer and your helpful comment in the sample capsule // route: self.GetImaginarySelf // for developers has NO Samsung device – Medo Jan 29 '20 at 14:10
  • Thank you for the note. Answered updated. Please accept the answer so it might help more developers. – BixbyDevSupport-Tokonyan Jan 29 '20 at 17:58