def test_conversations_send_to_conversation_with_attachment(self): card1 = HeroCard( title="A static image", text="JPEG image", images=[ CardImage( url="https://docs.com/en-us/bot-framework/media/designing-bots/core/dialogs-screens.png" ) ], ) card2 = HeroCard( title="An animation", subtitle="GIF image", images=[CardImage(url="http://i.giphy.com/Ki55RUbOV5njy.gif")], ) activity = Activity( type=ActivityTypes.message, channel_id=CHANNEL_ID, recipient=ChannelAccount(id=RECIPIENT_ID), from_property=ChannelAccount(id=BOT_ID), attachment_layout=AttachmentLayoutTypes.list, attachments=[ Attachment(content_type="application/vnd.card.hero", content=card1), Attachment(content_type="application/vnd.card.hero", content=card2), ], ) connector = ConnectorClient(self.credentials, base_url=SERVICE_URL) response = self.loop.run_until_complete( connector.conversations.send_to_conversation(CONVERSATION_ID, activity) ) assert response is not None
def create_receipt_card() -> Attachment: card = ReceiptCard( title='John Doe', facts=[ Fact(key="Order Number", value="1234"), Fact(key="Payment Method", value="VISA 5555-****") ], items=[ ReceiptItem( title="Data Transfer", price="$38.45", quantity="368", image=CardImage( url="https://github.com/amido/azure-vector-icons/raw/master/" "renders/traffic-manager.png")), ReceiptItem( title="App Service", price="$45.00", quantity="720", image=CardImage( url="https://github.com/amido/azure-vector-icons/raw/master/" "renders/cloud-service.png")) ], tax="$7.50", total="90.95", buttons=[ CardAction( type=ActionTypes.open_url, title="More Information", value= "https://azure.microsoft.com/en-us/pricing/details/bot-service/" ) ]) return CardFactory.receipt_card(card)
def create_receipt_card(self) -> Attachment: card = ReceiptCard() card.title = "Receipt Card - Sample" card.facts = [ Fact(key="Bill NO", value="2001"), Fact(key="Payment Mode", value="Cash") ] card.items = [ ReceiptItem( title="Bot Framework book", price="20Euro", quantity=1, image=CardImage( url="https://pypi.org/static/images/logo-small.6eef541e.svg" )), ReceiptItem( title="Python Book", price="100 Euro", quantity=5, image=CardImage( url="https://pypi.org/static/images/logo-small.6eef541e.svg" )) ] card.vat = "0.2" card.tax = "12%" card.total = "180" return CardFactory.receipt_card(card)
def create_welcome_card(self): title = "Benvenuto in BotTipBooks" subtitle = "Per iniziare ad utilizzare il bot effettuare il login oppure utilizzare il menu" image = CardImage(url="https://www.lineaedp.it/files/2017/01/bot.jpg") card = HeroCard(title=title, subtitle=subtitle, images=[image]) activity = MessageFactory.attachment(CardFactory.hero_card(card)) return activity
async def __send_intro_card(self, turn_context: TurnContext): card = HeroCard( title="Welcome to Universal Rentals!", text="""I am Owlbert the chat bot. How may I improve your experience?""", images=[CardImage(url="https://aka.ms/bf-welcome-card-image")], buttons=[ CardAction( type=ActionTypes.open_url, title="Register", text="Registration button", display_text="Registration button", value= "https://docs.microsoft.com/en-us/azure/bot-service/?view=azure-bot-service-4.0", ), CardAction( type=ActionTypes.open_url, title="Ask a question", text="Ask a question", display_text="Ask a question", value="https://www.google.com", ), ], ) return await turn_context.send_activity( MessageFactory.attachment(CardFactory.hero_card(card)))
async def __send_intro_card(self, turn_context: TurnContext): card = HeroCard( title=f"안녕하세요 {turn_context.activity.from_property.name} 님", text="", images=[CardImage(url="https://aka.ms/bf-welcome-card-image")], buttons=[ CardAction( type=ActionTypes.open_url, title="Get an overview", text="Get an overview", display_text="Get an overview", value="https://docs.microsoft.com/en-us/azure/bot-service/?view=azure-bot-service-4.0", ), CardAction( type=ActionTypes.open_url, title="Ask a question", text="Ask a question", display_text="Ask a question", value="https://stackoverflow.com/questions/tagged/botframework", ), CardAction( type=ActionTypes.open_url, title="Learn how to deploy", text="Learn how to deploy", display_text="Learn how to deploy", value="https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-howto-deploy-azure?view=azure-bot-service-4.0", ), ], ) return await turn_context.send_activity( MessageFactory.attachment(CardFactory.hero_card(card)) )
def account_SelectionForBill_card(): card = ThumbnailCard( title="Account List", text="Please select an account from which you want to pay the bill", images=[CardImage(url="")], buttons=[ CardAction( type=ActionTypes.im_back, title="Savings Account xxxxxxxxx4567 \n Opened date: 05/10/2010 \n Balance is $112.02", text="Balance is $112.02", display_text="Balance is $112.02", value="Debit from xxxxxxxxx4567", ), CardAction( type=ActionTypes.im_back, title="Current Account xxxxxxxxx4566 \n Opened date: 05/10/2012 \n Balance is $0.00", text="Balance is $0.00", display_text="Balance is $0.00", value="Debit from xxxxxxxxx4566", ), ], ) return card
def _create_select_items_result_attachment( self, search_query: str) -> MessagingExtensionAttachment: card_text = f"You said {search_query}" bf_logo = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQtB3AwMUeNoq4gUBGe6Ocj8kyh3bXa9ZbV7u1fVKQoyKFHdkqU" buttons = CardAction( type="openUrl", title="Click for more Information", value= "https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bots-overview" ) images = [CardImage(url=bf_logo)] buttons = [buttons] select_item_tap = CardAction(type="invoke", value={"query": search_query}) hero_card = HeroCard(title="You searched for:", text=card_text, images=images, buttons=buttons) preview = HeroCard(title=card_text, text=card_text, images=images, tap=select_item_tap) return MessagingExtensionAttachment( content_type=CardFactory.content_types.hero_card, content=hero_card, preview=CardFactory.hero_card(preview))
async def on_teams_messaging_extension_query( self, turn_context: TurnContext, query: MessagingExtensionQuery): search_query = str(query.parameters[0].value) response = requests.get(f"http://registry.npmjs.com/-/v1/search", params={"text": search_query}) data = response.json() attachments = [] for obj in data["objects"]: hero_card = HeroCard( title=obj["package"]["name"], tap=CardAction(type="invoke", value=obj["package"]), preview=[CardImage(url=obj["package"]["links"]["npm"])]) attachment = MessagingExtensionAttachment( content_type=CardFactory.content_types.hero_card, content=HeroCard(title=obj["package"]["name"]), preview=CardFactory.hero_card(hero_card)) attachments.append(attachment) return MessagingExtensionResponse( compose_extension=MessagingExtensionResult( type="result", attachment_layout="list", attachments=attachments))
def _create_dummy_search_result_attachment( self) -> MessagingExtensionAttachment: card_text = "https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bots-overview" bf_logo = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQtB3AwMUeNoq4gUBGe6Ocj8kyh3bXa9ZbV7u1fVKQoyKFHdkqU" button = CardAction( type="openUrl", title="Click for more Information", value= "https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bots-overview" ) images = [CardImage(url=bf_logo)] buttons = [button] hero_card = HeroCard(title="Learn more about Teams:", text=card_text, images=images, buttons=buttons) preview = HeroCard(title="Learn more about Teams:", text=card_text, images=images) return MessagingExtensionAttachment( content_type=CardFactory.content_types.hero_card, content=hero_card, preview=CardFactory.hero_card(preview))
def mobile_confirmation_card(): card = ThumbnailCard( title="", text="Please confirm if you want to pay the bill now?", images=[CardImage(url="https://images.app.goo.gl/voWF7ZpTWzJocoUw5")], buttons=[ CardAction( type=ActionTypes.im_back, title="Confirm", text="Confirm", display_text="Confirm", value="Confirm", ), CardAction( type=ActionTypes.im_back, title="Cancel", text="Cancel", display_text="Cancel", value="Cancel", ), ], ) return card
async def _send_help_message(self, turn_context: TurnContext): card = HeroCard( title=f"도움말", text="봇과의 1:1 대화에서 이미지를 전송하면 공유가능한 링크가 반환됩니다.", images=[CardImage(url="https://aka.ms/bf-welcome-card-image")], buttons=[ CardAction( type=ActionTypes.post_back, title="/날씨", text="/날씨", display_text="/날씨", value="/날씨", ), CardAction( type=ActionTypes.post_back, title="/미세먼지", text="/미세먼지", display_text="/미세먼지", value="/미세먼지", ), ], ) return await turn_context.send_activity( MessageFactory.attachment(CardFactory.hero_card(card)))
async def __send_intro_card(self, turn_context: TurnContext): card = HeroCard( title="ADC INTRODUCTION", text="BOT IS THE NEW FUTURE", images=[CardImage(url="https://aka.ms/bf-welcome-card-image")], buttons=[ CardAction( type=ActionTypes.open_url, title="ADC", text="Ask a question", display_text="Ask a question", value="http://cisadc.capgemini.com/", ), CardAction( type=ActionTypes.open_url, title="Bot Catalog", text="Browse to view bot catalog", display_text="Get an overview", value="http://cisadc.capgemini.com/bots_catalog/", ) ], ) return await turn_context.send_activity( MessageFactory.attachment(CardFactory.hero_card(card)))
async def __send_docs_card(self, turn_context: TurnContext): card = HeroCard( title="ADC DOCS!!", text="Click to browse the docs", images=[CardImage(url="https://aka.ms/bf-welcome-card-image")], buttons=[ CardAction( type=ActionTypes.open_url, title="Bot factory share point", text="Browse to explore the sharepoint", display_text="Browse to explore the sharepoint", value= "https://capgemini.sharepoint.com/sites/BOTfactory/Shared%20Documents/Forms/AllItems.aspx?id=%2Fsites%2FBOTfactory%2FShared%20Documents&newTargetListUrl=%2Fsites%2FBOTfactory%2FShared%20Documents&viewpath=%2Fsites%2FBOTfactory%2FShared%20Documents%2FForms%2FAllItems%2Easpx", ), CardAction( type=ActionTypes.open_url, title="Effort Tracker", text="Browse to fill youe daily efforts", display_text="Browse to fill youe daily efforts", value= "https://apps.powerapps.com/play/2ad7c8fa-550e-44c5-af65-d6a29c0bb39e?tenantId=76a2ae5a-9f00-4f6b-95ed-5d33d77c4d61", ), CardAction( type=ActionTypes.open_url, title="Jira", text="Browse to access Jira", display_text="Browse to access Jira", value="http://10.58.144.45/pm/login.jsp", ), ], ) return await turn_context.send_activity( MessageFactory.attachment(CardFactory.hero_card(card)))
def create_receipt_card() -> Attachment: card = ReceiptCard( title="John Doe", facts=[ Fact( key="Order Number", value="1234", ), Fact( key="Payment Method", value="VISA 5555-****", ), ], items=[ ReceiptItem( title="Data Transfer", image=CardImage( url= "https://github.com/amido/azure-vector-icons/raw/master/renders/traffic-manager.png", ), price="$ 38.45", quantity="368", ), ReceiptItem( title="App Service", image=CardImage( url= "https://github.com/amido/azure-vector-icons/raw/master/renders/cloud-service.png", ), price="$ 45.00", quantity="720", ), ], total="$ 90.95", tax="$ 7.50", buttons=[ CardAction( type=ActionTypes.open_url, title="More information", image= "https://account.windowsazure.com/content/6.10.1.38-.8225.160809-1618/aux-pre/" "images/offer-icon-freetrial.png", value="https://azure.microsoft.com/en-us/pricing/", ) ], ) return CardFactory.receipt_card(card)
def create_hero_card() -> Attachment: card = HeroCard(title='', images=[CardImage(url='https://sec.ch9.ms/ch9/7ff5/e07cfef0-aa3b-40bb-9baa-7c9ef8ff7ff5/buildreactionbotframework_960.jpg')], buttons=[CardAction(type=ActionTypes.open_url, title='Get Started', value='https://docs.microsoft.com/en-us/azure/bot-service/')], ) return CardFactory.hero_card(card)
def create_tweet_card(self, tweet): card = ThumbnailCard( title=tweet.user.name, subtitle="@" + tweet.user.screen_name, text=tweet.text, images=[CardImage(url=tweet.user.profile_image_url)]) return CardFactory.thumbnail_card(card)
def create_thumbnail_card() -> Attachment: card = ThumbnailCard(title="BotFramework Thumbnail Card", subtitle="Your bots — wherever your users are talking", text="Build and connect intelligent bots to interact with your users naturally wherever" " they are, from text/sms to Skype, Slack, Office 365 mail and other popular services.", images=[CardImage(url="https://sec.ch9.ms/ch9/7ff5/" "e07cfef0-aa3b-40bb-9baa-7c9ef8ff7ff5/" "buildreactionbotframework_960.jpg")], buttons=[CardAction(type=ActionTypes.open_url, title="Get Started", value="https://docs.microsoft.com/en-us/azure/bot-service/")]) return CardFactory.thumbnail_card(card)
def create_hero_card2_home_3(self) -> Attachment: herocard1 = HeroCard(images=[ CardImage( url= "https://image.shutterstock.com/image-photo/homeless-person-sleep-on-sidewalk-600w-550248562.jpg" ) ], buttons=[ CardAction(title="homeless", type=ActionTypes.im_back, value="homeless") ]) return CardFactory.hero_card(herocard1)
def create_hero_card(self): memes_list = [ 'https://images3.memedroid.com/images/UPLOADED826/5e6ea59356326.jpeg', 'https://i.pinimg.com/originals/8c/04/87/8c04877aad35b1b0dad8376f7899d878.png', 'https://starecat.com/content/wp-content/uploads/im-no-expert-on-covid-19-but-this-is-the-cure-literally-band.jpg', 'https://images3.memedroid.com/images/UPLOADED86/5e2cc3aeec5c0.jpeg', ] card = HeroCard(title="", images=[CardImage(url=random.choice(memes_list))]) return CardFactory.hero_card(card)
def create_hero_card2_love_1(self) -> Attachment: herocard1 = HeroCard(images=[ CardImage( url= "https://image.shutterstock.com/image-photo/divorce-decree-form-ring-600w-570636967.jpg" ) ], buttons=[ CardAction(title="never", type=ActionTypes.im_back, value="never") ]) return CardFactory.hero_card(herocard1)
def create_hero_card2_love_3(self) -> Attachment: herocard1 = HeroCard(images=[ CardImage( url= "https://image.shutterstock.com/image-illustration/empty-white-box-open-doors-600w-1803238906.jpg" ) ], buttons=[ CardAction(title="nothing", type=ActionTypes.im_back, value="nothing") ]) return CardFactory.hero_card(herocard1)
def create_hero_card2_love_2(self) -> Attachment: herocard2 = HeroCard(images=[ CardImage( url= "https://image.shutterstock.com/image-photo/asian-men-drug-addicts-inject-600w-1170996361.jpg" ) ], buttons=[ CardAction(title="distrust", type=ActionTypes.im_back, value="distrust") ]) return CardFactory.hero_card(herocard2)
def create_hero_card2_self_1(self) -> Attachment: herocard1 = HeroCard(images=[ CardImage( url= "https://www.aconsciousrethink.com/wp-content/uploads/2017/10/self-loathing-702x336.jpg" ) ], buttons=[ CardAction(title="loathing", type=ActionTypes.im_back, value="loathing") ]) return CardFactory.hero_card(herocard1)
def create_hero_card2_love_4(self) -> Attachment: herocard1 = HeroCard(images=[ CardImage( url= "https://image.shutterstock.com/image-photo/man-being-rejected-by-his-600w-247296826.jpg" ) ], buttons=[ CardAction(title="rejection", type=ActionTypes.im_back, value="rejection") ]) return CardFactory.hero_card(herocard1)
def create_hero_card2_self_3(self) -> Attachment: herocard1 = HeroCard(images=[ CardImage( url= "https://media2.fdncms.com/tucsonweekly/imager/u/zoom/6031074/5134c2c0_jesse_-_womens_sdcopy.jpg" ) ], buttons=[ CardAction(title="trauma/assault", type=ActionTypes.im_back, value="trauma/assault") ]) return CardFactory.hero_card(herocard1)
def create_hero_card2_self_4(self) -> Attachment: herocard1 = HeroCard(images=[ CardImage( url= "https://image.shutterstock.com/image-photo/man-carries-stack-big-rocks-600w-1362736310.jpg" ) ], buttons=[ CardAction(title="burden", type=ActionTypes.im_back, value="burden") ]) return CardFactory.hero_card(herocard1)
def create_hero_card2_home_1(self) -> Attachment: herocard1 = HeroCard(images=[ CardImage( url= "https://image.shutterstock.com/image-photo/very-emotional-image-bearded-homeless-600w-194969381.jpg" ) ], buttons=[ CardAction(title="torment", type=ActionTypes.im_back, value="torment") ]) return CardFactory.hero_card(herocard1)
def create_hero_card2_home_4(self) -> Attachment: herocard1 = HeroCard(images=[ CardImage( url= "https://image.shutterstock.com/image-photo/sad-handsome-man-thinking-over-600w-1255598947.jpg" ) ], buttons=[ CardAction(title="unsupportive", type=ActionTypes.im_back, value="unsupportive") ]) return CardFactory.hero_card(herocard1)
def create_hero_card2_home_2(self) -> Attachment: herocard2 = HeroCard(images=[ CardImage( url= "https://wp-media.patheos.com/blogs/sites/658/2018/02/Ilchi-Lee_I-dont-care_20180220.jpg" ) ], buttons=[ CardAction(title="dontcare", type=ActionTypes.im_back, value="dontcare") ]) return CardFactory.hero_card(herocard2)