Skip to content
This repository was archived by the owner on Dec 3, 2023. It is now read-only.

samples: add sample code for ConversationProfile, Conversation and Participant#832

Merged
chingor13 merged 20 commits intogoogleapis:mainfrom
deliaqi:main
Mar 17, 2022
Merged

samples: add sample code for ConversationProfile, Conversation and Participant#832
chingor13 merged 20 commits intogoogleapis:mainfrom
deliaqi:main

Conversation

@deliaqi
Copy link
Copy Markdown
Contributor

@deliaqi deliaqi commented Jan 27, 2022

Hi, this is Jiaqi Liu from CCAI - Assist and Knowledge team. We are trying to add java sample code for APIs related to CCAI-features, like answer record management and conversation management. This is the first PR for updating answer record, could you help with reviewing it? Let me know anything else needed for checking in the code. Thanks!

@snippet-bot
Copy link
Copy Markdown

snippet-bot Bot commented Jan 27, 2022

Here is the summary of changes.

You are about to add 3 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label Bot added api: dialogflow Issues related to the googleapis/java-dialogflow API. samples Issues that are directly related to samples. labels Jan 27, 2022
@chingor13 chingor13 requested a review from a team January 27, 2022 20:33
@chingor13 chingor13 removed their assignment Jan 27, 2022
@chingor13 chingor13 added the blunderbuss: assign Instruct blunderbuss to assign someone label Jan 27, 2022
@blunderbuss-gcf blunderbuss-gcf Bot removed the blunderbuss: assign Instruct blunderbuss to assign someone label Jan 27, 2022
@chingor13 chingor13 changed the title add UpdateAnswerRecord sample code samples: add UpdateAnswerRecord sample code Jan 27, 2022
Copy link
Copy Markdown
Contributor

@chingor13 chingor13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think according to the guidelines, you should add a static main method with sample values.

Comment thread samples/snippets/src/main/java/com/example/dialogflow/AnswerRecordManagement.java Outdated
Comment thread samples/snippets/src/main/java/com/example/dialogflow/AnswerRecordManagement.java Outdated
Comment thread samples/snippets/src/test/java/com/example/dialogflow/UpdateAnswerRecordTest.java Outdated
Comment thread samples/snippets/src/test/java/com/example/dialogflow/UpdateAnswerRecordTest.java Outdated
Comment thread samples/snippets/src/main/java/com/example/dialogflow/AnswerRecordManagement.java Outdated
@averikitsch averikitsch removed their assignment Jan 27, 2022
@deliaqi deliaqi requested a review from chingor13 January 28, 2022 22:39
@deliaqi deliaqi marked this pull request as draft January 29, 2022 01:10
@deliaqi deliaqi marked this pull request as ready for review February 1, 2022 04:38
@deliaqi deliaqi marked this pull request as draft February 3, 2022 23:20
@deliaqi deliaqi marked this pull request as ready for review February 15, 2022 22:57
@deliaqi
Copy link
Copy Markdown
Contributor Author

deliaqi commented Feb 15, 2022

Hi Jeff, could you review the updated code again? Let me know if you have other comments!

Comment thread samples/snippets/src/main/java/com/example/dialogflow/AnswerRecordManagement.java Outdated
Comment thread samples/snippets/src/test/java/com/example/dialogflow/UpdateAnswerRecordTest.java Outdated
Comment thread samples/snippets/src/test/java/com/example/dialogflow/UpdateAnswerRecordTest.java Outdated
@deliaqi deliaqi changed the title samples: add UpdateAnswerRecord sample code samples: add sample code for ConversationProfile, Conversation and Participant Feb 24, 2022
@deliaqi
Copy link
Copy Markdown
Contributor Author

deliaqi commented Feb 24, 2022

Try to add sample code that requires less long-alive resources first after discussing with @chingor13. The starting point can be sample code for ConversationProfile, Conversation and Participant.
I have updated the code and removed the previous code for AnswerRecord, could you review the PR again?

@chingor13 chingor13 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 8, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 8, 2022
@chingor13 chingor13 added the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 8, 2022
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 8, 2022
Copy link
Copy Markdown
Contributor

@lesv lesv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Region Tags are missing
  • Tests can be in a single file if that makes things easier.
  • Never System.setOut(null);
  • Please read SAMPLE_FORMAT

Comment on lines +73 to +89
SuggestionFeatureConfig articleSuggestionFeatureConfig =
SuggestionFeatureConfig.newBuilder()
.setSuggestionFeature(
SuggestionFeature.newBuilder().setType(Type.ARTICLE_SUGGESTION).build())
.setSuggestionTriggerSettings(
SuggestionTriggerSettings.newBuilder()
.setNoSmalltalk(true)
.setOnlyEndUser(true)
.build())
.setQueryConfig(
SuggestionQueryConfig.newBuilder()
.setKnowledgeBaseQuerySource(
KnowledgeBaseQuerySource.newBuilder()
.addKnowledgeBases(articleSuggestionKbName.toString()))
.setMaxResults(3)
.build())
.build();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow - that looks complicated. Is there an easier way to present this since we are trying to teach users here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality-wise, it's hard to simplify it as we should include such nested configurations to make the feature work, but we can improve the readability by adding variables one by one and also add more descriptions.

Comment on lines +136 to +137
deleteConversationProfile(conversationProfileNameToDelete);
conversationProfileNameToDelete = null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like a failure will leave a lot of conversation Profile's around. Perhaps you'd like to make things a bit more robust.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be mitigated by checking conversationProfileNameToDelete during tearDown. Do you have other suggestions?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We often look for >24h old resources in the setUp() method and delete them. That way if we crash, they are eventually removed.

Comment thread samples/snippets/src/test/java/com/example/dialogflow/CreateConversationTest.java Outdated
Comment thread samples/snippets/src/test/java/com/example/dialogflow/CreateParticipantTest.java Outdated
@deliaqi deliaqi requested a review from lesv March 15, 2022 18:57
@deliaqi
Copy link
Copy Markdown
Contributor Author

deliaqi commented Mar 15, 2022

  1. The suggestion about making one single test file is reasonable, maybe we can add an integration test file, including the workflow from creating a conversation profile to creating participants, while the current separate unit tests could still make sense for testing each component.
  2. The regional tags should have been added, if that means comments like // [START dialogflow_create_conversation] and // [END dialogflow_create_conversation]. Could @lesv confirm it please?

@lesv
Copy link
Copy Markdown
Contributor

lesv commented Mar 15, 2022

@deliaqi Please internally visit github/ and join googleapis

@lesv lesv added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Mar 15, 2022
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 15, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 16, 2022
@deliaqi
Copy link
Copy Markdown
Contributor Author

deliaqi commented Mar 16, 2022

@deliaqi Please internally visit github/ and join googleapis

Thanks, done!

@lesv lesv added owlbot:ignore instruct owl-bot to ignore a PR owlbot:run Add this label to trigger the Owlbot post processor. labels Mar 16, 2022
@lesv
Copy link
Copy Markdown
Contributor

lesv commented Mar 16, 2022

Assuming owlbot runs, you should be able to merge.

@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 16, 2022
@chingor13 chingor13 added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. and removed owlbot:ignore instruct owl-bot to ignore a PR labels Mar 17, 2022
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 17, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 17, 2022
@chingor13 chingor13 merged commit b76764a into googleapis:main Mar 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: dialogflow Issues related to the googleapis/java-dialogflow API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants