Getting started with Dialog Managers - utwente-interaction-lab/interaction-lab GitHub Wiki
Getting started with DialogFlow
Getting started
-
Create a Google Cloud Platform account via this link.
-
If you want to run DialogFlow locally (if not, you can skip this step), follow the next steps to set up authentication:
A. Go to the Google Cloud console (this link).
B. Set up a service account for your project. Navigate to 'IAM & Admin' > 'Service Accounts'.
C. Fill in the information, and set the role to 'owner'. Save the service account.
D. Click your service account link. If you cant find it, navigate to 'APIs & Services'> 'Credentials', scroll down to the tab 'Service Accounts' and click your service account link, or go to 'IAM & Admin'> 'Service Accounts'.
E. Go to the tab 'Keys' and click 'Add key' > 'Create new key' and choose 'json'.
F. Click 'Create' and your download will start immediately. Save the .json file to your computer. Keep your key private as it allows access to all your project files, without asking for an additional password!.
G. Add to your python file:
import os
from google.cloud import dialogflow
credential_path = (r'[path to json key file]')
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = credential_path
- Follow the following Google tutorial: here.
The corresponding code can also be found in this Google Colab Notebook.
Advanced
- When trying to build more complicated functions with the DialogFlow API, you can use the following site as a starting point for finding documentation: https://cloud.google.com/python/docs/reference/dialogflow/latest
- For sentiment analysis: https://cloud.google.com/dialogflow/es/docs/how/sentiment
- Extra quick-start built-a-chatbot: https://medium.com/velotio-perspectives/chatbots-with-google-dialogflow-build-a-fun-reddit-chatbot-in-30-minutes-d9105fe83cd8
- TTS with DialogFlow: https://cloud.google.com/dialogflow/es/docs/how/detect-intent-tts
Getting started with Rasa
Getting started
Follow the steps with Windows Powershell
- Make sure you are running python 3.9. Newer did not seem to work, a older version might work.
- For windows to be able to run batch files and run the activate command make sure "Change execution policy to allow local PowerShell scripts to run without signing. Require signing for remote scripts." is enabled
- In an empty folder, run:
python -m venv ./venv
- Activate the venv:
.\venv\Scripts\activate
- Install Rasa:
pip install rasa
- Initialise a new rasa application:
rasa run -enable-api
- You can now use the HTTP API to interface with the RASA dialogue
- For example, run the following python script to estimate the conversational intent for a given text:
import requests
import json
payload = {'text':'hi how are you?'}
headers = {'content-type': 'application/json'}
r = requests.post('http://localhost:5005/model/parse', json=payload, headers=headers)
print(r.content)
- Server response will be:
{"text":"hi how are you?","intent":{"name":"bot_challenge","confidence":0.9699272513389587},"entities":[],"text_tokens":[0,2],[3,6],[7,10],[11,14](/utwente-interaction-lab/interaction-lab/wiki/0,2],[3,6],[7,10],[11,14),"intent_ranking":[{"name":"bot_challenge","confidence":0.9699272513389587},{"name":"greet","confidence":0.029042799025774002},{"name":"goodbye","confidence":0.000709471118170768},{"name":"mood_great","confidence":0.00016511892317794263},{"name":"affirm","confidence":5.772636359324679e-5},{"name":"deny","confidence":5.0280494178878143e-5},{"name":"mood_unhappy","confidence":4.738435018225573e-5}],"response_selector":{"all_retrieval_intents":[],"default":{"response":{"responses":null,"confidence":0.0,"intent_response_key":null,"utter_action":"utter_None"},"ranking":[]}}}'
Advanced
- How responses work in Rasa: https://www.youtube.com/watch?v=k2uA5gxTM80
- How entities work in Rasa: https://www.youtube.com/watch?v=7nFXhd3AF78
- How to use slots in Rasa: https://www.youtube.com/watch?v=vNBHzSLZukc
- Finetune a model in Rasa: https://rasa.com/docs/rasa/tuning-your-model/ & https://www.youtube.com/watch?v=YxMzz6NF6Zw
- How to do sentiment analysis: https://www.datacamp.com/tutorial/simplifying-sentiment-analysis-python