09-19-2024 06:50 AM
I have created a bot which anyone in my organization can use to raise a request with my team. Once any user sends a message , the bot gets that user's ID and Message and sends it into my team space. The bot gives a reply button. I want to add a functionality that whoever in the space clicks on reply button, it should open the chat of that user directly on webex app. Right now, it open the mail of that user
Any ideas how to do it.
This is the current function
def notify_team(self, user_email, user_query):
"""
Sends an adaptive card with the request details and a "Reply" button to the target space.
"""
# Define the adaptive card with a "Reply" button using mailto:
request_card = {
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": f"**New Request from {user_email}**",
"weight": "Bolder",
"size": "Medium"
},
{
"type": "TextBlock",
"text": f"**Request:** {user_query}",
"wrap": True
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "Reply",
"url": f"mailto:{user_email}"
}
]
}
Solved! Go to Solution.
09-20-2024 01:37 AM
Hello @Muhammad-Ali6,
Thanks for your patience so far!
So, in such scenario where you've to send a one-to-one email upon a Card submission, you can't use the "Email" as a link to redirect the communication to that email ID.
Because it's just a email ID, the "Action.OpenURL" or, the Submit operation doesn't know how to open this Email link as a Webex 1-1 Chat space. It'd just consider it as a Email ID or, Email link only.
And, anyway "mailto:{}" is not a Webex supported chat message format to send even 1-1 chat.
Now if you talk about a Webex Space, then for a space - there is a URL format in the and that's a Webex defined format i.e., webexteams://im?space=<webex_space_UUID>
Even though if you use this Space Webex URL for "mailto:{}", still won't work. Because this "mailto:{}" is not a Webex defined trigger.
What you need here is a Webex Webhook!
You can just simply have a "Action.Submit" behind the Submit button and hitting that Submit button should trigger an "Attachment Action" webhook.
How to create such Webhook? Follow the documentation of /create-a-webhook REST API here - https://developer.webex.com/docs/api/v1/webhooks/create-a-webhook
So, from the Webhook response, you should be able to fetch the User response like,
- his/her question
- his/her emailID
Now, you need to use that person Email ID in the "toPersonEmail" request parameter and you need to make a API request using the Bot token for https://developer.webex.com/docs/api/v1/messages/create-a-message REST API.
That's how it'd open a 1-1 chat with the Bot and the personEmail. And that's the only way to achieve it.
Please note: Webhook needs Public URL and for test purpose, you can get a public URL here - https://webhook.site
But this https://webhook.site can be used only for test purpose, don't use such public URL received from that portal for Production purpose.
Let us know for any further queries.
Regards!
Sandip
09-20-2024 01:37 AM
Hello @Muhammad-Ali6,
Thanks for your patience so far!
So, in such scenario where you've to send a one-to-one email upon a Card submission, you can't use the "Email" as a link to redirect the communication to that email ID.
Because it's just a email ID, the "Action.OpenURL" or, the Submit operation doesn't know how to open this Email link as a Webex 1-1 Chat space. It'd just consider it as a Email ID or, Email link only.
And, anyway "mailto:{}" is not a Webex supported chat message format to send even 1-1 chat.
Now if you talk about a Webex Space, then for a space - there is a URL format in the and that's a Webex defined format i.e., webexteams://im?space=<webex_space_UUID>
Even though if you use this Space Webex URL for "mailto:{}", still won't work. Because this "mailto:{}" is not a Webex defined trigger.
What you need here is a Webex Webhook!
You can just simply have a "Action.Submit" behind the Submit button and hitting that Submit button should trigger an "Attachment Action" webhook.
How to create such Webhook? Follow the documentation of /create-a-webhook REST API here - https://developer.webex.com/docs/api/v1/webhooks/create-a-webhook
So, from the Webhook response, you should be able to fetch the User response like,
- his/her question
- his/her emailID
Now, you need to use that person Email ID in the "toPersonEmail" request parameter and you need to make a API request using the Bot token for https://developer.webex.com/docs/api/v1/messages/create-a-message REST API.
That's how it'd open a 1-1 chat with the Bot and the personEmail. And that's the only way to achieve it.
Please note: Webhook needs Public URL and for test purpose, you can get a public URL here - https://webhook.site
But this https://webhook.site can be used only for test purpose, don't use such public URL received from that portal for Production purpose.
Let us know for any further queries.
Regards!
Sandip
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide