Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cards (example) not working #155

Closed
DJF3 opened this issue Mar 17, 2021 · 6 comments
Closed

Cards (example) not working #155

DJF3 opened this issue Mar 17, 2021 · 6 comments

Comments

@DJF3
Copy link

DJF3 commented Mar 17, 2021

The cards functionality doesn't seem to work. If that is confirmed, can we remove the code and the documentation?

from webexteamssdk.cards.card import AdaptiveCard
from webexteamssdk.cards.components import TextBlock
from webexteamssdk.cards.options import Colors, HorizontalAlignment
from webexteamssdk.cards.inputs import Text, Number
from webexteamssdk.cards.actions import Submit

Always results in: "ModuleNotFoundError: No module named 'webexteamssdk.cards'"

Can someone confirm that the cards functionality is broken (and won't be fixed)?

@marksull
Copy link
Collaborator

marksull commented Mar 30, 2021

@DJF3 Insert ".model." before ".cards". For example:

>>> from webexteamssdk.models.cards.card import AdaptiveCard
>>> from webexteamssdk.models.cards.inputs import Text, Number
>>> from webexteamssdk.models.cards.components import TextBlock
>>> from webexteamssdk.models.cards.actions import Submit
>>> greeting = TextBlock("Hey hello there! I am a adaptive card")
>>> first_name = Text('first_name', placeholder="First Name")
>>> age = Number('age', placeholder="Age")
>>> 

@DJF3
Copy link
Author

DJF3 commented Apr 1, 2021

Thank you Mark!

When I apply these changes to the example shown here this error appears:

TypeError: Object of type AdaptiveCard is not JSON serializable

@marksull
Copy link
Collaborator

marksull commented Apr 1, 2021

Yes, that is caused by a bug that will be resolved by this pull request: #141

Either wait for the pull request to be merged, or use the above branch until then, or instead of passing in the ActiveCard, pass in the raw dictionary for the attachement:

For example, instead of using this:

api.messages.create(text="fallback", roomId="...", cards=card)

replace it with:

from webexteamssdk.utils import make_attachment
...
api.messages.create(text="fallback", roomId="...", attachments=[make_attachment(card)])

That should provide a good workaround for now.

@DJF3
Copy link
Author

DJF3 commented Apr 1, 2021

Great, it's working now.

Thanks for the quick support!

@DJF3
Copy link
Author

DJF3 commented Apr 7, 2021

Either wait for the pull request to be merged, or use the above branch until then, or instead of passing in the ActiveCard, pass in the raw dictionary for the attachement:

Hope that this pull request gets merged asap!

@DJF3 DJF3 closed this as completed Apr 7, 2021
@DJF3
Copy link
Author

DJF3 commented Apr 13, 2021

For those who need a working example with more features used: https://github.com/DJF3/Webex-SDK-Cards-example

@aquaMAX aquaMAX mentioned this issue Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants