Syncing your user data

How to enhance queries for Contacts and Home Automation Domains.

Asif
Houndify
3 min readJan 25, 2018

--

Some Houndify domains require indexed user data to support richer sets of queries. For example:

  1. The Email domain needs to know about the user’s contacts to figure out to whom the email is addressed.
  2. The Home Automation Commands domain will understand broader range of queries if it knows about the names and types of available connected devices.

This tutorial demonstrates how domains work with indexed user data.

User Contacts

If you have enabled SMS domain and your user makes a query: “Text Alice.”, the user will be asked to provide the missing contact number. If the name is not common it might not even get recognized, unless the contacts of that user are already synced.

Similarly, the Phone and Email domains become more useful if the contacts are synced. These domains all rely on the underlying User Contacts domain.

Adding Contact Data

You can pass in contacts via a special text request with a query, user_contacts_request and contact data in UserContactsRequests field of the Request Info JSON.

Here is an example of a User Contacts request using the Houndify Python SDK.

User Contacts request using the Houndify Python SDK.

It is important that you use a unique UserId for each user, as the data will be stored for that key. Also you need to send these requests only when the stored data becomes outdated.

With UserContactsRequest you can add, modify, delete, find and clear contact data for the users. More information about these actions can be found on the UserContactsRequest JSON reference page. Every contact can have several optional fields, like FirstName, LastName, PhoneEntries, EmailEntries, etc.

The full list of supported fields can be found on OneContact JSON reference page.

Home Automation

Home Automation Commands domain can be used to control smart devices. It supports general queries like “Turn on the lights.” without syncing any user data, but if you index available devices, the domain will understand the queries that mention specific device names or groups. Devices can be grouped arbitrarily, but these groups can represent the rooms, for example.

Adding Device Data

A special index_user_devices_from_request_info text request with a JSON object insideClientState.IndexUserDevicesData in Request Info JSON can be made for indexing user devices.

Here’s an example:

Example of passing in device data for the Home Automation domain.

Indexing device groups is pretty similar and is done through index_user_groups_from_request_info text query and ClientState.IndexUserGroupsData object in Request Info JSON.

As with the User Contacts domain, it is important to use a unique UserID for each user, and you need to send these special indexing requests only when the stored data should be modified.

Both device and group indices can be cleared by sending an empty array in IndexUserDevicesData and IndexUserGroupsData fields respectively.

You can find the detailed description of the supported device and group fields here.

Conclusion

In this tutorial, we looked at how we can pass in user data via the Hound RequestInfo object to facilitate richer voice queries. Specifically, we looked at:

  1. Passing in user data to support voice recognition for contacts
  2. Passing in connected devices data to support voice recognition for connected devices.

Happy coding!

--

--