async def __send_intro_card(self, turn_context: TurnContext): return await turn_context.send_activity( MessageFactory.attachment(CardFactory.hero_card(intro_card())))
async def PS_display_options(turn_context: TurnContext, option): """ Create a HeroCard with options for the user to interact with the bot. :param turn_context: :return: """ if option == "[PS]": card = HeroCard( text="Please choose one of the following options", buttons=[ CardAction(type=ActionTypes.im_back, title="1. Products", value="[PRODUCTS]"), CardAction(type=ActionTypes.im_back, title="2. Services", value="[SERVICES]") ], ) reply = MessageFactory.attachment(CardFactory.hero_card(card)) elif option == "[PRODUCTS]": card = HeroCard( text="Please choose one of the following options", buttons=[ CardAction(type=ActionTypes.im_back, title="1. INDIVIDUALS AND FAMILIES PRODUCTS", value="[IAF]"), CardAction(type=ActionTypes.im_back, title="2. INTERNATIONAL PRODUCTS", value="[IP]"), CardAction(type=ActionTypes.im_back, title="3. GROUPS PRODUCTS", value="[GROUPS]"), CardAction(type=ActionTypes.im_back, title="4. SPECIALIZED PRODUCTS", value="[SP]"), CardAction(type=ActionTypes.im_back, title="5. TRAVEL PRODUCTS", value="[TP]") ], ) reply = MessageFactory.attachment(CardFactory.hero_card(card)) elif option == "[IAF]": card = HeroCard( text="Please choose one of the following options", buttons=[ CardAction(type=ActionTypes.im_back, title="1. THE PERPETUAL PLAN ", value="[TPP]"), CardAction(type=ActionTypes.im_back, title="2. THE MUTUAL UPGRADED PLAN", value="[MUP]") ], ) reply = MessageFactory.attachment(CardFactory.hero_card(card)) elif option == "[GROUPS]": card = HeroCard( text="Please choose one of the following options", buttons=[ CardAction(type=ActionTypes.im_back, title="1. THE DELTA NSSF PLAN", value="[DNP]"), CardAction(type=ActionTypes.im_back, title="2. THE THE MEDCARE PLAN", value="[TMP]"), CardAction(type=ActionTypes.im_back, title="3. THE NSSF OPT OUT PLAN", value="[NSOP]") ], ) reply = MessageFactory.attachment(CardFactory.hero_card(card)) elif option == "[SP]": card = HeroCard( text="Please choose one of the following options", buttons=[ CardAction(type=ActionTypes.im_back, title="1. THE PERPETUAL CONVERSION PLAN", value="[TPCP]"), CardAction(type=ActionTypes.im_back, title="2. THE EXPATCARE PLAN", value="[TEP]") ], ) reply = MessageFactory.attachment(CardFactory.hero_card(card)) elif option == "[TPP]": reply = productsDict["[TPP]"] elif option == "[MUP]": reply = productsDict["[MUP]"] elif option == "[IP]": reply = productsDict["[IP]"] elif option == "[TP]": reply = productsDict["[TP]"] elif option == "[DNP]": reply = productsDict["[DNP]"] elif option == "[TMP]": reply = productsDict["[TMP]"] elif option == "[NSOP]": reply = productsDict["[NSOP]"] elif option == "[TPCP]": reply = productsDict["[TPCP]"] elif option == "[TEP]": reply = productsDict["[TEP]"] elif option == "[SERVICES]": card = HeroCard( text="Please choose one of the following options", buttons=[ CardAction(type=ActionTypes.im_back, title="1. INTERNATIONAL HEALTH SERVICES", value="[IHS]"), CardAction(type=ActionTypes.im_back, title="2. HEALTHCARE BENEFITS MANAGEMENT", value="[HBM]"), CardAction(type=ActionTypes.im_back, title="3. PHARMACY BENEFITS MANAGEMENT", value="[PBM]"), CardAction(type=ActionTypes.im_back, title="4. ACTUARIAL", value="[ACTUARIAL]"), CardAction(type=ActionTypes.im_back, title="5. PUMA", value="[PUMA]") ], ) reply = MessageFactory.attachment(CardFactory.hero_card(card)) elif option == "[PUMA]": card = HeroCard( text= '''We value every applicant and we have established a solid strategy where even the applicants with unfavorable health conditions can receive coverage under specific terms. Our models can be used to price substandard risks and our systems can serve to apply coverage conditions at the most detailed level. Together they provide our clients with the capability tO reach all market segments while maintaining profitability.''', buttons=[ CardAction(type=ActionTypes.im_back, title="1. Production Module", value="[PM]"), CardAction(type=ActionTypes.im_back, title="2. Medical Scoring Module", value="[MSM]"), CardAction(type=ActionTypes.im_back, title="3. Deep Dive Module", value="[DDM]"), CardAction(type=ActionTypes.im_back, title="4. Simulator Module", value="[SM]"), CardAction(type=ActionTypes.im_back, title="5. Actuarial Service Module", value="[ASM]") ], ) reply = MessageFactory.attachment(CardFactory.hero_card(card)) elif option == "[IHS]": card = HeroCard( text= '''GlobeMed offers a wide range of services to provide your members access to healthcare around the world. Through GlobeMed Assist, our 24/7 call center, we can ensure that your members get the medical and assistance services needed anytime anywhere.''', buttons=[ CardAction(type=ActionTypes.im_back, title="1. Access and Assistance", value="[AAA]"), CardAction(type=ActionTypes.im_back, title="2. Expert Second Medical Opinion", value="[ESMP]"), CardAction(type=ActionTypes.im_back, title="3. Travel Insurance Programs", value="[TIP]"), CardAction( type=ActionTypes.im_back, title= "4. International Private Medical Insurance Programs (IPMI)", value="[IPMI]") ], ) reply = MessageFactory.attachment(CardFactory.hero_card(card)) elif option == "[AAA]": reply = servicesDict["[AAA]"] elif option == "[ESMP]": reply = servicesDict["[ESMP]"] elif option == "[TIP]": reply = servicesDict["[AAA]"] elif option == "[IPMI]": reply = servicesDict["[IPMI]"] elif option == "[HBM]": reply = servicesDict["[HBM]"] elif option == "[PBM]": reply = servicesDict["[PBM]"] elif option == "[ACTUARIAL]": reply = servicesDict["[ACTUARIAL]"] elif option == "[PM]": reply = servicesDict["[PM]"] elif option == "[MSM]": reply = servicesDict["[MSM]"] elif option == "[SM]": reply = servicesDict["[SM]"] elif option == "[ASM]": reply = servicesDict["[ASM]"] elif option == "[DDM]": reply = servicesDict["[DDM]"] else: reply = "<Under construction>" await turn_context.send_activity(reply)
def _create_adaptive_card_preview( self, user_text: str = None, is_multi_select: bool = False, option1: str = None, option2: str = None, option3: str = None, ) -> Attachment: return CardFactory.adaptive_card({ "actions": [{ "type": "Action.Submit", "title": "Submit", "data": { "submitLocation": "messagingExtensionSubmit" }, }], "body": [ { "text": "Adaptive Card from Task Module", "type": "TextBlock", "weight": "bolder", }, { "text": user_text, "type": "TextBlock", "id": "Question" }, { "id": "Answer", "placeholder": "Answer here...", "type": "Input.Text", }, { "choices": [ { "title": option1, "value": option1 }, { "title": option2, "value": option2 }, { "title": option3, "value": option3 }, ], "id": "Choices", "isMultiSelect": is_multi_select, "style": "expanded", "type": "Input.ChoiceSet", }, ], "type": "AdaptiveCard", "version": "1.0", })
async def send_welcome(self, turn_context: TurnContext): message = MessageFactory.attachment( CardFactory.hero_card( HeroCard(title=welcome_text, images=[CardImage(url=random.choice(welcome_urls))]))) await turn_context.send_activity(message)
def guest_info(): card = adaptive_list.guest_card return CardFactory.adaptive_card(card)
DialogTurnStatus) from model import UserProfile from helpers.dao import UserDAO, PeopleDAO import requests import json CONFIG = DefaultConfig() user_dao = UserDAO(CONFIG) people_dao = PeopleDAO(CONFIG) with open("resources/insertPersonCard.json", 'rb') as f: INSERT_PERSON_CARD = CardFactory.adaptive_card(json.load(f)) class AddPersonDialog(ComponentDialog): def __init__(self, user_profile_accessor: StatePropertyAccessor, logged_users: Dict[str, str]): super().__init__(AddPersonDialog.__name__) self.add_dialog(AttachmentPrompt(AttachmentPrompt.__name__)) self.add_dialog(ChoicePrompt(ChoicePrompt.__name__)) self.add_dialog(TextPrompt(TextPrompt.__name__)) self.add_dialog( WaterfallDialog('AddPersonMainWF', [ self._init_step, self._select_picture, self._select_insert_mode,
async def on_message_activity(self, turn_context: TurnContext): TurnContext.remove_recipient_mention(turn_context.activity) turn_context.activity.text = turn_context.activity.text.strip() await turn_context.send_activities( [Activity(type=ActivityTypes.typing)]) # LUIS request request_query = "{}/apps/{}?staging=true&verbose=true&timezoneOffset=-180&subscription-key={}&q='{}'".format( CONFIG.LUIS_ENDPOINT, CONFIG.LUIS_APP_ID, CONFIG.LUIS_RUNTIME_KEY, turn_context.activity.text.lower()) response = requests.get(request_query).json() print(request_query) print(response.get('topScoringIntent').get('intent')) intent = response.get('topScoringIntent').get('intent') if intent == 'Greeting': await self._greet_back(turn_context) return if intent == 'GetServiceStatus': for entity in response.get('entities'): if entity.get('role') == 'TargetServer': target_server = entity.get('entity').replace(" ", "") if entity.get('role') == 'ServiceName': service_name = entity.get('entity') #if target_server and service_name: if 'target_server' in locals() and 'service_name' in locals(): request_ps_result = request_ps_expression( target_server, f"Get-Service -Name {service_name} | Select Name, DisplayName, Status | ConvertTo-Json -Compress", turn_context.activity.from_property.aad_object_id, turn_context.activity.from_property.name) #ps_result = powershell.invoke("Get-Service {} -ComputerName {}".format(service_name, target_server)) if request_ps_result: await turn_context.send_activity( "O Serviço '{}' ({}) está com status: {}.".format( request_ps_result.get("Name"), request_ps_result.get("DisplayName"), switchers.SERVICE_STATUS_SWITCHER.get( request_ps_result.get("Status")))) else: await turn_context.send_activity( "Não encontrei nada sobre o serviço '{}' no host '{}'." .format(service_name, target_server)) await turn_context.send_activity( "Verifique se os nomes do serviço e host estão corretos." ) else: await turn_context.send_activity( "Entendo que você precisa de informações sobre um serviço do Windows, porém preciso de mais informações." ) await turn_context.send_activity( "Preciso do nome do serviço e nome do servidor.") return if intent == 'GetADUserInfo': target_server = "asl-ad04" ps_command_tail = "-Properties DisplayName | Select Name, SamAccountName, DisplayName, UserPrincipalName, Enabled | ConvertTo-Json -Compress" for entity in response.get('entities'): if entity.get('role') == 'CPF': identity = re.sub(r'\.|-| ', '', entity.get('entity')) ps_command = f"Get-ADUser -Identity {identity} {ps_command_tail}" elif entity.get('role') == 'Email': identity = re.replace(' ', '', entity.get('entity')) ps_command = f"Get-ADUser -Filter {{UserPrincipalName -eq \"{identity}\"}} {ps_command_tail}" if ps_command: request_ps_result = request_ps_expression( target_server, ps_command, turn_context.activity.from_property.aad_object_id, turn_context.activity.from_property.name) if request_ps_result: await turn_context.send_activity( "SamAccountName: {} - Nome: {} - Email: {} - Habilitado: {}" .format( request_ps_result.get("SamAccountName"), request_ps_result.get("DisplayName"), request_ps_result.get("UserPrincipalName"), switchers.ADUSER_ENABLED_SWITCHER.get( request_ps_result.get("Enabled")))) else: await turn_context.send_activity("Não encontrei ninguém :(" ) await turn_context.send_activity( "Verifique se os dados estão corretos. Pode ser que eu seja incompetente também." ) else: await turn_context.send_activity( "Entendo que você gostaria de buscar por uma pessoa no AD, porém não consegui identificar as informações dela." ) await turn_context.send_activity( "Preciso de um CPF, Nome ou E-mail.") return if intent == 'AADConnectSyncResult': await turn_context.send_activity( "Você quer saber o resultado da sincronização do Office 365?") return if turn_context.activity.text.lower() == "michael!": await self._show_members(turn_context) return if turn_context.activity.text == "UpdateCardAction": await self._update_card_activity(turn_context) return if turn_context.activity.text == "Delete": await self._delete_card_activity(turn_context) return card = HeroCard( title="O que você quer?", text="Tenho algumas sugestões...", buttons=[ CardAction( type=ActionTypes.message_back, title="Update Card", text="UpdateCardAction", value={"count": 0}, ) ], ) await turn_context.send_activity( MessageFactory.attachment(CardFactory.hero_card(card))) return
async def __show_menu_card(self, turn_context: TurnContext): return await turn_context.send_activity( MessageFactory.attachment( CardFactory.adaptive_card(INTRO_ADAPTIVE_CARD_CONTENT)))
async def __show_invoice_card(self, turn_context: TurnContext): return await turn_context.send_activity( MessageFactory.attachment( CardFactory.adaptive_card(INVOICE_ADAPTIVE_CARD)))
async def __list_accountTransaction_card(self, turn_context: TurnContext): return await turn_context.send_activity( MessageFactory.attachment( CardFactory.adaptive_card(ADAPTIVE_CARD_CONTENT)))
async def __show_congratulations_card(self, turn_context: TurnContext): return await turn_context.send_activity( MessageFactory.attachment( CardFactory.adaptive_card(CONGRATULATIONS_ADAPTIVE_CARD)))
async def __show_selectAccountForBill_card(self, turn_context: TurnContext): text = turn_context.activity.text return await turn_context.send_activity( MessageFactory.attachment( CardFactory.thumbnail_card(account_SelectionForBill_card())))
async def __login_otp_card_card(self, turn_context: TurnContext): return await turn_context.send_activity( MessageFactory.attachment( CardFactory.adaptive_card(LOGIN_OTP_CARD_CONTENT)))
async def __send_accountbalance_card(self, turn_context: TurnContext): text = turn_context.activity.text return await turn_context.send_activity( MessageFactory.attachment( CardFactory.thumbnail_card(accountbalance_card())))
async def _get_auth_or_search_result( self, turn_context: TurnContext, query: MessagingExtensionQuery, search_query: str, ) -> MessagingExtensionResponse: # When the Bot Service Auth flow completes, the action.State will contain # a magic code used for verification. magic_code = "" if query.state is not None: magic_code = query.state token_response = await turn_context.adapter.get_user_token( turn_context, self.connection_name, magic_code) if token_response is None or token_response.token is None: # There is no token, so the user has not signed in yet. # Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions sign_in_link = await turn_context.adapter.get_oauth_sign_in_link( turn_context, self.connection_name) return MessagingExtensionResponse( compose_extension=MessagingExtensionResult( type="auth", suggested_actions=MessagingExtensionSuggestedAction( actions=[ CardAction( type="openUrl", value=sign_in_link, title="Bot Service OAuth", ) ]), )) # User is signed in, so use their token to search email via the Graph Client client = SimpleGraphClient(token_response.token) search_results = await client.search_mail_inbox(search_query) # Here we construct a ThumbnailCard for every attachment, and provide a HeroCard which will be # displayed if the user selects that item. attachments = [] for message_meta in search_results: message = message_meta["_source"] message_from = message["from"] if "from" in message else None if message_from: subtitle = (f"{message_from['emailAddress']['name']}," f"<{message_from['emailAddress']['address']}>") else: subtitle = "" hero_card = HeroCard( title=message["subject"] if "subject" in message else "", subtitle=subtitle, text=message["bodyPreview"] if "bodyPreview" in message else "", ) thumbnail_card = CardFactory.thumbnail_card( ThumbnailCard( title=subtitle, subtitle=message["subject"], images=[ CardImage( url= "https://botframeworksamples.blob.core.windows.net/samples" "/OutlookLogo.jpg", alt="Outlook Logo", ) ], )) attachment = MessagingExtensionAttachment( content_type=CardFactory.content_types.hero_card, content=hero_card, preview=thumbnail_card, ) attachments.append(attachment) return MessagingExtensionResponse( compose_extension=MessagingExtensionResult( type="result", attachment_layout="list", attachments=attachments))
async def __mobile_confirmation_card(self, turn_context: TurnContext): text = turn_context.activity.text return await turn_context.send_activity( MessageFactory.attachment( CardFactory.thumbnail_card(mobile_confirmation_card())))
async def on_message_activity(self, turn_context: TurnContext): turn_context.activity.address = '' ## DB insert old user id_res = self.db_func.DB_query('SELECT ID FROM user_info') user_id = turn_context.activity.recipient.id # if userid not in our db, add it if user_id not in id_res: insert_query = 'INSERT INTO user_info (ID, counter) VALUES (\'' + user_id + '\', 0);' self.db_func.DB_insert(insert_query) self.db_func.DB_commit() ## QnA Maker's response response = await self.qna_maker.get_answers(turn_context) # check if user typing in qna maker if response and len(response) > 0 and (turn_context.activity.text != response[0].answer): await turn_context.send_activity( MessageFactory.text(response[0].answer)) # 個人化推薦 elif turn_context.activity.text == '個人化推薦': todayrecom = todaytop3eat() await turn_context.send_activity("今天最低溫為 %s, 為您推薦以下料理:" % todayrecom[0]) todaylist = [] for tt in range(3): restaurants_dict = googlemaps_API("北車", 3, todayrecom[1][tt]) todaylist.append( restaurants_list.append( CardFactory.hero_card( HeroCard( title=restaurants_dict[0]['name'], text='推薦指數 : ' + str(restaurants_dict[0]['rating']), images=[ CardImage( url=show_photo(restaurants_dict[0] ['photo_reference'])) ], buttons=[ CardAction( type="openUrl", title="地圖", value= "https://www.google.com/maps/search/?api=1&query=" + str(restaurants_dict[0]['location_x']) + "," + str(restaurants_dict[0]['location_y']) + "&query_place_id=" + str(restaurants_dict[0]['place_id'])), CardAction( type="imBack", title="點此看評論", value=restaurants_dict[0]['name'] + "_評論"), CardAction( type="imBack", title="加入我的最愛", value=restaurants_dict[0]['name'] + "_加入最愛") ])))) msg = MessageFactory.carousel(today_list) await turn_context.send_activity(msg) elif "加入最愛" in turn_context.activity.text: ## add favorite button rest_name = turn_context.activity.text.split("_")[0] message = self.favor.add_favorite(user_id, rest_name) await turn_context.send_activity(message) elif turn_context.activity.text == '瀏覽紀錄': res = self.history.get_history(user_id) if (res == []): await turn_context.send_activity("還沒有瀏覽紀錄,趕快搜尋餐廳吧~GOGO") else: history_list = [] for length in range(len(res)): rest_name = res[length] rest_location = find_position_with_xy(rest_name) (x, y) = googlemaps_search_location(rest_name) history_list.append( CardFactory.hero_card( HeroCard( title=rest_name, subtitle=rest_location, buttons=[ CardAction( type="openUrl", title="地圖", value= "https://www.google.com/maps/search/?api=1&query=" + str(x) + ',' + str(y)) ]))) message = MessageFactory.carousel(history_list) await turn_context.send_activity(message) elif turn_context.activity.text == '我的最愛': res = self.favor.get_favorite(user_id) if (res == []): await turn_context.send_activity("還沒有最愛的餐廳,趕快搜尋餐廳並加入最愛吧~GOGO") else: fav_list = [] for length in range(len(res)): rest_name = res[length] rest_location = find_position_with_xy(rest_name) (x, y) = googlemaps_search_location(rest_name) fav_list.append( CardFactory.hero_card( HeroCard( title=rest_name, subtitle=rest_location, buttons=[ CardAction( type="openUrl", title="地圖", value= "https://www.google.com/maps/search/?api=1&query=" + str(x) + ',' + str(y)) ]))) message = MessageFactory.carousel(fav_list) await turn_context.send_activity(message) elif "加入最愛" in turn_context.activity.text: ## add favorite button rest_name = turn_context.activity.text.split("_")[0] message = self.favor.add_favorite(user_id, rest_name) await turn_context.send_activity(message) # 歷史紀錄 elif turn_context.activity.text == '瀏覽紀錄': res = self.history.get_history(user_id) print(user_id) if (res is None): await turn_context.send_activity("還沒有瀏覽紀錄,趕快搜尋餐廳吧~") else: history_list = [] for length in range(len(res)): rest_name = res[length] rest_location = find_position_with_xy(rest_name) history_list.append( CardFactory.hero_card( HeroCard(title=rest_name, subtitle=rest_location))) message = MessageFactory.carousel(history_list) await turn_context.send_activity(message) # IG elif "_IG" in turn_context.activity.text: hashtag = turn_context.activity.text.split("_")[0].split( ' ')[0].split('-')[0].split('/')[0].split("'")[0].split('&')[0] url = 'https://www.instagram.com/explore/tags/' + hashtag await turn_context.send_activity("稍等一下唷! 美食公道伯正在幫你尋找餐廳的IG熱門貼文...") message = MessageFactory.carousel([ CardFactory.hero_card( HeroCard( title=hashtag + '的IG熱門文章', images=[ CardImage( url= 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQB1DfQKJ-vfC16ybbNPP0N7FVVV6bNEC3W9Q&usqp=CAU' ) ], buttons=[ CardAction(type="openUrl", title="前往IG熱門文章", value=url) ])) ]) await turn_context.send_activity(message) # 找評論 elif "評論" in turn_context.activity.text: await turn_context.send_activity("稍等一下唷! 美食公道伯正在幫你尋找餐廳評論...") # 展宏的func re = webcrawl(turn_context.activity.text) # 佑誠的func blog_re = [] blog_re = blogcrawler(turn_context.activity.text) review_list = [] for index in range(len(blog_re)): review_list.append( CardFactory.hero_card( HeroCard(title=blog_re[index][1], images=[CardImage(url=blog_re[index][3])], buttons=[ CardAction(type="openUrl", title="前往網頁", value=blog_re[index][2]) ]))) if re: review_list.append( CardFactory.hero_card( HeroCard(title=re["愛食記"][0], images=[CardImage(url=re["愛食記"][2])], buttons=[ CardAction(type="openUrl", title="前往網頁", value=re["愛食記"][1]) ]))) if len(review_list) != 0: message = MessageFactory.carousel(review_list) else: message = "未查詢到這間餐廳的相關評論文章喔~ 歡迎您發布首則評論!" rest_name = turn_context.activity.text.split("_")[0] self.history.add_history(user_id, rest_name) message = MessageFactory.carousel(review_list) await turn_context.send_activity(message) # 書文的func # line address elif ("{" in turn_context.activity.text and "}" in turn_context.activity.text): line_address_json = json.loads(turn_context.activity.text) print('line_address_json', line_address_json) x = line_address_json['latitude'] y = line_address_json['longitude'] restaurants_dict = googlemaps_search_nearby(x, y, 'steak') # 沒有餐廳的狀況 if (len(restaurants_dict) == 0): message = "您附近沒有相對應的餐廳可以推薦呦,輸入『吃』來繼續👀" else: restaurants_list = [] for i in range(len(restaurants_dict)): restaurants_list.append( CardFactory.hero_card( HeroCard( title=restaurants_dict[i]['name'], text='推薦指數 : ' + str(restaurants_dict[i]['rating']) + "👍", images=[ CardImage( url=show_photo(restaurants_dict[i] ['photo_reference'])) ], buttons=[ CardAction( type="openUrl", title="地圖", value= "https://www.google.com/maps/search/?api=1&query=" + str(restaurants_dict[i]['location_x']) + "," + str(restaurants_dict[i]['location_y']) + "&query_place_id=" + str(restaurants_dict[i]['place_id'])), CardAction( type="imBack", title="點此看評論", value=restaurants_dict[i]['name'] + "_評論"), CardAction( type="imBack", title="加入我的最愛", value=restaurants_dict[i]['name'] + "_加入最愛") ]))) if (i == 10): break message = MessageFactory.carousel(restaurants_list) await turn_context.send_activity(message) else: ## LUIS's result & intent recognizer_result = await self.recognizer.recognize(turn_context) # parse intent and entity intent = LuisRecognizer.top_intent(recognizer_result) print(intent) ## get user input and make response luis_result = recognizer_result.properties["luisResult"] entity = '' if luis_result.entities: entities_list = [] for ll in luis_result.entities: print(turn_context.activity.text) print(ll) ll.entity = ll.entity.replace(" ", '') entities_list.append(ll.entity) print(entities_list) print(len(entities_list)) if len(entities_list) == 1: entity = entities_list[0] # two entites situation else: entity = entities_list[0] + '^' + entities_list[1] print("double entity:", entity) entity = entity.replace("\x08", '') if entity == '': message = MessageFactory.carousel([ CardFactory.hero_card( HeroCard(title="無法了解您的需求,美食公道伯在這邊先推薦幾家給您😉", subtitle='請選擇您想吃的類型: 😗', buttons=[ CardAction(type="imBack", title="咖啡廳", value="我想吃咖啡廳"), CardAction(type="imBack", title="牛排", value="我想吃牛排"), CardAction(type="imBack", title="火鍋", value="我想吃火鍋") ])) ]) await turn_context.send_activity(message) print('entity:', entity) elif intent == "使用者食物類別" and "_$" not in turn_context.activity.text and "_IG" not in turn_context.activity.text: message = MessageFactory.carousel([ CardFactory.hero_card( HeroCard( title='您想吃的食物為:' + str(entity), subtitle='請選擇您的預算區間: 🤑', buttons=[ CardAction(type="imBack", title="$$$", value="我想吃" + str(entity) + "_$$$"), CardAction(type="imBack", title="$$", value="我想吃" + str(entity) + "_$$"), CardAction(type="imBack", title="$", value="我想吃" + str(entity) + "_$") ])) ]) await turn_context.send_activity(message) # msg = '請輸入您目前的地點或是附近的景點 🧐(例如:北車、公館)(小提示:點擊Line的+號可以傳地址上來呦!)' # await turn_context.send_activity(msg) elif intent == "使用者地理位置" and "_$" not in turn_context.activity.text and "_IG" not in turn_context.activity.text: message = MessageFactory.carousel([ CardFactory.hero_card( HeroCard( title='您的所在位置為:' + str(entity), subtitle='請選擇您的預算區間: 🤑', buttons=[ CardAction(type="imBack", title="$$$", value="我在" + str(entity) + "_$$$"), CardAction(type="imBack", title="$$", value="我在" + str(entity) + "_$$"), CardAction(type="imBack", title="$", value="我在" + str(entity) + "_$") ])) ]) await turn_context.send_activity(message) # find 2 entites in sequence elif "^" in entity: entity = entity.split("^") food = entity[0] location = entity[1] restaurants_dict = googlemaps_API(location, 2, food) # 沒有餐廳的狀況 if (len(restaurants_dict) == 0): message = "您附近沒有相對應的餐廳可以推薦呦,輸入『我想吃...』來繼續👀" else: restaurants_list = [] for i in range(len(restaurants_dict)): restaurants_list.append( CardFactory.hero_card( HeroCard( title=restaurants_dict[i]['name'], text='推薦指數 : ' + str(restaurants_dict[i]['rating']) + "👍", images=[ CardImage(url=show_photo( restaurants_dict[i] ['photo_reference'])) ], buttons=[ CardAction( type="openUrl", title="地圖", value= "https://www.google.com/maps/search/?api=1&query=" + str(restaurants_dict[i] ['location_x']) + "," + str(restaurants_dict[i] ['location_y']) + "&query_place_id=" + str(restaurants_dict[i] ['place_id'])), CardAction( type="imBack", title="點此看評論", value=restaurants_dict[i]['name'] + "_評論"), CardAction( type="imBack", title="加入我的最愛", value=restaurants_dict[i]['name'] + "_加入最愛") ]))) if (i == 10): break message = MessageFactory.carousel(restaurants_list) await turn_context.send_activity(message) elif ('_$' in turn_context.activity.text): money_status = 1 msg = turn_context.activity.text # 判斷price_level if ('_$$' in turn_context.activity.text): money_status = 2 msg = msg.replace('_$$', '') elif ('_$$$' in turn_context.activity.text): money_status = 3 msg = msg.replace('_$$$', '') msg = msg.replace('_$', '') msg = msg.replace('_', '') msg = msg.replace('我想吃', '') msg = msg.replace('我想喝', '') msg = msg.replace('我要吃', '') msg = msg.replace('我要喝', '') msg = msg.replace('我在', '') if (intent == '使用者食物類別'): restaurants_dict = googlemaps_API("北車", money_status, msg) print(restaurants_dict) if (intent == '使用者地理位置'): restaurants_dict = googlemaps_API(msg, money_status, '') print(restaurants_dict) print('money_status:', money_status) print('msg:', msg) # 沒有餐廳的狀況 if not restaurants_dict: message = "您附近沒有相對應的餐廳可以推薦呦,輸入『我想吃...』來繼續👀" await turn_context.send_activity(message) else: # good_list = opendata_earth.get_earth_data() # vegetable_list = opendata_vegetable.get_vege_data() restaurants_list = [] for i in range(len(restaurants_dict)): restaurants_list.append( CardFactory.hero_card( HeroCard( title=restaurants_dict[i]['name'], text='推薦指數 : ' + str(restaurants_dict[i]['rating']) + " 👍", images=[ CardImage(url=show_photo( restaurants_dict[i] ['photo_reference'])) ], buttons=[ CardAction( type="openUrl", title="地圖", value= "https://www.google.com/maps/search/?api=1&query=" + str(restaurants_dict[i] ['location_x']) + "," + str(restaurants_dict[i] ['location_y']) + "&query_place_id=" + str(restaurants_dict[i] ['place_id'])), CardAction( type="imBack", title="點此看IG熱門貼文", value=restaurants_dict[i]['name'] + "_IG"), CardAction( type="imBack", title="點此看評論", value=restaurants_dict[i]['name'] + "_評論"), CardAction( type="imBack", title="加入我的最愛", value=restaurants_dict[i]['name'] + "_加入最愛") ]))) if (i == 10): break message = MessageFactory.carousel(restaurants_list) await turn_context.send_activity(message) elif turn_context.activity.address != '': turn_context.send_activity(turn_context.activity.address) # non-type else: message = '不好意思,我聽不太明白,請說的具體一點' await turn_context.send_activity(message)
async def send_message(tc2: TurnContext): return await tc2.send_activity( MessageFactory.attachment(CardFactory.hero_card(card))) # pylint: disable=cell-var-from-loop
def create_animation_card() -> Attachment: card = AnimationCard( media=[MediaUrl(url='http://i.giphy.com/Ki55RUbOV5njy.gif')], title='Microsoft Bot Framework', subtitle='Animation Card') return CardFactory.animation_card(card)
async def _send_oauth_card( self, context: TurnContext, prompt: Union[Activity, str] = None ): if not isinstance(prompt, Activity): prompt = MessageFactory.text(prompt or "", None, InputHints.accepting_input) else: prompt.input_hint = prompt.input_hint or InputHints.accepting_input prompt.attachments = prompt.attachments or [] if OAuthPrompt._channel_suppports_oauth_card(context.activity.channel_id): if not any( att.content_type == CardFactory.content_types.oauth_card for att in prompt.attachments ): adapter: ExtendedUserTokenProvider = context.adapter card_action_type = ActionTypes.signin sign_in_resource: SignInUrlResponse = await adapter.get_sign_in_resource_from_user_and_credentials( context, self._settings.oath_app_credentials, self._settings.connection_name, context.activity.from_property.id, ) link = sign_in_resource.sign_in_link bot_identity: ClaimsIdentity = context.turn_state.get( BotAdapter.BOT_IDENTITY_KEY ) # use the SignInLink when in speech channel or bot is a skill or # an extra OAuthAppCredentials is being passed in if ( ( bot_identity and SkillValidation.is_skill_claim(bot_identity.claims) ) or not context.activity.service_url.startswith("http") or self._settings.oath_app_credentials ): if context.activity.channel_id == Channels.emulator: card_action_type = ActionTypes.open_url else: link = None json_token_ex_resource = ( sign_in_resource.token_exchange_resource.as_dict() if sign_in_resource.token_exchange_resource else None ) prompt.attachments.append( CardFactory.oauth_card( OAuthCard( text=self._settings.text, connection_name=self._settings.connection_name, buttons=[ CardAction( title=self._settings.title, text=self._settings.text, type=card_action_type, value=link, ) ], token_exchange_resource=json_token_ex_resource, ) ) ) else: if not any( att.content_type == CardFactory.content_types.signin_card for att in prompt.attachments ): if not hasattr(context.adapter, "get_oauth_sign_in_link"): raise Exception( "OAuthPrompt._send_oauth_card(): get_oauth_sign_in_link() not supported by the current adapter" ) link = await context.adapter.get_oauth_sign_in_link( context, self._settings.connection_name, None, self._settings.oath_app_credentials, ) prompt.attachments.append( CardFactory.signin_card( SigninCard( text=self._settings.text, buttons=[ CardAction( title=self._settings.title, value=link, type=ActionTypes.signin, ) ], ) ) ) # Send prompt await context.send_activity(prompt)
def create_adaptive_card(self) -> Attachment: return CardFactory.adaptive_card(ADAPTIVE_CARD_CONTENT)
async def _send_oauth_card(self, context: TurnContext, prompt: Union[Activity, str] = None): if not isinstance(prompt, Activity): prompt = MessageFactory.text(prompt or "", None, InputHints.accepting_input) else: prompt.input_hint = prompt.input_hint or InputHints.accepting_input prompt.attachments = prompt.attachments or [] if OAuthPrompt._channel_suppports_oauth_card( context.activity.channel_id): if not any(att.content_type == CardFactory.content_types.oauth_card for att in prompt.attachments): link = None card_action_type = ActionTypes.signin bot_identity: ClaimsIdentity = context.turn_state.get( "BotIdentity") # check if it's from streaming connection if not context.activity.service_url.startswith("http"): if not hasattr(context.adapter, "get_oauth_sign_in_link"): raise Exception( "OAuthPrompt: get_oauth_sign_in_link() not supported by the current adapter" ) link = await context.adapter.get_oauth_sign_in_link( context, self._settings.connection_name) elif bot_identity and SkillValidation.is_skill_claim( bot_identity.claims): link = await context.adapter.get_oauth_sign_in_link( context, self._settings.connection_name) card_action_type = ActionTypes.open_url prompt.attachments.append( CardFactory.oauth_card( OAuthCard( text=self._settings.text, connection_name=self._settings.connection_name, buttons=[ CardAction( title=self._settings.title, text=self._settings.text, type=card_action_type, value=link, ) ], ))) else: if not any( att.content_type == CardFactory.content_types.signin_card for att in prompt.attachments): if not hasattr(context.adapter, "get_oauth_sign_in_link"): raise Exception( "OAuthPrompt.send_oauth_card(): get_oauth_sign_in_link() not supported by the current adapter" ) link = await context.adapter.get_oauth_sign_in_link( context, self._settings.connection_name) prompt.attachments.append( CardFactory.signin_card( SigninCard( text=self._settings.text, buttons=[ CardAction( title=self._settings.title, value=link, type=ActionTypes.signin, ) ], ))) # Send prompt await context.send_activity(prompt)
def book_room(): #Return room booking form card = adaptive_list.room_card return CardFactory.adaptive_card(card)
async def __send_about_card(self, turn_context: TurnContext): ADAPTIVE_CARD_CONTENT = { "type": "AdaptiveCard", "body": [{ "type": "TextBlock", "size": "Medium", "weight": "Bolder", "text": "About Patient", "wrap": True }, { "type": "ColumnSet", "columns": [{ "type": "Column", "items": [{ "type": "Image", "style": "Person", "url": "https://icon-library.com/images/blank-person-icon/blank-person-icon-27.jpg", "size": "Small" }], "width": "auto" }, { "type": "Column", "items": [{ "type": "TextBlock", "weight": "Bolder", "text": (f"{trak_name}"), "wrap": True }, { "type": "TextBlock", "spacing": "None", "text": (f"Last Updated : {trak_lastUpdated}"), "isSubtle": True, "wrap": True }], "width": "stretch" }] }, { "type": "FactSet", "facts": [{ "title": "Record Number", "value": (f"{trak_recordNumber}") }, { "title": "DOB", "value": (f"{trak_dob}") }, { "title": "Sex", "value": (f"{trak_gender}") }, { "title": "Care Provider", "value": (f"{trak_careProvider}") }], "separator": True }], "actions": [{ "type": "Action.OpenUrl", "title": "Go to trakcare", "url": (f"{trak_url}") }, { "type": "Action.ShowCard", "title": "Show Allergies", "card": { "type": "AdaptiveCard", "body": [{ "type": "TextBlock", "size": "Medium", "weight": "Bolder", "text": (f"Following data is available for {trak_name} : "), "wrap": True }, { "type": "TextBlock", "text": (f"{allergy_data}"), "wrap": True }], "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "version": "1.0" } }, { "type": "Action.OpenUrl", "title": "Observations", "url": (f"{ob_url}") }], "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "version": "1.0" } return await turn_context.send_activity( MessageFactory.attachment( CardFactory.adaptive_card(ADAPTIVE_CARD_CONTENT)))
def __handle_message_activity(self, activity): #Main logic to handle each reply self.send_response(200) self.end_headers() credentials = MicrosoftAppCredentials(APP_ID, APP_PASSWORD) connector = ConnectorClient(credentials, base_url=activity.service_url) if Bot.init: #Initial customization Bot.Name = activity.text locs = Bot.show_location() st = wlc + Bot.Name + " to chat with me. \nPlease choose which city you prefer." reply = Bot.__create_reply_activity(activity, st, locs) connector.conversations.send_to_conversation( reply.conversation.id, reply) Bot.init = False else: if not Bot.menu_opt: # If it is not hotel menu if not Bot.sub: #If it is not a sub-hotel menu (sub-hotel menu meaning - it is not clicked from the list of many hotels in a single city) Bot.city = activity.text hotel = Hotels.data().get(Bot.city) if len( hotel.keys() ) == 1: # If there is only one hotel in the city, directly display the pics and info Bot.hotel_name = list(hotel.keys())[0] ht = list(hotel.values())[0] info = ht['info'] img = ht['img'] card = Bot.hotel_card(info, img) Bot.property_code = ht['PropertyCode'] reply = Bot.__create_reply_activity(activity, '', card) connector.conversations.send_to_conversation( reply.conversation.id, reply) time.sleep(1) menu = Bot.menu_card(hotel.get(Bot.hotel_name)) reply = Bot.__create_reply_activity(activity, '', menu) connector.conversations.send_to_conversation( reply.conversation.id, reply) Bot.menu_opt = True else: #If there are more than one hotel in a city, show the hotels list and set Bot.sub as True htlst = SigninCard( text="Choose a hotel in {}".format(Bot.city), buttons=[ CardAction(type=ActionTypes.im_back, title=i, value=i) for i in hotel.keys() ]) card = CardFactory.signin_card(htlst) reply = Bot.__create_reply_activity(activity, '', card) connector.conversations.send_to_conversation( reply.conversation.id, reply) Bot.sub = True else: # For choosing one hotel from multiple hotels in single city, i.e it is a sub-hotel menu Bot.hotel_name = activity.text hotel = Hotels.data().get(Bot.city).get(Bot.hotel_name) info = hotel.get('info') img = hotel.get('img') card = Bot.hotel_card(info, img) Bot.property_code = hotel['PropertyCode'] reply = Bot.__create_reply_activity(activity, '', card) connector.conversations.send_to_conversation( reply.conversation.id, reply) time.sleep(1) menu = Bot.menu_card(hotel) reply = Bot.__create_reply_activity(activity, '', menu) connector.conversations.send_to_conversation( reply.conversation.id, reply) Bot.menu_opt = True else: #For rest of the inputs value = activity.text defmsg = "I am Sorry " + Bot.Name + ", Kindly share your e-mail id. I will revert at the earliest." if value == "Book_Package": msg = Bot.Name + ", Your details have been submitted successfully. We will call you back shortly. Thanks for contacting us." reply = Bot.__create_reply_activity(activity, msg, menu) connector.conversations.send_to_conversation( reply.conversation.id, reply) hotel = Hotels.data().get(Bot.city).get(Bot.hotel_name) menu = Bot.menu_card(hotel) #Display main menu reply = Bot.__create_reply_activity( activity, 'Is there anything else I can help you with?', menu) connector.conversations.send_to_conversation( reply.conversation.id, reply) Bot.menu_opt = True if Bot.query == True: #If faq is clicked out = Bot.faq(value) reply = Bot.__create_reply_activity(activity, out) connector.conversations.send_to_conversation( reply.conversation.id, reply) Bot.query = False hotel = Hotels.data().get(Bot.city).get(Bot.hotel_name) menu = Bot.menu_card(hotel) reply = Bot.__create_reply_activity( activity, 'Is there anything else I can help you with?', menu) connector.conversations.send_to_conversation( reply.conversation.id, reply) Bot.menu_opt = True else: if value == 'Book a Room': Bot.reset_flags() Bot.flag_dict['book'] = True card = Bot.book_room() #show booking form reply = Bot.__create_reply_activity(activity, '', card) connector.conversations.send_to_conversation( reply.conversation.id, reply) elif value == "Dining" or value == "Wine & Dine": Bot.reset_flags() Bot.flag_dict['dine'] = True images = Hotels.data().get(Bot.city).get( Bot.hotel_name).get('img') card = Bot.guest_info() reply = Bot.__create_reply_activity(activity, '', card) connector.conversations.send_to_conversation( reply.conversation.id, reply) elif value == "Plan an Event": Bot.reset_flags() Bot.flag_dict['event'] = True images = Hotels.data().get(Bot.city).get( Bot.hotel_name).get('img') card = Bot.guest_info() reply = Bot.__create_reply_activity(activity, '', card) connector.conversations.send_to_conversation( reply.conversation.id, reply) elif value == "Book a Package": Bot.reset_flags() Bot.flag_dict['package'] = True card = Bot.guest_info() reply = Bot.__create_reply_activity(activity, '', card) connector.conversations.send_to_conversation( reply.conversation.id, reply) elif value == "Have any Questions?": Bot.query = True reply = Bot.__create_reply_activity( activity, 'Hey ' + Bot.Name + ',Type your question and I will try my best to answer for you..' ) connector.conversations.send_to_conversation( reply.conversation.id, reply) elif value == "Main Menu": locs = Bot.choose_hotel() reply = Bot.__create_reply_activity( activity, 'Choose a city', locs) connector.conversations.send_to_conversation( reply.conversation.id, reply) else: if value == None: #For all submit buttons, value is returned as None. So using that to differentiate inputs obtained through various submit buttons success = "Your details have been submitted successfully " + Bot.Name + ". You will soon be contacted back" if Bot.flag_dict.get( 'book' ): #Open resavenue booking page in browser data = activity.value indate = data['indate'] outdate = data['outdate'] #indate = indt[3:6]+indt[0:3]+indt[6:] #outdate = otdt[3:6]+otdt[0:3]+otdt[6:] url = "http://www.resavenue.com/bookingNew/servlet/checkAvailable.resBookings?regCode={}&arr_date={}&dep_date={}&roomNo={}&adult_1={}&child_1={}&targetTemplate=3".format( Bot.property_code, indate, outdate, data['rooms'], data['adults'], data['child']) print(url) webbrowser.open_new(url) reply = Bot.__create_reply_activity( activity, 'You will now be redirected to the booking page' ) connector.conversations.send_to_conversation( reply.conversation.id, reply) if Bot.flag_dict.get('event'): reply = Bot.__create_reply_activity( activity, success) connector.conversations.send_to_conversation( reply.conversation.id, reply) if Bot.flag_dict.get('dine'): reply = Bot.__create_reply_activity( activity, success) connector.conversations.send_to_conversation( reply.conversation.id, reply) if Bot.flag_dict.get('package'): reply = Bot.__create_reply_activity( activity, success) connector.conversations.send_to_conversation( reply.conversation.id, reply) Bot.reset_flags() else: reply = Bot.__create_reply_activity( activity, defmsg) connector.conversations.send_to_conversation( reply.conversation.id, reply) hotel = Hotels.data().get(Bot.city).get(Bot.hotel_name) menu = Bot.menu_card(hotel) reply = Bot.__create_reply_activity( activity, 'Is there anything else I can help you with?', menu) connector.conversations.send_to_conversation( reply.conversation.id, reply) Bot.menu_opt = True
async def __send_intro_card(self, turn_context: TurnContext): ADAPTIVE_CARD_CONTENT = { "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.0", "body": [{ "type": "ColumnSet", "columns": [{ "type": "Column", "width": "auto", "items": [{ "type": "TextBlock", "text": "Intersystems Bot", "weight": "Bolder", "size": "ExtraLarge", "spacing": "None", "wrap": True }, { "type": "TextBlock", "text": (f"Hi {gname}, I am InterSystems bot."), "size": "Medium", "wrap": True, "maxLines": 3 }, { "type": "TextBlock", "text": "Write \"Patient\" followed by patient ID or \"mrn\" followed by Medical Record Number to get details about patient", "wrap": True, "size": "Medium" }], "style": "default" }, { "type": "Column", "width": 1, "items": [{ "type": "Image", "url": "https://media-exp1.licdn.com/dms/image/C560BAQG6u8nOkqxK2w/company-logo_200_200/0?e=2159024400&v=beta&t=7DvyiaL7v0xYIzQtl0kDZCjGs_e-MA7h5xC5Rg5xtaI", "horizontalAlignment": "Center", "spacing": "Small" }] }] }], "actions": [{ "type": "Action.OpenUrl", "title": "More Info", "url": "https://usconfluence.iscinternal.com/display/AU101/TEAMS%3A+Technical+Discovery" }] } return await turn_context.send_activity( MessageFactory.attachment( CardFactory.adaptive_card(ADAPTIVE_CARD_CONTENT)))
def _create_adaptive_card_editor( self, user_text: str = None, is_multi_select: bool = False, option1: str = None, option2: str = None, option3: str = None, ) -> Attachment: return CardFactory.adaptive_card({ "actions": [{ "data": { "submitLocation": "messagingExtensionFetchTask" }, "title": "Submit", "type": "Action.Submit", }], "body": [ { "text": "This is an Adaptive Card within a Task Module", "type": "TextBlock", "weight": "bolder", }, { "type": "TextBlock", "text": "Enter text for Question:" }, { "id": "Question", "placeholder": "Question text here", "type": "Input.Text", "value": user_text, }, { "type": "TextBlock", "text": "Options for Question:" }, { "type": "TextBlock", "text": "Is Multi-Select:" }, { "choices": [ { "title": "True", "value": "true" }, { "title": "False", "value": "false" }, ], "id": "MultiSelect", "isMultiSelect": "false", "style": "expanded", "type": "Input.ChoiceSet", "value": "true" if is_multi_select else "false", }, { "id": "Option1", "placeholder": "Option 1 here", "type": "Input.Text", "value": option1, }, { "id": "Option2", "placeholder": "Option 2 here", "type": "Input.Text", "value": option2, }, { "id": "Option3", "placeholder": "Option 3 here", "type": "Input.Text", "value": option3, }, ], "type": "AdaptiveCard", "version": "1.0", })
async def __send_oauth_card(self, turn_context: TurnContext): ADAPTIVE_CARD_CONTENT = { "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.0", "body": [{ "type": "ColumnSet", "columns": [{ "type": "Column", "width": 2, "items": [{ "type": "TextBlock", "text": "FHIR Login Wizard", "weight": "Bolder", "size": "Medium", "wrap": True }, { "type": "TextBlock", "text": "Click the button below to open a login window", "isSubtle": True, "wrap": True }, { "type": "Container", "items": [{ "type": "ActionSet", "actions": [{ "type": "Action.OpenUrl", "title": "Login", "url": (f"{OAuth_url}") }] }, { "type": "TextBlock", "text": "Enter the Authorization code below and press submit", "wrap": True }, { "type": "Input.Text", "id": "SimpleVal", "placeholder": "Enter Authorization Code Here" }] }] }] }], "actions": [{ "type": "Action.Submit", "title": "Submit Authorization Code", "data": { "msteams": { "type": "messageBack", "text": "This goes to the bot", "value": "{\"bfKey\": \"bfVal\", \"conflictKey\": \"from value\"}" } } }, { "type": "Action.ShowCard", "title": "Show steps to get the Authorization Code", "card": { "type": "AdaptiveCard", "body": [{ "type": "TextBlock", "text": "Steps to get the authorization code", "wrap": True, "horizontalAlignment": "Center", "size": "Medium", "weight": "Bolder" }, { "type": "TextBlock", "text": "1. Click on the login button and submit your credentials.\n2. Click \"Allow Access\" to authorize the access.\n3. Copy the authorization code from the url and paste in the input field given on card.\n4. Click \"Submit Authorization Code\" button", "wrap": True }], "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "version": "1.0" }, }] } return await turn_context.send_activity( MessageFactory.attachment( CardFactory.adaptive_card(ADAPTIVE_CARD_CONTENT)))
def __create_adaptive_card_attachment() -> Attachment: card_path = os.path.join(os.getcwd(), "resources/adaptiveCard.json") with open(card_path, "rb") as in_file: card_data = json.load(in_file) return CardFactory.adaptive_card(card_data)
def create_adaptive_card_attachment(self): title = "Ciao sono BotTipBooks" subtitle = "Ecco cosa posso fare per te..." text = '''Sono un bot dotato di intelligenza artificiale che ti permette di:\n\n- Ricercare libri e mostrarti i prezzi migliori sul mercato.\n- Creare una wishlist dove poter inserire tutti i libri che ti interessano.\n- Mantenere sott'occhio i libri della tua wishlist e avvisarti se cambiano di prezzo, o ritornano disponibili.\n- Posso offrirti suggerimenti su nuovi libri da leggere in base alle tue preferenze.\n- Posso guidarti all'acquisto di nuovi libri, confrontando le varie recensioni per un particolare libro che ti interessa.\n\nPuoi utilizzarmi come preferisci, puoi impartirmi comandi, oppure utilizzare i bottoni del menu'. Iniziamo? :)''' card = CardFactory.hero_card(HeroCard(title=title, subtitle=subtitle, text=text)) return card