03-22-2022 08:23 AM
I am using a webex application and can create spaces.
How can I create a webhook to post messages to my spaces from an external application?
Any pointer would be appreciated.
Thanks
Solved! Go to Solution.
03-22-2022 08:55 AM
The page I linked gives you the URL for the POST: https://webexapis.com/v1/messages
The parameters are described at the page. You do not need all off them, mostly I use markdown and either toPersonEmail or roomId, depending on the use case.
The roomId can be fetched by listing all rooms you're in: https://developer.webex.com/docs/api/v1/rooms/list-rooms. Do not use the UUID-form you get from CRTL-SHIFT-K and that can be used for the protocol handlers you mentioned. You have to use the base64 encoded ones as returned by the list-rooms endpoint.
If you want to sent the bot the message to a person directly, you may also specify the mail address instead in the toPersonEmail parameter.
03-22-2022 08:26 AM
A webhook is used to notify your application of an event.
If you want to post something to a space, simply create a bot and use the bot's access token along with https://developer.webex.com/docs/api/v1/messages/create-a-message
03-22-2022 08:45 AM
Thanks, I have created a bot, got my access token, now I need more help for finding the right POST arguments...
From the space I want to post to, I found the space link which looks like:
webexteams://im?space=<uuid>
How can I find out the URL to use to post the message? how about roomId, is it the space uuid?
Thanks!
03-22-2022 08:55 AM
The page I linked gives you the URL for the POST: https://webexapis.com/v1/messages
The parameters are described at the page. You do not need all off them, mostly I use markdown and either toPersonEmail or roomId, depending on the use case.
The roomId can be fetched by listing all rooms you're in: https://developer.webex.com/docs/api/v1/rooms/list-rooms. Do not use the UUID-form you get from CRTL-SHIFT-K and that can be used for the protocol handlers you mentioned. You have to use the base64 encoded ones as returned by the list-rooms endpoint.
If you want to sent the bot the message to a person directly, you may also specify the mail address instead in the toPersonEmail parameter.
03-22-2022 09:57 AM
Ahhh, thanks for the clarification, it makes sense now,
I did not know that the panel on the right side was live on actual webex spaces! Clever!
I managed to send a message to my space, thank you!
03-22-2022 12:38 PM
One extra step that is needed and was not documented, is that the bot email address must be explicitly added to the space.
I failed to do that and got this error message:
Error postMessage failed: request failed with status code 404, {"message":"Could not find a room with provided ID.","errors"...
I thought my roomID was wrong!
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