cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
146
Views
1
Helpful
1
Replies

Need help to open a user chat using reply button

Muhammad-Ali6
Level 1
Level 1

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}"
}
]
}
1 Accepted Solution

sandiban
Cisco Employee
Cisco Employee

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

View solution in original post

1 Reply 1

sandiban
Cisco Employee
Cisco Employee

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