Skip to main content

Contact Search

To use the product database for contact search, you can follow these steps:

1. Upload your contacts

Upload your contacts to the product database using the LoyJoy backend. Each contact should have a unique identifier, such as a contact ID, and relevant information such as address, phone number, and email address. Take special note of the title and description fields, as these are the ones that will be shown in the chat interface. The title can be the name of the contact, while the description can include the address and phone number. You can also include a URL to the contact's website in the url field.

Example: Here is an example table you can use when uploading store locations to the product database:

reference_idtitledescriptionemailcityzip_codesphone_numberurl
1Peter NewmanYou can reach Peter Newman via phone [555-555-5555](tel:5555555555) or email [peter.newman@example.org](mailto:peter.newman@example.org)peter.newman@example.orgChicago60001,60002,60003555-555-5555https://example.org/peter-newman
2Kathy SmithYou can reach Kathy Smith via phone [555-123-4567](tel:5551234567) or email [kathy.smith@example.org](mailto:kathy.smith@example.org)kathy.smith@example.orgMiami33101,33102,33103555-123-4567https://example.org/kathy-smith
  • title: Contact name
  • description: E.g. email and phone number (shown in chat, can include Markdown links)
  • email, city, phone_number, url: Additional fields for search/filtering or information
  • zip_codes: A comma-separated list of zip codes that the contact serves (used for search/filtering). You can control which contact is shown for which zip code by changing the list of zip codes in this column.

You can add more contacts by adding more rows to this table.

2. Search for Contacts

There are various ways to search for contacts in the product database, for example:

  • Ask the user to enter a city or zip code and save it in a variable (e.g. via a questionnaire), which is then used to query the product database
  • Add an AI Agent module with a products_search tool that queries the product database based on user input. The AI agent module can reply with the contact information or use the products_display tool to show the search results in a product gallery format.

All these methods function similarly: A variable is set to narrow down the search criteria, and the product database is queried using this variable.

3. Display the Results

Once the search is performed, you can display the results using the Product Feed module. To do this, you need to add a Product database connector to the module and add an SQL query that uses the variable set in the previous step to filter the results. For example, if you set a variable location to the user's input, you can use the following SQL query:

SELECT * FROM products WHERE city LIKE '%${location}%' OR zip_code LIKE '%${location}%';