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

User blocked the conversation with the bot #4

Closed
juancotrino opened this issue Aug 28, 2024 · 2 comments
Closed

User blocked the conversation with the bot #4

juancotrino opened this issue Aug 28, 2024 · 2 comments

Comments

@juancotrino
Copy link

juancotrino commented Aug 28, 2024

I am using the example in your README.md file to test a webhook created with Workflows. I changed the image url, EMAIL and NAME strings to my corresponding company email and name, and a test image url. The workflow is failing and I am getting this error in the failure report:

Request to the Bot framework failed with error: '{\"error\":{\"code\":\"ConversationBlockedByUser\",\"message\":\"User blocked the conversation with the bot.\"}}'.

Any ideas of what is going on or what should I do to make this work?

Thanks in advance.

@ALERTua
Copy link
Owner

ALERTua commented Aug 28, 2024

I just tested my example code from scratch:

from msteamsapi import TeamsWebhook, AdaptiveCard, Container, FactSet, ContainerStyle, TextWeight, TextSize

webhook = TeamsWebhook('https://prod-87.westeurope.logic.azure.com:443/workflows/blabla/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=blabla')

card = AdaptiveCard(title='card title', title_style=ContainerStyle.DEFAULT)
card.add_background(url="https://github.com/ALERTua/msteamsapi/raw/main/tests/background.png")

container = Container(style=ContainerStyle.DEFAULT)

card.mention('[email protected]', 'me', add_text_block=True)
mention_tag = card.mention('[email protected]', 'this dude')

container.add_image("https://github.com/ALERTua/msteamsapi/raw/main/tests/background.png", "image alt text")
container.add_text_block(
    'multiline\n\ntext\n\nmention 1: %s' % mention_tag,
    size=TextSize.DEFAULT, weight=TextWeight.DEFAULT, color="default"
)

factset = FactSet(('fact 1', 'fact 1 value'))
factset.add_facts(('fact 2', 'fact 2 value'), ('fact 3', 'fact 3 value'))
container.add_fact_set(factset)

card.add_container(container)

for i, url in enumerate(['https://google.com/', 'https://goo.gle']):
    card.add_url_button('url %s' % i, url)

webhook.add_cards(card)
webhook.send()

and everything works like a charm
image
did you create a webhook for a public channel? a standard one?
image

@juancotrino
Copy link
Author

Ok. Got it working now. It was because I had the channel restrictions on like this:
image
I thought the connector was the one posting the actual card, but it seems to be posting the card from my email, so I had to turn that setting off, or I assume giving specific posting permissions to my user would also work.

@ALERTua ALERTua pinned this issue Aug 29, 2024
@ALERTua ALERTua closed this as completed Aug 29, 2024
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