cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

If your Cloud Collaboration question is not answered quickly, please email devsupport@webex.com for additional help

407
Views
0
Helpful
4
Replies
Highlighted
Beginner

webex bot post contents of an email into a room

I am interested in using webex bots or anything else that would take a body of an email and post it into a webex room.  We have automated emails that come from a system and I would prefer those to be in a webex space that would get noticed sooner.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Here's a version of your script that variable-izes things:

url = 'https://webexapis.com/v1/messages'

message = '**Test Message**'
roomId = 'Y2lzY29zcGFyazovL3Vz***********************************************L1mYzRhYTM2YjVi'
token = 'NGEyYjhlMGItZjg1*********************************************17ae04-c4aa-4444-9f54-4bebcee07305'

payload = {
    'roomId': roomId,
    'markdown': message
}

headers = {
  'Authorization': f'Bearer { token }',
  'Content-Type': 'application/json'
}

response = requests.request( 'POST', url, headers = headers, json = payload )

print( response.text.encode( 'utf8'  ))

View solution in original post

4 REPLIES 4
Highlighted
Cisco Employee

Hello,

 

Bot tokens can be used to message Webex Teams spaces that the bot has been added to using the POST method for the /meetings endpoint, documented at https://developer.webex.com/docs/api/v1/messages/create-a-message. 

Highlighted

I have been playing with the bots and i have a python script that will post what i type in the script but i am having some trouble with adding a variable.  I want the message to be a variable that I can input later.

 

import requests


payload = "{\r\n  \"roomId\": \"Y2lzY29zcGFyazovL3Vz***********************************************L1mYzRhYTM2YjVi\",\r\n  \"markdown\": \"  Message   \"\r\n}"
headers = {
  'Authorization''Bearer NGEyYjhlMGItZjg1*********************************************17ae04-c4aa-4444-9f54-4bebcee07305',
  'Content-Type''application/json'
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))

 

Highlighted

Here's a version of your script that variable-izes things:

url = 'https://webexapis.com/v1/messages'

message = '**Test Message**'
roomId = 'Y2lzY29zcGFyazovL3Vz***********************************************L1mYzRhYTM2YjVi'
token = 'NGEyYjhlMGItZjg1*********************************************17ae04-c4aa-4444-9f54-4bebcee07305'

payload = {
    'roomId': roomId,
    'markdown': message
}

headers = {
  'Authorization': f'Bearer { token }',
  'Content-Type': 'application/json'
}

response = requests.request( 'POST', url, headers = headers, json = payload )

print( response.text.encode( 'utf8'  ))

View solution in original post

Highlighted

Thank you that worked

 

I added message = (input_data['message']) this so I can handle inputs.  That is a bit closer to what I want.  Thank you

This widget could not be displayed.