How to save user email or number in sqllite databse

How chatbot can save user emails or numbers in sqllite database permanent and when user ask his email chatbot will give his email.

@Vish Are you taking the emails and numbers from user as an input?

Yes @swetangkashyap. How bot will save the emails or numbers of persons from user as input and when i will ask a query about persons email can it answer.

@Vish - For these scenario, there are two ways we can achieve this:

  1. Migrate your DB to postgresql and store the username in temp or user variable. Use knex to store it in any custom table. While asking bot use an action to run a SQL query and fetch the results.

  2. You can create a rest API for your database using PHP or any other tool. Store the new username and email in a db and do a GET call every time you wish to fetch information about user and email details and do a POST call to save in DB if the user is new.

Thanks @swetangkashyap

1 Like

Even without Postgres, you can use the user attributes and built in function setAttribute to save that data, and you have access to these attributes in any hook for easy retrieval.

1 Like

Can u explain with example how setAttribute to save a user email and how hook retrieve that email in sqllite database. Using built in function

This post was flagged by the community and is temporarily hidden.

In an action following the user prompt, you can use the “user” variable which contains the user attributes, then setAttributes to add your email, here’s a sample: = event.payload.text
  bp.users.setAttributes(,, user)

And in any other action, you can refer to :wink:

Happy Building :robot:

Can u give me steps to save 3 email with name in default sqllite using attributes.