GoogleCloudPlatform / dfcx-scrapi

A high level scripting API for bot builders, developers, and maintainers.
Apache License 2.0
88 stars 59 forks source link

un-converatble datatype in flows - class 'google.cloud.dialogflowcx_v3beta1.types.page.TransitionRoute' #194

Closed devyanil16 closed 1 month ago

devyanil16 commented 3 months ago

https://github.com/GoogleCloudPlatform/dfcx-scrapi/blob/8a229db34ea613443040a2ca2cb45ff590452169/examples/bot_building_series/bot_building_101.py#L85C5-L85C5 (use case - create agent, add pages, flow, intents update present flows with intents and route flows to new page)

hi! the data type of my_tr does not match with dsf.transition_routes

my_tr data type - <class 'google.cloud.dialogflowcx_v3beta1.types.flow.Flow'> dsf (target) - <class 'google.cloud.dialogflowcx_v3beta1.types.page.TransitionRoute'> (is it possible to convert these to class <class 'google.protobuf.pyext._message.RepeatedCompositeContainer'>??)

How to append the data types? also if you could give any example for such use case, would be great.

error -

image

steps to reproduce - https://github.com/GoogleCloudPlatform/dfcx-scrapi/blob/main/examples/bot_building_series/bot_building_101.ipynb

kmaphoenix commented 3 months ago

@devyanil16 thanks for submitting this issue!

I've just stepped through the Bot Building 101 series notebook and did not have any issues.
You can see here that the Transition Route and Flow were updated properly:
image

When you encountered the issue, where you using the .py version or the .ipynb version?
The errors suggests that you might have tried to build the TransitionRoute directly from the base class imports, but I'm not 100% sure from just the error screenshot.

This notebook is quite old actually (3+ years?), and it could definitely use an update.
Since then, we've released some better Builder classes that I would suggest using instead.
These provide a much more simple way to build your proto objects directly, then push them to your Agent when ready.
Take a look at this Builders notebook for examples on how to use them.