mirror of
https://github.com/jlengrand/dialogflow-fun.git
synced 2026-03-10 08:11:22 +00:00
Update creation agent and positive float
This commit is contained in:
@@ -7,10 +7,8 @@ import com.google.cloud.dialogflow.v2beta1.ProjectName;
|
||||
public class CreateAgent {
|
||||
|
||||
private static final String GOOGLE_AUTH_ENV_NAME = "GOOGLE_APPLICATION_CREDENTIALS";
|
||||
// private static final String AGENT_NAME = "dialogflow-fun-agent";
|
||||
// private static final String AGENT_ID =
|
||||
// "ac522b80-e75b-40cd-9493-269fbb4ef634";
|
||||
// private static final String ENTITY_TYPE_ID = "Developer";
|
||||
static final String PROJECT_NAME = "dialogflow-fun-agent-live-jhwm";
|
||||
// private static final String PROJECT_NAME = "dialogflow-fun";
|
||||
|
||||
private static EntityCreator entityCreator = new EntityCreator();
|
||||
|
||||
@@ -20,6 +18,7 @@ public class CreateAgent {
|
||||
System.out.println("Error with Google Authentication. Exiting...");
|
||||
System.exit(0);
|
||||
}
|
||||
System.out.println(System.getenv().get(GOOGLE_AUTH_ENV_NAME));
|
||||
|
||||
entityCreator.deleteAllEntityTypes();
|
||||
entityCreator.createContactEntityType();
|
||||
@@ -33,7 +32,7 @@ public class CreateAgent {
|
||||
|
||||
try {
|
||||
AgentsClient agentsClient = AgentsClient.create();
|
||||
Agent myAgent = agentsClient.getAgent(ProjectName.of("dialogflow-fun"));
|
||||
Agent myAgent = agentsClient.getAgent(ProjectName.of(PROJECT_NAME));
|
||||
System.out.println(myAgent.getDisplayName());
|
||||
System.out.println(myAgent.getDescription());
|
||||
|
||||
|
||||
@@ -12,15 +12,14 @@ import data.ReadNames;
|
||||
|
||||
public class EntityCreator {
|
||||
|
||||
private static final String CONTACT_ENTITY_NAME = "names_composite";
|
||||
private static final String PROJECT_NAME = "dialogflow-fun";
|
||||
private static final String CONTACT_ENTITY_NAME = "contact";
|
||||
|
||||
private ReadNames namesReader = new ReadNames();
|
||||
|
||||
public void createContactEntityType() {
|
||||
try {
|
||||
EntityTypesClient entityTypesClient = EntityTypesClient.create();
|
||||
ProjectAgentName parent = ProjectAgentName.of(PROJECT_NAME);
|
||||
ProjectAgentName parent = ProjectAgentName.of(CreateAgent.PROJECT_NAME);
|
||||
|
||||
List<String> names = namesReader.getListOfNames();
|
||||
List<Entity> contactEntities = names.stream().map(n -> Entity.newBuilder().setValue(n).build())
|
||||
@@ -38,7 +37,7 @@ public class EntityCreator {
|
||||
|
||||
public void deleteAllEntityTypes() throws IOException {
|
||||
EntityTypesClient entityTypesClient = EntityTypesClient.create();
|
||||
ProjectAgentName parent = ProjectAgentName.of(PROJECT_NAME);
|
||||
ProjectAgentName parent = ProjectAgentName.of(CreateAgent.PROJECT_NAME);
|
||||
|
||||
for (EntityType entityType : entityTypesClient.listEntityTypes(parent).iterateAll()) {
|
||||
System.out.println("Deleting " + entityType.getDisplayName() + " with name " + entityType.getName());
|
||||
@@ -54,7 +53,7 @@ public class EntityCreator {
|
||||
|
||||
try {
|
||||
EntityTypesClient entityTypesClient = EntityTypesClient.create();
|
||||
ProjectAgentName parent = ProjectAgentName.of(PROJECT_NAME);
|
||||
ProjectAgentName parent = ProjectAgentName.of(CreateAgent.PROJECT_NAME);
|
||||
for (EntityType entityType : entityTypesClient.listEntityTypes(parent).iterateAll()) {
|
||||
System.out.println(entityType.getDisplayName());
|
||||
List<Entity> entities = entityType.getEntitiesList();
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Scanner;
|
||||
|
||||
public class ReadNames {
|
||||
|
||||
private static final String NAMES_FILE_LOCATION = "names2";
|
||||
private static final String NAMES_FILE_LOCATION = "names_composite";
|
||||
|
||||
public List<String> getListOfNames() throws FileNotFoundException {
|
||||
|
||||
|
||||
@@ -247,4 +247,8 @@ Allyn Claire
|
||||
Magdalene Michna
|
||||
Leticia Jorgenson
|
||||
Jaleesa Dally
|
||||
Candace Tootle
|
||||
Candace Tootle
|
||||
georges
|
||||
bob
|
||||
suzann
|
||||
ellen
|
||||
@@ -48,7 +48,7 @@ public class DialogFlowService {
|
||||
}
|
||||
|
||||
private String createTransactionDialogResponse(Transaction transaction){
|
||||
return "Your last transaction was for " + transaction.getDetails().getDescription() + " with an amount of " + (transaction.getDetails().getValue().getAmount()) + transaction.getDetails().getValue().getCurrency() + ". Your new balance is " + transaction.getDetails().getNewBalance().getAmount() + transaction.getDetails().getNewBalance().getCurrency();
|
||||
return "Your last transaction was for " + transaction.getDetails().getDescription() + " with an amount of " + (-transaction.getDetails().getValue().getAmount()) + transaction.getDetails().getValue().getCurrency() + ". Your new balance is " + transaction.getDetails().getNewBalance().getAmount() + transaction.getDetails().getNewBalance().getCurrency();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user